Skip to content

Commit 66b2b0e

Browse files
author
Nathan Seidle
committed
Add end and flush functions.
These come from am_bsp_uart_printf_disable().
1 parent 55ba5ab commit 66b2b0e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

+16-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,20 @@ void Uart::begin(unsigned long baudrate, am_hal_uart_config_t config)
6767

6868
void Uart::end()
6969
{
70-
// todo:
70+
if (_handle != NULL)
71+
{
72+
flush();
73+
74+
// Power down the UART, and surrender the handle.
75+
am_hal_uart_power_control(_handle, AM_HAL_SYSCTRL_DEEPSLEEP, false);
76+
am_hal_uart_deinitialize(_handle);
77+
78+
// Disable the UART pins.
79+
am_hal_gpio_pinconfig(_pinTX, g_AM_HAL_GPIO_DISABLE);
80+
am_hal_gpio_pinconfig(_pinRX, g_AM_HAL_GPIO_DISABLE);
81+
82+
_handle = NULL;
83+
}
7184
}
7285

7386
int Uart::available()
@@ -93,7 +106,8 @@ int Uart::read()
93106

94107
void Uart::flush()
95108
{
96-
// todo:
109+
// Make sure the UART has finished sending everything it's going to send.
110+
am_hal_uart_tx_flush(_handle);
97111
}
98112

99113
size_t Uart::write(const uint8_t data)

0 commit comments

Comments
 (0)