Skip to content

Commit 40c2b1e

Browse files
dcpleungcfriedt
authored andcommitted
uart: add API support for wide data
This adds API to support datum more than 8-bit wide. Drivers are still responsible for the implementation. Fixes #31914 Signed-off-by: Daniel Leung <[email protected]>
1 parent 2cb4d41 commit 40c2b1e

File tree

3 files changed

+325
-0
lines changed

3 files changed

+325
-0
lines changed

drivers/serial/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ config SERIAL_INIT_PRIORITY
3737
help
3838
Serial driver device initialization priority.
3939

40+
config SERIAL_SUPPORT_WIDE_DATA
41+
bool
42+
help
43+
This is an option to be enabled by individual serial driver
44+
to signal that the driver and hardware support data longer
45+
than 8-bit.
46+
4047
config UART_USE_RUNTIME_CONFIGURE
4148
bool "Enable runtime configuration for UART controllers"
4249
default y
@@ -83,6 +90,13 @@ config UART_DRV_CMD
8390

8491
Says no if not sure.
8592

93+
config UART_WIDE_DATA
94+
bool "Enable API to support data longer than 8-bit"
95+
help
96+
This enables the API to process data longer than 8-bit.
97+
This is up to the driver to implement the necessary functions
98+
to properly support this.
99+
86100
comment "Serial Drivers"
87101

88102
source "drivers/serial/Kconfig.b91"

drivers/serial/uart_handlers.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ static inline int z_vrfy_uart_poll_in(const struct device *dev,
3333
}
3434
#include <syscalls/uart_poll_in_mrsh.c>
3535

36+
static inline int z_vrfy_uart_poll_in_u16(const struct device *dev,
37+
uint16_t *p_u16)
38+
{
39+
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_in));
40+
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(p_u16, sizeof(uint16_t)));
41+
return z_impl_uart_poll_in_u16(dev, p_u16);
42+
}
43+
#include <syscalls/uart_poll_in_u16_mrsh.c>
44+
3645
static inline void z_vrfy_uart_poll_out(const struct device *dev,
3746
unsigned char out_char)
3847
{
@@ -41,6 +50,14 @@ static inline void z_vrfy_uart_poll_out(const struct device *dev,
4150
}
4251
#include <syscalls/uart_poll_out_mrsh.c>
4352

53+
static inline void z_vrfy_uart_poll_out_u16(const struct device *dev,
54+
uint16_t out_u16)
55+
{
56+
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_out));
57+
z_impl_uart_poll_out_u16((const struct device *)dev, out_u16);
58+
}
59+
#include <syscalls/uart_poll_out_u16_mrsh.c>
60+
4461
static inline int z_vrfy_uart_config_get(const struct device *dev,
4562
struct uart_config *cfg)
4663
{
@@ -77,6 +94,18 @@ static inline int z_vrfy_uart_tx(const struct device *dev, const uint8_t *buf,
7794
}
7895
#include <syscalls/uart_tx_mrsh.c>
7996

97+
#ifdef CONFIG_UART_WIDE_DATA
98+
static inline int z_vrfy_uart_tx_u16(const struct device *dev,
99+
const uint16_t *buf,
100+
size_t len, int32_t timeout)
101+
{
102+
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, tx));
103+
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(buf, len, sizeof(uint16_t)));
104+
return z_impl_uart_tx_u16(dev, buf, len, timeout);
105+
}
106+
#include <syscalls/uart_tx_u16_mrsh.c>
107+
#endif
108+
80109
UART_SIMPLE(tx_abort);
81110
#include <syscalls/uart_tx_abort_mrsh.c>
82111

@@ -90,6 +119,18 @@ static inline int z_vrfy_uart_rx_enable(const struct device *dev,
90119
}
91120
#include <syscalls/uart_rx_enable_mrsh.c>
92121

122+
#ifdef CONFIG_UART_WIDE_DATA
123+
static inline int z_vrfy_uart_rx_enable_u16(const struct device *dev,
124+
uint16_t *buf,
125+
size_t len, int32_t timeout)
126+
{
127+
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, rx_enable));
128+
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(buf, len, sizeof(uint16_t)));
129+
return z_impl_uart_rx_enable_u16(dev, buf, len, timeout);
130+
}
131+
#include <syscalls/uart_rx_enable_u16_mrsh.c>
132+
#endif
133+
93134
UART_SIMPLE(rx_disable);
94135
#include <syscalls/uart_rx_disable_mrsh.c>
95136
#endif /* CONFIG_UART_ASYNC_API */

0 commit comments

Comments
 (0)