sam0/uart: add support for hardware flow control
This commit is contained in:
parent
c9955f9c74
commit
bd06772980
@ -28,6 +28,9 @@ CFLAGS += -DDONT_USE_PREDEFINED_PERIPHERALS_HANDLERS
|
|||||||
# For Cortex-M cpu we use the common cortexm.ld linker script
|
# For Cortex-M cpu we use the common cortexm.ld linker script
|
||||||
LINKER_SCRIPT ?= cortexm.ld
|
LINKER_SCRIPT ?= cortexm.ld
|
||||||
|
|
||||||
|
# define sam0 specific pseudomodules
|
||||||
|
PSEUDOMODULES += sam0_periph_uart_hw_fc
|
||||||
|
|
||||||
# include sam0 common periph drivers
|
# include sam0 common periph drivers
|
||||||
USEMODULE += sam0_common_periph
|
USEMODULE += sam0_common_periph
|
||||||
|
|
||||||
|
|||||||
@ -211,6 +211,10 @@ typedef struct {
|
|||||||
SercomUsart *dev; /**< pointer to the used UART device */
|
SercomUsart *dev; /**< pointer to the used UART device */
|
||||||
gpio_t rx_pin; /**< pin used for RX */
|
gpio_t rx_pin; /**< pin used for RX */
|
||||||
gpio_t tx_pin; /**< pin used for TX */
|
gpio_t tx_pin; /**< pin used for TX */
|
||||||
|
#ifdef MODULE_SAM0_PERIPH_UART_HW_FC
|
||||||
|
gpio_t rts_pin; /**< pin used for RTS */
|
||||||
|
gpio_t cts_pin; /**< pin used for CTS */
|
||||||
|
#endif
|
||||||
gpio_mux_t mux; /**< alternative function for pins */
|
gpio_mux_t mux; /**< alternative function for pins */
|
||||||
uart_rxpad_t rx_pad; /**< pad selection for RX line */
|
uart_rxpad_t rx_pad; /**< pad selection for RX line */
|
||||||
uart_txpad_t tx_pad; /**< pad selection for TX line */
|
uart_txpad_t tx_pad; /**< pad selection for TX line */
|
||||||
|
|||||||
@ -80,6 +80,19 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
gpio_set(uart_config[uart].tx_pin);
|
gpio_set(uart_config[uart].tx_pin);
|
||||||
gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux);
|
gpio_init_mux(uart_config[uart].tx_pin, uart_config[uart].mux);
|
||||||
|
|
||||||
|
#ifdef MODULE_SAM0_PERIPH_UART_HW_FC
|
||||||
|
/* If RTS/CTS needed, enable them */
|
||||||
|
if (uart_config[uart].tx_pad == UART_PAD_TX_0_RTS_2_CTS_3) {
|
||||||
|
/* Ensure RTS is defined */
|
||||||
|
if (uart_config[uart].rts_pin != GPIO_UNDEF) {
|
||||||
|
gpio_init_mux(uart_config[uart].rts_pin, uart_config[uart].mux);
|
||||||
|
}
|
||||||
|
/* Ensure CTS is defined */
|
||||||
|
if (uart_config[uart].cts_pin != GPIO_UNDEF) {
|
||||||
|
gpio_init_mux(uart_config[uart].cts_pin, uart_config[uart].mux);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* enable peripheral clock */
|
/* enable peripheral clock */
|
||||||
sercom_clk_en(dev(uart));
|
sercom_clk_en(dev(uart));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user