Skip to content

Commit b83267d

Browse files
asmellbykartben
authored andcommitted
drivers: serial: silabs_usart: Fix configure error cases
Enable uart_elementary test and fix edge cases where the configure function did not return the appropriate error code when given invalid parity or flow control parameters. Signed-off-by: Aksel Skauge Mellbye <[email protected]>
1 parent 3f7e614 commit b83267d

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

drivers/serial/uart_silabs_usart.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,19 @@ static int uart_silabs_configure(const struct device *dev,
982982
return -ENOSYS;
983983
}
984984

985+
if (cfg->parity > UART_CFG_PARITY_SPACE) {
986+
return -EINVAL;
987+
}
988+
985989
if (cfg->flow_ctrl == UART_CFG_FLOW_CTRL_DTR_DSR ||
986990
cfg->flow_ctrl == UART_CFG_FLOW_CTRL_RS485) {
987991
return -ENOSYS;
988992
}
989993

994+
if (cfg->flow_ctrl > UART_CFG_FLOW_CTRL_RS485) {
995+
return -EINVAL;
996+
}
997+
990998
*data->uart_cfg = *cfg;
991999
USART_Enable(base, usartDisable);
9921000

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2025, Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,console = &eusart0;
10+
zephyr,shell-uart = &eusart0;
11+
zephyr,uart-pipe = &eusart0;
12+
};
13+
};
14+
15+
/*
16+
* Connect EXP4 (PC1) and EXP6 (PC2) of the Expansion Pin header
17+
*/
18+
19+
&pinctrl {
20+
eusart0_default: eusart0_default {
21+
group0 {
22+
pins = <EUSART0_TX_PA8>;
23+
drive-push-pull;
24+
output-high;
25+
};
26+
group1 {
27+
pins = <EUSART0_RX_PA9>;
28+
input-enable;
29+
silabs,input-filter;
30+
};
31+
};
32+
33+
usart0_default: usart0_default {
34+
group0 {
35+
pins = <USART0_TX_PC1>; /* WPK EXP4 (PC1) */
36+
drive-push-pull;
37+
output-high;
38+
};
39+
group1 {
40+
pins = <USART0_RX_PC2>; /* WPK EXP6 (PC2) */
41+
input-enable;
42+
silabs,input-filter;
43+
};
44+
};
45+
};
46+
47+
dut: &usart0 {
48+
current-speed = <115200>;
49+
pinctrl-0 = <&usart0_default>;
50+
pinctrl-names = "default";
51+
status = "okay";
52+
};
53+
54+
&eusart0 {
55+
compatible = "silabs,eusart-uart";
56+
current-speed = <115200>;
57+
pinctrl-0 = <&eusart0_default>;
58+
pinctrl-names = "default";
59+
status = "okay";
60+
};

tests/drivers/uart/uart_elementary/testcase.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tests:
2525
- esp32h2_devkitm
2626
- esp32s2_saola
2727
- esp32s3_devkitm/esp32s3/procpu
28+
- xg24_rb4187c
2829
integration_platforms:
2930
- nrf54h20dk/nrf54h20/cpuapp
3031
drivers.uart.uart_elementary_dual_nrf54h:

0 commit comments

Comments
 (0)