Skip to content
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

drivers/periph/uart: add periph_uart_tx_ondemand feature #20108

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cpu/sam0_common: implement uart_tx_ondemand
  • Loading branch information
benpicco committed Dec 14, 2023
commit 60f84681917a0a3e755d0ee8b51939414aca2463
1 change: 1 addition & 0 deletions cpu/sam0_common/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ config CPU_COMMON_SAM0
select HAS_PERIPH_UART_NONBLOCKING
select HAS_PERIPH_UART_RECONFIGURE
select HAS_PERIPH_UART_RXSTART_IRQ
select HAS_PERIPH_UART_TX_ONDEMAND
select HAS_PERIPH_WDT
select HAS_PERIPH_WDT_CB
select HAS_PERIPH_WDT_WARNING_PERIOD
Expand Down
1 change: 1 addition & 0 deletions cpu/sam0_common/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FEATURES_PROVIDED += periph_uart_modecfg
FEATURES_PROVIDED += periph_uart_nonblocking
FEATURES_PROVIDED += periph_uart_reconfigure
FEATURES_PROVIDED += periph_uart_rxstart_irq
FEATURES_PROVIDED += periph_uart_tx_ondemand
FEATURES_PROVIDED += periph_wdt periph_wdt_cb periph_wdt_warning_period

FEATURES_CONFLICT += periph_rtc:periph_rtt
Expand Down
1 change: 1 addition & 0 deletions cpu/sam0_common/include/periph_cpu_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ typedef enum {
UART_FLAG_NONE = 0x0, /**< No flags set */
UART_FLAG_RUN_STANDBY = 0x1, /**< run SERCOM in standby mode */
UART_FLAG_WAKEUP = 0x2, /**< wake from sleep on receive */
UART_FLAG_TX_ONDEMAND = 0x4, /**< Only enable TX pin on demand */
} uart_flag_t;

#ifndef DOXYGEN
Expand Down
19 changes: 18 additions & 1 deletion cpu/sam0_common/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ static void _set_baud(uart_t uart, uint32_t baudrate, uint32_t f_src)
#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)
{
/* configure RX pin */
Expand All @@ -138,7 +154,8 @@ static void _configure_pins(uart_t uart)
}

/* 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_init(uart_config[uart].tx_pin, GPIO_OUT);
gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux);
Expand Down