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:
parent
b39960a5df
commit
e757f188c8
1 changed files with 14 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
||||||
struct usart_sam_dev_cfg {
|
struct usart_sam_dev_cfg {
|
||||||
Usart *regs;
|
Usart *regs;
|
||||||
uint32_t periph_id;
|
uint32_t periph_id;
|
||||||
|
bool hw_flow_control;
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#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;
|
const struct usart_sam_dev_cfg *const cfg = dev->config;
|
||||||
struct usart_sam_dev_data *const dev_data = dev->data;
|
struct usart_sam_dev_data *const dev_data = dev->data;
|
||||||
Usart *const usart = cfg->regs;
|
Usart *const usart = cfg->regs;
|
||||||
|
uint32_t us_mr;
|
||||||
|
|
||||||
/* Enable USART clock in PMC */
|
/* Enable USART clock in PMC */
|
||||||
soc_pmc_peripheral_enable(cfg->periph_id);
|
soc_pmc_peripheral_enable(cfg->periph_id);
|
||||||
|
@ -71,11 +73,17 @@ static int usart_sam_init(const struct device *dev)
|
||||||
usart->US_IDR = 0xFFFFFFFF;
|
usart->US_IDR = 0xFFFFFFFF;
|
||||||
|
|
||||||
/* 8 bits of data, no parity, 1 stop bit in normal mode */
|
/* 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_PAR_NO
|
||||||
| US_MR_CHRL_8_BIT
|
| US_MR_CHRL_8_BIT
|
||||||
| US_MR_USCLKS_MCK
|
| US_MR_USCLKS_MCK
|
||||||
| US_MR_CHMODE_NORMAL;
|
| 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 */
|
/* Set baud rate */
|
||||||
retval = baudrate_set(usart, dev_data->baud_rate,
|
retval = baudrate_set(usart, dev_data->baud_rate,
|
||||||
|
@ -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 = { \
|
static const struct usart_sam_dev_cfg usart##n##_sam_config = { \
|
||||||
.regs = (Usart *)DT_INST_REG_ADDR(n), \
|
.regs = (Usart *)DT_INST_REG_ADDR(n), \
|
||||||
.periph_id = DT_INST_PROP(n, peripheral_id), \
|
.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), \
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
|
||||||
\
|
\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue