1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Implement invert for HardwareSerial (#6816)

* Simple i/f to turn on inverted logic on UART0.

* Refactor invert from HardwareSerial to uart

* Final refactoring of invert bits into config bitmap.

* Overload instead of default arg for subclassing.

* Prevent unwanted effects if setting invert on other than UART0 - only that has these flags defined and documented.
This commit is contained in:
Dirk O. Kaar
2019-11-20 17:17:42 +01:00
committed by Earle F. Philhower, III
parent b478429fe4
commit 007e495e0d
5 changed files with 19 additions and 9 deletions

View File

@ -577,7 +577,7 @@ uart_get_baudrate(uart_t* uart)
}
uart_t*
uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin, size_t rx_size)
uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin, size_t rx_size, bool invert)
{
uart_t* uart = (uart_t*) malloc(sizeof(uart_t));
if(uart == NULL)
@ -657,6 +657,10 @@ uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin, size_t rx
}
uart_set_baudrate(uart, baudrate);
if(uart->uart_nr == UART0 && invert)
{
config |= BIT(UCDTRI) | BIT(UCRTSI) | BIT(UCTXI) | BIT(UCDSRI) | BIT(UCCTSI) | BIT(UCRXI);
}
USC0(uart->uart_nr) = config;
if(!gdbstub_has_uart_isr_control() || uart->uart_nr != UART0) {