Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
shell_uart.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SHELL_UART_H_
8#define ZEPHYR_INCLUDE_SHELL_UART_H_
9
12#include <zephyr/shell/shell.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
19
20#ifndef CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE
21#define CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE 0
22#endif
23
24#ifndef CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
25#define CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE 0
26#endif
27
28#ifndef CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_COUNT
29#define CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_COUNT 0
30#endif
31
32#ifndef CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_SIZE
33#define CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_SIZE 0
34#endif
35
36#define ASYNC_RX_BUF_SIZE (CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_COUNT * \
37 (CONFIG_SHELL_BACKEND_SERIAL_ASYNC_RX_BUFFER_SIZE + \
38 UART_ASYNC_RX_BUF_OVERHEAD))
39
41 const struct device *dev;
43 void *context;
45#ifdef CONFIG_MCUMGR_TRANSPORT_SHELL
46 struct smp_shell_data smp;
47#endif /* CONFIG_MCUMGR_TRANSPORT_SHELL */
48};
49
59
68
75
76#ifdef CONFIG_SHELL_BACKEND_SERIAL_API_POLLING
77#define SHELL_UART_STRUCT struct shell_uart_polling
78#elif defined(CONFIG_SHELL_BACKEND_SERIAL_API_ASYNC)
79#define SHELL_UART_STRUCT struct shell_uart_async
80#else
81#define SHELL_UART_STRUCT struct shell_uart_int_driven
82#endif
83
90#define SHELL_UART_DEFINE(_name, ...) \
91 static SHELL_UART_STRUCT _name##_shell_uart; \
92 struct shell_transport _name = { \
93 .api = &shell_uart_transport_api, \
94 .ctx = (struct shell_telnet *)&_name##_shell_uart, \
95 }
96
106
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* ZEPHYR_INCLUDE_SHELL_UART_H_ */
long atomic_t
Definition atomic_types.h:15
void(* shell_transport_handler_t)(enum shell_transport_evt evt, void *context)
Definition shell.h:624
struct smp_shell_data * shell_uart_smp_shell_data_get_ptr(void)
This function provides pointer to the smp shell data of the UART shell transport.
#define CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
Definition shell_uart.h:25
#define ASYNC_RX_BUF_SIZE
Definition shell_uart.h:36
const struct shell * shell_backend_uart_get_ptr(void)
This function provides pointer to the shell UART backend instance.
#define CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE
Definition shell_uart.h:21
const struct shell_transport_api shell_uart_transport_api
Shell transport for the mcumgr SMP protocol.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
A structure to represent a ring buffer.
Definition ring_buffer.h:41
Unified shell transport interface.
Definition shell.h:646
Definition shell_uart.h:60
struct k_sem tx_sem
Definition shell_uart.h:62
struct uart_async_rx async_rx
Definition shell_uart.h:63
atomic_t pending_rx_req
Definition shell_uart.h:65
struct uart_async_rx_config async_rx_config
Definition shell_uart.h:64
struct shell_uart_common common
Definition shell_uart.h:61
uint8_t rx_data[(0 *(0+UART_ASYNC_RX_BUF_OVERHEAD))]
Definition shell_uart.h:66
Definition shell_uart.h:40
shell_transport_handler_t handler
Definition shell_uart.h:42
void * context
Definition shell_uart.h:43
const struct device * dev
Definition shell_uart.h:41
bool blocking_tx
Definition shell_uart.h:44
Definition shell_uart.h:50
uint8_t tx_buf[0]
Definition shell_uart.h:54
struct ring_buf tx_ringbuf
Definition shell_uart.h:52
struct shell_uart_common common
Definition shell_uart.h:51
struct ring_buf rx_ringbuf
Definition shell_uart.h:53
struct k_timer dtr_timer
Definition shell_uart.h:56
atomic_t tx_busy
Definition shell_uart.h:57
uint8_t rx_buf[0]
Definition shell_uart.h:55
Definition shell_uart.h:69
struct k_timer rx_timer
Definition shell_uart.h:73
uint8_t rx_buf[0]
Definition shell_uart.h:72
struct ring_buf rx_ringbuf
Definition shell_uart.h:71
struct shell_uart_common common
Definition shell_uart.h:70
Shell instance internals.
Definition shell.h:890
Data used by SMP shell.
Definition smp_shell.h:23
UART asynchronous RX helper configuration structure.
Definition uart_async_rx.h:62
UART asynchronous RX helper structure.
Definition uart_async_rx.h:36
Helper module for receiving using UART Asynchronous API.