Skip to content

Commit 7179ef5

Browse files
ccli8kartben
authored andcommitted
drivers: serial: numaker: support hw-flow-control
This honors dts config hw-flow-control to enable flow control cts/rts at driver init stage. Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
1 parent 1f92890 commit 7179ef5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/serial/uart_numaker.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ static int uart_numaker_init(const struct device *dev)
231231

232232
UART_Open(config->uart, pData->ucfg.baudrate);
233233

234+
if (pData->ucfg.flow_ctrl == UART_CFG_FLOW_CTRL_NONE) {
235+
UART_DisableFlowCtrl(config->uart);
236+
} else if (pData->ucfg.flow_ctrl == UART_CFG_FLOW_CTRL_RTS_CTS) {
237+
UART_EnableFlowCtrl(config->uart);
238+
} else {
239+
LOG_ERR("H/W flow control (%d) not support", pData->ucfg.flow_ctrl);
240+
return -ENOTSUP;
241+
}
242+
234243
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
235244
config->irq_config_func(dev);
236245
#endif
@@ -439,6 +448,9 @@ static DEVICE_API(uart, uart_numaker_driver_api) = {
439448
.ucfg = \
440449
{ \
441450
.baudrate = DT_INST_PROP(inst, current_speed), \
451+
.flow_ctrl = COND_CODE_1(DT_INST_PROP_OR(inst, hw_flow_control, 0),\
452+
(UART_CFG_FLOW_CTRL_RTS_CTS), \
453+
(UART_CFG_FLOW_CTRL_NONE)), \
442454
}, \
443455
}; \
444456
\

0 commit comments

Comments
 (0)