@@ -296,6 +296,22 @@ ap3_err_t Uart::set_config(HardwareSerial_Config_e HWSconfig)
296296 retval = AP3_INVALID_ARG;
297297 break ;
298298 }
299+
300+ // Setup flow control
301+ _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_NONE;
302+ if (_pinRTS != AP3_UART_PIN_UNUSED && _pinCTS != AP3_UART_PIN_UNUSED)
303+ {
304+ _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_CTS;
305+ }
306+ else if (_pinRTS != AP3_UART_PIN_UNUSED)
307+ {
308+ _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_ONLY;
309+ }
310+ else if (_pinCTS != AP3_UART_PIN_UNUSED)
311+ {
312+ _config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_CTS_ONLY;
313+ }
314+
299315 return retval;
300316}
301317
@@ -375,7 +391,7 @@ ap3_err_t Uart::_begin(void)
375391
376392 if (_pinRTS != AP3_UART_PIN_UNUSED)
377393 {
378- retval = ap3_uart_pad_funcsel (_instance, AP3_UART_TX , ap3_gpio_pin2pad (_pinRTS), &funcsel);
394+ retval = ap3_uart_pad_funcsel (_instance, AP3_UART_RTS , ap3_gpio_pin2pad (_pinRTS), &funcsel);
379395 if (retval != AP3_OK)
380396 {
381397 return retval;
@@ -391,7 +407,7 @@ ap3_err_t Uart::_begin(void)
391407
392408 if (_pinCTS != AP3_UART_PIN_UNUSED)
393409 {
394- retval = ap3_uart_pad_funcsel (_instance, AP3_UART_RX , ap3_gpio_pin2pad (_pinCTS), &funcsel);
410+ retval = ap3_uart_pad_funcsel (_instance, AP3_UART_CTS , ap3_gpio_pin2pad (_pinCTS), &funcsel);
395411 if (retval != AP3_OK)
396412 {
397413 return retval;
0 commit comments