Skip to content

Commit 16894c2

Browse files
author
Owen
authored
Merge pull request #230 from sparkfun/addFlowControl
2 parents 5227c1c + ddda09e commit 16894c2

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Diff for: cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ am_hal_uart_transfer_t;
172172

173173
// Flow control
174174
#define AM_HAL_UART_FLOW_CTRL_NONE 0
175-
#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART_CR_CTSEN_Msk
176-
#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART_CR_RTSEN_Msk
175+
#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART0_CR_CTSEN_Msk
176+
#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART0_CR_RTSEN_Msk
177177
#define AM_HAL_UART_FLOW_CTRL_RTS_CTS (UART0_CR_CTSEN_Msk | \
178178
UART0_CR_RTSEN_Msk)
179179
// FIFO enable/disable.

Diff for: cores/arduino/ard_sup/uart/ap3_uart.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)