Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
Helper module for receiving using UART Asynchronous API. More...
#include <zephyr/kernel.h>
Go to the source code of this file.
Data Structures | |
struct | uart_async_rx_buf |
struct | uart_async_rx |
UART asynchronous RX helper structure. More... | |
struct | uart_async_rx_config |
UART asynchronous RX helper configuration structure. More... | |
Macros | |
#define | UART_ASYNC_RX_BUF_OVERHEAD offsetof(struct uart_async_rx_buf, buffer) |
Get amount of space dedicated for managing each buffer state. | |
Functions | |
static uint8_t | uart_async_rx_get_buf_len (struct uart_async_rx *async_rx) |
Get RX buffer length. | |
int | uart_async_rx_init (struct uart_async_rx *async_rx, const struct uart_async_rx_config *config) |
Initialize the helper instance. | |
void | uart_async_rx_reset (struct uart_async_rx *async_rx) |
Reset state of the helper instance. | |
void | uart_async_rx_on_rdy (struct uart_async_rx *async_rx, uint8_t *buffer, size_t length) |
Indicate received 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. | |
bool | uart_async_rx_data_consume (struct uart_async_rx *async_rx, size_t length) |
Consume claimed data. | |
Helper module for receiving using UART Asynchronous API.
#define UART_ASYNC_RX_BUF_OVERHEAD offsetof(struct uart_async_rx_buf, buffer) |
Get amount of space dedicated for managing each buffer state.
User buffer provided during the initialization is split into chunks and each chunk has overhead. This overhead can be used to calculate actual space used for UART data.
uint8_t * uart_async_rx_buf_req | ( | struct uart_async_rx * | async_rx | ) |
Get next RX buffer.
Returned pointer shall be provided to uart_rx_buf_rsp or uart_rx_enable. If null is returned that indicates that there are no available buffers since all buffers are used by the driver or contain not consumed data.
async_rx | Pointer to the helper instance. |
size_t uart_async_rx_data_claim | ( | struct uart_async_rx * | async_rx, |
uint8_t ** | data, | ||
size_t | length ) |
Claim received data for processing.
Helper module works in the zero copy mode. It provides a pointer to the buffer that was directly used by the UART driver. Since received data is spread across multiple buffers there is no possibility to read all data at once. It can only be consumed in chunks. After data is processed, uart_async_rx_data_consume is used to indicate that data is consumed.
async_rx | Pointer to the helper instance. |
data | Location where address to the buffer is written. Untouched if no data to claim. |
length | Amount of requested data. |
data
buffer. 0 is returned when there is no data. bool uart_async_rx_data_consume | ( | struct uart_async_rx * | async_rx, |
size_t | length ) |
Consume claimed data.
It pairs with uart_async_rx_data_claim.
async_rx | Pointer to the helper instance. |
length | Amount of data to consume. It must be less or equal than amount of claimed data. |
true | If there are free buffers in the pool after data got consumed. |
false | If there are no free buffers. |
|
inlinestatic |
Get RX buffer length.
async_rx | Pointer to the helper instance. |
int uart_async_rx_init | ( | struct uart_async_rx * | async_rx, |
const struct uart_async_rx_config * | config ) |
Initialize the helper instance.
async_rx | Pointer to the helper instance. |
config | Configuration. Must be persistent. |
0 | on successful initialization. |
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.
Function shall be called on UART_RX_BUF_RELEASED event.
async_rx | Pointer to the helper instance. |
buf | Buffer pointer received in the UART driver event. |
void uart_async_rx_on_rdy | ( | struct uart_async_rx * | async_rx, |
uint8_t * | buffer, | ||
size_t | length ) |
Indicate received data.
Function shall be called from UART_RX_RDY context.
async_rx | Pointer to the helper instance. |
buffer | Buffer received in the UART driver event. |
length | Length received in the UART driver event. |
void uart_async_rx_reset | ( | struct uart_async_rx * | async_rx | ) |
Reset state of the helper instance.
Helper can be reset after RX abort to discard all received data and bring the helper to its initial state.
async_rx | Pointer to the helper instance. |