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

Fix UART pins setting (#2098) (#2141)

This commit is contained in:
Ivan Grokhotkov 2016-06-20 12:08:33 +08:00 committed by GitHub
parent 1640cc302d
commit 79883e9d35

View File

@ -162,19 +162,19 @@ uart_t* uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin)
uart->rx_enabled = (mode != UART_TX_ONLY);
uart->tx_enabled = (mode != UART_RX_ONLY);
uart->rx_pin = (uart->rx_enabled)?3:255;
if(uart->rx_enabled) {
if(uart->tx_enabled) {
if (tx_pin == 2) {
uart->tx_pin = 2;
pinMode(uart->rx_pin, FUNCTION_4);
pinMode(uart->tx_pin, FUNCTION_4);
} else {
uart->tx_pin = 1;
pinMode(uart->rx_pin, SPECIAL);
pinMode(uart->tx_pin, FUNCTION_0);
}
} else {
uart->tx_pin = 255;
}
if(uart->tx_enabled) {
pinMode(uart->tx_pin, SPECIAL);
if(uart->rx_enabled) {
pinMode(uart->rx_pin, SPECIAL);
}
IOSWAP &= ~(1 << IOSWAPU0);
break;