drivers: esp32: UART - use dts config for HW flow Control

- dts updated for UART1/2
- Additional check added to _INIT macro to configure flow control mode
- Additional check added to _INIT macro to set CTS/RTS gpios values
- Additional check added for gpio config

Signed-off-by: Mohamed ElShahawi <ExtremeGTX@hotmail.com>
This commit is contained in:
Mohamed ElShahawi 2019-08-23 00:53:22 +02:00 committed by Kumar Gala
commit bcd9e49f3f
2 changed files with 72 additions and 59 deletions

View file

@ -45,6 +45,7 @@
rx-pin = <9>;
rts-pin = <11>;
cts-pin = <6>;
hw-flow-control;
};
&uart2 {
@ -53,4 +54,5 @@
rx-pin = <16>;
rts-pin = <7>;
cts-pin = <8>;
hw-flow-control;
};

View file

@ -211,14 +211,18 @@ static int uart_esp32_configure_pins(struct device *dev)
cfg->signals.rx_in,
false);
if (cfg->pins.cts) {
esp32_rom_gpio_matrix_out(cfg->pins.cts,
cfg->signals.cts_in,
false,
false);
}
if (cfg->pins.rts) {
esp32_rom_gpio_matrix_in(cfg->pins.rts,
cfg->signals.rts_out,
false);
}
return 0;
}
@ -496,8 +500,13 @@ static const struct uart_esp32_config uart_esp32_cfg_port_##idx = { \
.pins = { \
.tx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_TX_PIN, \
.rx = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RX_PIN, \
.rts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RTS_PIN, \
COND_CODE_1(IS_ENABLED(DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL), \
(.rts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_RTS_PIN, \
.cts = DT_INST_##idx##_ESPRESSIF_ESP32_UART_CTS_PIN, \
), \
(.rts = 0, \
.cts = 0 \
)) \
}, \
\
.irq = { \
@ -512,7 +521,9 @@ static struct uart_esp32_data uart_esp32_data_##idx = { \
.parity = UART_CFG_PARITY_NONE, \
.stop_bits = UART_CFG_STOP_BITS_1, \
.data_bits = UART_CFG_DATA_BITS_8, \
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE \
COND_CODE_1(IS_ENABLED(DT_INST_##idx##_ESPRESSIF_ESP32_UART_HW_FLOW_CONTROL), \
(.flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS), \
(.flow_ctrl = UART_CFG_FLOW_CTRL_NONE)) \
} \
}; \
\