@@ -83,33 +83,33 @@ static int uart_silabs_eusart_err_check(const struct device *dev)
83
83
static int uart_silabs_eusart_fifo_fill (const struct device * dev , const uint8_t * tx_data , int len )
84
84
{
85
85
const struct uart_silabs_eusart_config * config = dev -> config ;
86
- int num_tx = 0 ;
86
+ int i = 0 ;
87
87
88
- while ((len - num_tx > 0 ) && (EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_TXFL )) {
89
- config -> eusart -> TXDATA = (uint32_t )tx_data [num_tx ++ ];
88
+ while ((i < len ) && (EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_TXFL )) {
89
+ config -> eusart -> TXDATA = (uint32_t )tx_data [i ++ ];
90
90
}
91
91
92
92
if (!(EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_TXFL )) {
93
93
EUSART_IntClear (config -> eusart , EUSART_IF_TXFL );
94
94
}
95
95
96
- return num_tx ;
96
+ return i ;
97
97
}
98
98
99
99
static int uart_silabs_eusart_fifo_read (const struct device * dev , uint8_t * rx_data , const int len )
100
100
{
101
101
const struct uart_silabs_eusart_config * config = dev -> config ;
102
- int num_rx = 0 ;
102
+ int i = 0 ;
103
103
104
- while ((len - num_rx > 0 ) && (EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_RXFL )) {
105
- rx_data [num_rx ++ ] = (uint8_t )config -> eusart -> RXDATA ;
104
+ while ((i < len ) && (EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_RXFL )) {
105
+ rx_data [i ++ ] = (uint8_t )config -> eusart -> RXDATA ;
106
106
}
107
107
108
108
if (!(EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_RXFL )) {
109
109
EUSART_IntClear (config -> eusart , EUSART_IF_RXFL );
110
110
}
111
111
112
- return num_rx ;
112
+ return i ;
113
113
}
114
114
115
115
static void uart_silabs_eusart_irq_tx_enable (const struct device * dev )
@@ -135,7 +135,7 @@ static int uart_silabs_eusart_irq_tx_complete(const struct device *dev)
135
135
136
136
EUSART_IntClear (config -> eusart , EUSART_IF_TXC );
137
137
138
- return (flags & EUSART_IF_TXC ) != 0 ;
138
+ return !! (flags & EUSART_IF_TXC );
139
139
}
140
140
141
141
static int uart_silabs_eusart_irq_tx_ready (const struct device * dev )
@@ -215,7 +215,7 @@ static void uart_silabs_eusart_isr(const struct device *dev)
215
215
}
216
216
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
217
217
218
- static inline EUSART_Parity_TypeDef uart_silabs_eusart_cfg2ll_parity (enum uart_config_parity parity )
218
+ static EUSART_Parity_TypeDef uart_silabs_eusart_cfg2ll_parity (enum uart_config_parity parity )
219
219
{
220
220
switch (parity ) {
221
221
case UART_CFG_PARITY_ODD :
@@ -241,8 +241,7 @@ static inline enum uart_config_parity uart_silabs_eusart_ll2cfg_parity(EUSART_Pa
241
241
}
242
242
}
243
243
244
- static inline EUSART_Stopbits_TypeDef
245
- uart_silabs_eusart_cfg2ll_stopbits (enum uart_config_stop_bits sb )
244
+ static EUSART_Stopbits_TypeDef uart_silabs_eusart_cfg2ll_stopbits (enum uart_config_stop_bits sb )
246
245
{
247
246
switch (sb ) {
248
247
case UART_CFG_STOP_BITS_0_5 :
@@ -275,8 +274,8 @@ uart_silabs_eusart_ll2cfg_stopbits(EUSART_Stopbits_TypeDef sb)
275
274
}
276
275
}
277
276
278
- static inline EUSART_Databits_TypeDef
279
- uart_silabs_eusart_cfg2ll_databits ( enum uart_config_data_bits db , enum uart_config_parity p )
277
+ static EUSART_Databits_TypeDef uart_silabs_eusart_cfg2ll_databits ( enum uart_config_data_bits db ,
278
+ enum uart_config_parity p )
280
279
{
281
280
switch (db ) {
282
281
case UART_CFG_DATA_BITS_7 :
@@ -324,14 +323,7 @@ uart_silabs_eusart_ll2cfg_databits(EUSART_Databits_TypeDef db, EUSART_Parity_Typ
324
323
}
325
324
}
326
325
327
- /**
328
- * @brief Get LL hardware flow control define from
329
- * Zephyr hardware flow control option.
330
- * @note Supports only UART_CFG_FLOW_CTRL_RTS_CTS and UART_CFG_FLOW_CTRL_RS485.
331
- * @param fc: Zephyr hardware flow control option.
332
- * @retval eusartHwFlowControlCtsAndRts, or eusartHwFlowControlNone.
333
- */
334
- static inline EUSART_HwFlowControl_TypeDef
326
+ static EUSART_HwFlowControl_TypeDef
335
327
uart_silabs_eusart_cfg2ll_hwctrl (enum uart_config_flow_control fc )
336
328
{
337
329
if (fc == UART_CFG_FLOW_CTRL_RTS_CTS ) {
@@ -341,13 +333,6 @@ uart_silabs_eusart_cfg2ll_hwctrl(enum uart_config_flow_control fc)
341
333
return eusartHwFlowControlNone ;
342
334
}
343
335
344
- /**
345
- * @brief Get Zephyr hardware flow control option from
346
- * LL hardware flow control define.
347
- * @note Supports only eusartHwFlowControlCtsAndRts.
348
- * @param fc: LL hardware flow control definition.
349
- * @retval UART_CFG_FLOW_CTRL_RTS_CTS, or UART_CFG_FLOW_CTRL_NONE.
350
- */
351
336
static inline enum uart_config_flow_control
352
337
uart_silabs_eusart_ll2cfg_hwctrl (EUSART_HwFlowControl_TypeDef fc )
353
338
{
@@ -382,12 +367,6 @@ static void uart_silabs_eusart_configure_peripheral(const struct device *dev, bo
382
367
}
383
368
}
384
369
385
- /**
386
- * @brief Main initializer for UART
387
- *
388
- * @param dev UART device to be initialized
389
- * @return int 0
390
- */
391
370
static int uart_silabs_eusart_init (const struct device * dev )
392
371
{
393
372
int err ;
@@ -421,11 +400,9 @@ static int uart_silabs_eusart_pm_action(const struct device *dev, enum pm_device
421
400
422
401
switch (action ) {
423
402
case PM_DEVICE_ACTION_SUSPEND :
424
- #ifdef EUSART_STATUS_TXIDLE
425
403
/* Wait for TX FIFO to flush before suspending */
426
404
while (!(EUSART_StatusGet (config -> eusart ) & EUSART_STATUS_TXIDLE )) {
427
405
}
428
- #endif
429
406
break ;
430
407
431
408
case PM_DEVICE_ACTION_RESUME :
@@ -462,8 +439,8 @@ static DEVICE_API(uart, uart_silabs_eusart_driver_api) = {
462
439
};
463
440
464
441
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
465
- #define UART_IRQ_HANDLER_FUNC (idx ) .irq_config_func = uart_silabs_eusart_config_func_##idx,
466
- #define UART_IRQ_HANDLER (idx ) \
442
+ #define SILABS_EUSART_IRQ_HANDLER_FUNC (idx ) .irq_config_func = uart_silabs_eusart_config_func_##idx,
443
+ #define SILABS_EUSART_IRQ_HANDLER (idx ) \
467
444
static void uart_silabs_eusart_config_func_##idx(const struct device *dev) \
468
445
{ \
469
446
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(idx, rx, irq), \
@@ -477,20 +454,21 @@ static DEVICE_API(uart, uart_silabs_eusart_driver_api) = {
477
454
irq_enable(DT_INST_IRQ_BY_NAME(idx, tx, irq)); \
478
455
}
479
456
#else
480
- #define UART_IRQ_HANDLER_FUNC (idx )
481
- #define UART_IRQ_HANDLER (idx )
457
+ #define SILABS_EUSART_IRQ_HANDLER_FUNC (idx )
458
+ #define SILABS_EUSART_IRQ_HANDLER (idx )
482
459
#endif
483
460
484
- #define UART_INIT (idx ) \
485
- UART_IRQ_HANDLER (idx) \
461
+ #define SILABS_EUSART_INIT (idx ) \
462
+ SILABS_EUSART_IRQ_HANDLER (idx); \
486
463
PINCTRL_DT_INST_DEFINE(idx); \
464
+ PM_DEVICE_DT_INST_DEFINE(idx, uart_silabs_eusart_pm_action); \
487
465
\
488
466
static const struct uart_silabs_eusart_config uart_silabs_eusart_cfg_##idx = { \
489
467
.eusart = (EUSART_TypeDef *)DT_INST_REG_ADDR(idx), \
490
468
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
491
469
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(idx)), \
492
470
.clock_cfg = SILABS_DT_INST_CLOCK_CFG(idx), \
493
- UART_IRQ_HANDLER_FUNC (idx) \
471
+ SILABS_EUSART_IRQ_HANDLER_FUNC (idx) \
494
472
}; \
495
473
\
496
474
static struct uart_silabs_eusart_data uart_silabs_eusart_data_##idx = { \
@@ -505,11 +483,9 @@ static DEVICE_API(uart, uart_silabs_eusart_driver_api) = {
505
483
}, \
506
484
}; \
507
485
\
508
- PM_DEVICE_DT_INST_DEFINE(idx, uart_silabs_eusart_pm_action); \
509
- \
510
486
DEVICE_DT_INST_DEFINE(idx, uart_silabs_eusart_init, PM_DEVICE_DT_INST_GET(idx), \
511
487
&uart_silabs_eusart_data_##idx, &uart_silabs_eusart_cfg_##idx, \
512
488
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
513
489
&uart_silabs_eusart_driver_api);
514
490
515
- DT_INST_FOREACH_STATUS_OKAY (UART_INIT )
491
+ DT_INST_FOREACH_STATUS_OKAY (SILABS_EUSART_INIT )
0 commit comments