1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/sam0_common: implement uart_tx_ondemand

This commit is contained in:
Benjamin Valentin 2023-11-22 19:21:32 +01:00
parent fc9669bcfd
commit 60f8468191
4 changed files with 21 additions and 1 deletions

View File

@ -29,6 +29,7 @@ config CPU_COMMON_SAM0
select HAS_PERIPH_UART_NONBLOCKING select HAS_PERIPH_UART_NONBLOCKING
select HAS_PERIPH_UART_RECONFIGURE select HAS_PERIPH_UART_RECONFIGURE
select HAS_PERIPH_UART_RXSTART_IRQ select HAS_PERIPH_UART_RXSTART_IRQ
select HAS_PERIPH_UART_TX_ONDEMAND
select HAS_PERIPH_WDT select HAS_PERIPH_WDT
select HAS_PERIPH_WDT_CB select HAS_PERIPH_WDT_CB
select HAS_PERIPH_WDT_WARNING_PERIOD select HAS_PERIPH_WDT_WARNING_PERIOD

View File

@ -27,6 +27,7 @@ FEATURES_PROVIDED += periph_uart_modecfg
FEATURES_PROVIDED += periph_uart_nonblocking FEATURES_PROVIDED += periph_uart_nonblocking
FEATURES_PROVIDED += periph_uart_reconfigure FEATURES_PROVIDED += periph_uart_reconfigure
FEATURES_PROVIDED += periph_uart_rxstart_irq FEATURES_PROVIDED += periph_uart_rxstart_irq
FEATURES_PROVIDED += periph_uart_tx_ondemand
FEATURES_PROVIDED += periph_wdt periph_wdt_cb periph_wdt_warning_period FEATURES_PROVIDED += periph_wdt periph_wdt_cb periph_wdt_warning_period
FEATURES_CONFLICT += periph_rtc:periph_rtt FEATURES_CONFLICT += periph_rtc:periph_rtt

View File

@ -188,6 +188,7 @@ typedef enum {
UART_FLAG_NONE = 0x0, /**< No flags set */ UART_FLAG_NONE = 0x0, /**< No flags set */
UART_FLAG_RUN_STANDBY = 0x1, /**< run SERCOM in standby mode */ UART_FLAG_RUN_STANDBY = 0x1, /**< run SERCOM in standby mode */
UART_FLAG_WAKEUP = 0x2, /**< wake from sleep on receive */ UART_FLAG_WAKEUP = 0x2, /**< wake from sleep on receive */
UART_FLAG_TX_ONDEMAND = 0x4, /**< Only enable TX pin on demand */
} uart_flag_t; } uart_flag_t;
#ifndef DOXYGEN #ifndef DOXYGEN

View File

@ -129,6 +129,22 @@ static void _set_baud(uart_t uart, uint32_t baudrate, uint32_t f_src)
#endif #endif
} }
void uart_enable_tx(uart_t uart)
{
/* configure RX pin */
if (uart_config[uart].tx_pin != GPIO_UNDEF) {
gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux);
}
}
void uart_disable_tx(uart_t uart)
{
/* configure RX pin */
if (uart_config[uart].tx_pin != GPIO_UNDEF) {
gpio_init_mux(uart_config[uart].tx_pin, GPIO_MUX_A);
}
}
static void _configure_pins(uart_t uart) static void _configure_pins(uart_t uart)
{ {
/* configure RX pin */ /* configure RX pin */
@ -138,7 +154,8 @@ static void _configure_pins(uart_t uart)
} }
/* configure TX pin */ /* configure TX pin */
if (uart_config[uart].tx_pin != GPIO_UNDEF) { if (uart_config[uart].tx_pin != GPIO_UNDEF &&
!(uart_config[uart].flags & UART_FLAG_TX_ONDEMAND)) {
gpio_set(uart_config[uart].tx_pin); gpio_set(uart_config[uart].tx_pin);
gpio_init(uart_config[uart].tx_pin, GPIO_OUT); gpio_init(uart_config[uart].tx_pin, GPIO_OUT);
gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux); gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux);