driver: uart: npcx: fix coding style
Fix the coding style by clang-format tool. Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
This commit is contained in:
parent
fe5a5edfc8
commit
3ba7874cd5
1 changed files with 39 additions and 36 deletions
|
@ -125,8 +125,7 @@ static void uart_npcx_dis_all_tx_interrupts(const struct device *dev)
|
||||||
struct uart_reg *const inst = config->inst;
|
struct uart_reg *const inst = config->inst;
|
||||||
|
|
||||||
/* Disable all Tx interrupts */
|
/* Disable all Tx interrupts */
|
||||||
inst->UFTCTL &= ~(BIT(NPCX_UFTCTL_TEMPTY_LVL_EN) |
|
inst->UFTCTL &= ~(BIT(NPCX_UFTCTL_TEMPTY_LVL_EN) | BIT(NPCX_UFTCTL_TEMPTY_EN) |
|
||||||
BIT(NPCX_UFTCTL_TEMPTY_EN) |
|
|
||||||
BIT(NPCX_UFTCTL_NXMIP_EN));
|
BIT(NPCX_UFTCTL_NXMIP_EN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +136,9 @@ static void uart_npcx_clear_rx_fifo(const struct device *dev)
|
||||||
uint8_t scratch;
|
uint8_t scratch;
|
||||||
|
|
||||||
/* Read all dummy bytes out from Rx FIFO */
|
/* Read all dummy bytes out from Rx FIFO */
|
||||||
while (uart_npcx_rx_fifo_available(dev))
|
while (uart_npcx_rx_fifo_available(dev)) {
|
||||||
scratch = inst->URBUF;
|
scratch = inst->URBUF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uart_npcx_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
|
static int uart_npcx_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
|
||||||
|
@ -341,8 +341,9 @@ static int uart_npcx_poll_in(const struct device *dev, unsigned char *c)
|
||||||
*/
|
*/
|
||||||
static void uart_npcx_poll_out(const struct device *dev, unsigned char c)
|
static void uart_npcx_poll_out(const struct device *dev, unsigned char c)
|
||||||
{
|
{
|
||||||
while (!uart_npcx_fifo_fill(dev, &c, 1))
|
while (!uart_npcx_fifo_fill(dev, &c, 1)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !CONFIG_UART_INTERRUPT_DRIVEN */
|
#else /* !CONFIG_UART_INTERRUPT_DRIVEN */
|
||||||
|
@ -357,8 +358,9 @@ static int uart_npcx_poll_in(const struct device *dev, unsigned char *c)
|
||||||
struct uart_reg *const inst = config->inst;
|
struct uart_reg *const inst = config->inst;
|
||||||
|
|
||||||
/* Rx single byte buffer is not full */
|
/* Rx single byte buffer is not full */
|
||||||
if (!IS_BIT_SET(inst->UICTRL, NPCX_UICTRL_RBF))
|
if (!IS_BIT_SET(inst->UICTRL, NPCX_UICTRL_RBF)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
*c = inst->URBUF;
|
*c = inst->URBUF;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -373,8 +375,9 @@ static void uart_npcx_poll_out(const struct device *dev, unsigned char c)
|
||||||
struct uart_reg *const inst = config->inst;
|
struct uart_reg *const inst = config->inst;
|
||||||
|
|
||||||
/* Wait while Tx single byte buffer is ready to send */
|
/* Wait while Tx single byte buffer is ready to send */
|
||||||
while (!IS_BIT_SET(inst->UICTRL, NPCX_UICTRL_TBE))
|
while (!IS_BIT_SET(inst->UICTRL, NPCX_UICTRL_TBE)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
inst->UTBUF = c;
|
inst->UTBUF = c;
|
||||||
}
|
}
|
||||||
|
@ -388,14 +391,17 @@ static int uart_npcx_err_check(const struct device *dev)
|
||||||
uint32_t err = 0U;
|
uint32_t err = 0U;
|
||||||
uint8_t stat = inst->USTAT;
|
uint8_t stat = inst->USTAT;
|
||||||
|
|
||||||
if (IS_BIT_SET(stat, NPCX_USTAT_DOE))
|
if (IS_BIT_SET(stat, NPCX_USTAT_DOE)) {
|
||||||
err |= UART_ERROR_OVERRUN;
|
err |= UART_ERROR_OVERRUN;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_BIT_SET(stat, NPCX_USTAT_PE))
|
if (IS_BIT_SET(stat, NPCX_USTAT_PE)) {
|
||||||
err |= UART_ERROR_PARITY;
|
err |= UART_ERROR_PARITY;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_BIT_SET(stat, NPCX_USTAT_FE))
|
if (IS_BIT_SET(stat, NPCX_USTAT_FE)) {
|
||||||
err |= UART_ERROR_FRAMING;
|
err |= UART_ERROR_FRAMING;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -480,8 +486,7 @@ static int uart_npcx_init(const struct device *dev)
|
||||||
* If apb2's clock is not 15MHz, we need to find the other optimized
|
* If apb2's clock is not 15MHz, we need to find the other optimized
|
||||||
* values of UPSR and UBAUD for baud rate 115200.
|
* values of UPSR and UBAUD for baud rate 115200.
|
||||||
*/
|
*/
|
||||||
ret = clock_control_get_rate(clk_dev, (clock_control_subsys_t)&config->clk_cfg,
|
ret = clock_control_get_rate(clk_dev, (clock_control_subsys_t)&config->clk_cfg, &uart_rate);
|
||||||
&uart_rate);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
LOG_ERR("Get UART clock rate error %d", ret);
|
LOG_ERR("Get UART clock rate error %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -570,15 +575,13 @@ static int uart_npcx_init(const struct device *dev)
|
||||||
.clk_cfg = NPCX_DT_CLK_CFG_ITEM(i), \
|
.clk_cfg = NPCX_DT_CLK_CFG_ITEM(i), \
|
||||||
.uart_rx_wui = NPCX_DT_WUI_ITEM_BY_NAME(0, uart_rx), \
|
.uart_rx_wui = NPCX_DT_WUI_ITEM_BY_NAME(0, uart_rx), \
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(i), \
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(i), \
|
||||||
NPCX_UART_IRQ_CONFIG_FUNC_INIT(i) \
|
NPCX_UART_IRQ_CONFIG_FUNC_INIT(i)}; \
|
||||||
}; \
|
|
||||||
\
|
\
|
||||||
static struct uart_npcx_data uart_npcx_data_##i = { .baud_rate = DT_INST_PROP( \
|
static struct uart_npcx_data uart_npcx_data_##i = { \
|
||||||
i, current_speed) }; \
|
.baud_rate = DT_INST_PROP(i, current_speed)}; \
|
||||||
\
|
\
|
||||||
DEVICE_DT_INST_DEFINE(i, &uart_npcx_init, NULL, &uart_npcx_data_##i, \
|
DEVICE_DT_INST_DEFINE(i, &uart_npcx_init, NULL, &uart_npcx_data_##i, &uart_npcx_cfg_##i, \
|
||||||
&uart_npcx_cfg_##i, PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
|
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, &uart_npcx_driver_api); \
|
||||||
&uart_npcx_driver_api); \
|
|
||||||
\
|
\
|
||||||
NPCX_UART_IRQ_CONFIG_FUNC(i)
|
NPCX_UART_IRQ_CONFIG_FUNC(i)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue