Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
uart_async_rx.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_DRIVERS_SERIAL_UART_ASYNC_RX_H_
13#define ZEPHYR_DRIVERS_SERIAL_UART_ASYNC_RX_H_
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include <zephyr/kernel.h>
20
21/* @brief RX buffer structure which holds the buffer and its state. */
23 /* Write index which is incremented whenever new data is reported to be
24 * received to that buffer.
25 */
27
28 /* Set to one if buffer is released by the driver. */
30
31 /* Location which is passed to the UART driver. */
33};
34
37 /* Pointer to the configuration structure. Structure must be persistent. */
39
40 /* Total amount of pending bytes. Bytes may be spread across multiple RX buffers. */
42
43 /* Number of buffers which are free. */
45
46 /* Single buffer size. */
48
49 /* Index of the next buffer to be provided to the driver. */
51
52 /* Current buffer from which data is being consumed. */
54
55 /* Current read index in the buffer from which data is being consumed.
56 * Read index which is incremented whenever data is consumed from the buffer.
57 */
59};
60
63 /* Pointer to the buffer. */
65
66 /* Buffer length. */
67 size_t length;
68
69 /* Number of buffers into provided space shall be split. */
71};
72
79static inline uint8_t uart_async_rx_get_buf_len(struct uart_async_rx *async_rx)
80{
81 return async_rx->buf_len;
82}
83
92#define UART_ASYNC_RX_BUF_OVERHEAD offsetof(struct uart_async_rx_buf, buffer)
93
102 const struct uart_async_rx_config *config);
103
111void uart_async_rx_reset(struct uart_async_rx *async_rx);
112
121void uart_async_rx_on_rdy(struct uart_async_rx *async_rx, uint8_t *buffer, size_t length);
122
134
142void uart_async_rx_on_buf_rel(struct uart_async_rx *async_rx, uint8_t *buf);
143
158size_t uart_async_rx_data_claim(struct uart_async_rx *async_rx, uint8_t **data, size_t length);
159
170bool uart_async_rx_data_consume(struct uart_async_rx *async_rx, size_t length);
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif /* ZEPHYR_DRIVERS_SERIAL_UART_ASYNC_RX_H_ */
long atomic_t
Definition: atomic_types.h:15
Public kernel APIs.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Definition: uart_async_rx.h:22
uint8_t completed
Definition: uart_async_rx.h:29
uint8_t wr_idx
Definition: uart_async_rx.h:26
uint8_t buffer[]
Definition: uart_async_rx.h:32
UART asynchronous RX helper configuration structure.
Definition: uart_async_rx.h:62
uint8_t * buffer
Definition: uart_async_rx.h:64
uint8_t buf_cnt
Definition: uart_async_rx.h:70
size_t length
Definition: uart_async_rx.h:67
UART asynchronous RX helper structure.
Definition: uart_async_rx.h:36
atomic_t pending_bytes
Definition: uart_async_rx.h:41
atomic_t free_buf_cnt
Definition: uart_async_rx.h:44
uint8_t buf_len
Definition: uart_async_rx.h:47
uint8_t rd_buf_idx
Definition: uart_async_rx.h:53
const struct uart_async_rx_config * config
Definition: uart_async_rx.h:38
uint8_t drv_buf_idx
Definition: uart_async_rx.h:50
uint8_t rd_idx
Definition: uart_async_rx.h:58
bool uart_async_rx_data_consume(struct uart_async_rx *async_rx, size_t length)
Consume claimed data.
uint8_t * uart_async_rx_buf_req(struct uart_async_rx *async_rx)
Get next RX buffer.
void uart_async_rx_on_buf_rel(struct uart_async_rx *async_rx, uint8_t *buf)
Indicate that buffer is no longer used by the UART driver.
size_t uart_async_rx_data_claim(struct uart_async_rx *async_rx, uint8_t **data, size_t length)
Claim received data for processing.
int uart_async_rx_init(struct uart_async_rx *async_rx, const struct uart_async_rx_config *config)
Initialize the helper instance.
static uint8_t uart_async_rx_get_buf_len(struct uart_async_rx *async_rx)
Get RX buffer length.
Definition: uart_async_rx.h:79
void uart_async_rx_on_rdy(struct uart_async_rx *async_rx, uint8_t *buffer, size_t length)
Indicate received data.
void uart_async_rx_reset(struct uart_async_rx *async_rx)
Reset state of the helper instance.