drivers: serial: atmel_sam: Added hw flow control

Patch added hw flow control to usart driver

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
This commit is contained in:
Wojciech Slenska 2022-06-20 07:47:52 +02:00 committed by Carles Cufí
commit e757f188c8

View file

@ -26,6 +26,7 @@
struct usart_sam_dev_cfg {
Usart *regs;
uint32_t periph_id;
bool hw_flow_control;
const struct pinctrl_dev_config *pcfg;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
@ -53,6 +54,7 @@ static int usart_sam_init(const struct device *dev)
const struct usart_sam_dev_cfg *const cfg = dev->config;
struct usart_sam_dev_data *const dev_data = dev->data;
Usart *const usart = cfg->regs;
uint32_t us_mr;
/* Enable USART clock in PMC */
soc_pmc_peripheral_enable(cfg->periph_id);
@ -71,12 +73,18 @@ static int usart_sam_init(const struct device *dev)
usart->US_IDR = 0xFFFFFFFF;
/* 8 bits of data, no parity, 1 stop bit in normal mode */
usart->US_MR = US_MR_NBSTOP_1_BIT
us_mr = US_MR_NBSTOP_1_BIT
| US_MR_PAR_NO
| US_MR_CHRL_8_BIT
| US_MR_USCLKS_MCK
| US_MR_CHMODE_NORMAL;
if (cfg->hw_flow_control) {
us_mr |= US_MR_USART_MODE_HW_HANDSHAKING;
}
usart->US_MR = us_mr;
/* Set baud rate */
retval = baudrate_set(usart, dev_data->baud_rate,
SOC_ATMEL_SAM_MCK_FREQ_HZ);
@ -358,6 +366,7 @@ static const struct uart_driver_api usart_sam_driver_api = {
static const struct usart_sam_dev_cfg usart##n##_sam_config = { \
.regs = (Usart *)DT_INST_REG_ADDR(n), \
.periph_id = DT_INST_PROP(n, peripheral_id), \
.hw_flow_control = DT_INST_PROP(n, hw_flow_control), \
\
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
\