Skip to content

Add flow control #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cores/arduino/am_sdk_ap3/mcu/apollo3/hal/am_hal_uart.h
Original file line number Diff line number Diff line change
@@ -172,8 +172,8 @@ am_hal_uart_transfer_t;

// Flow control
#define AM_HAL_UART_FLOW_CTRL_NONE 0
#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART_CR_CTSEN_Msk
#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART_CR_RTSEN_Msk
#define AM_HAL_UART_FLOW_CTRL_CTS_ONLY UART0_CR_CTSEN_Msk
#define AM_HAL_UART_FLOW_CTRL_RTS_ONLY UART0_CR_RTSEN_Msk
#define AM_HAL_UART_FLOW_CTRL_RTS_CTS (UART0_CR_CTSEN_Msk | \
UART0_CR_RTSEN_Msk)
// FIFO enable/disable.
20 changes: 18 additions & 2 deletions cores/arduino/ard_sup/uart/ap3_uart.cpp
Original file line number Diff line number Diff line change
@@ -296,6 +296,22 @@ ap3_err_t Uart::set_config(HardwareSerial_Config_e HWSconfig)
retval = AP3_INVALID_ARG;
break;
}

//Setup flow control
_config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_NONE;
if(_pinRTS != AP3_UART_PIN_UNUSED && _pinCTS != AP3_UART_PIN_UNUSED)
{
_config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_CTS;
}
else if(_pinRTS != AP3_UART_PIN_UNUSED)
{
_config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_RTS_ONLY;
}
else if(_pinCTS != AP3_UART_PIN_UNUSED)
{
_config.ui32FlowControl = AM_HAL_UART_FLOW_CTRL_CTS_ONLY;
}

return retval;
}

@@ -375,7 +391,7 @@ ap3_err_t Uart::_begin(void)

if (_pinRTS != AP3_UART_PIN_UNUSED)
{
retval = ap3_uart_pad_funcsel(_instance, AP3_UART_TX, ap3_gpio_pin2pad(_pinRTS), &funcsel);
retval = ap3_uart_pad_funcsel(_instance, AP3_UART_RTS, ap3_gpio_pin2pad(_pinRTS), &funcsel);
if (retval != AP3_OK)
{
return retval;
@@ -391,7 +407,7 @@ ap3_err_t Uart::_begin(void)

if (_pinCTS != AP3_UART_PIN_UNUSED)
{
retval = ap3_uart_pad_funcsel(_instance, AP3_UART_RX, ap3_gpio_pin2pad(_pinCTS), &funcsel);
retval = ap3_uart_pad_funcsel(_instance, AP3_UART_CTS, ap3_gpio_pin2pad(_pinCTS), &funcsel);
if (retval != AP3_OK)
{
return retval;