Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
uart_emul.h File Reference

Backend API for emulated UART. More...

#include <zephyr/device.h>
#include <zephyr/types.h>

Go to the source code of this file.

Typedefs

typedef void(* uart_emul_callback_tx_data_ready_t) (const struct device *dev, size_t size, void *user_data)
 Define the application callback function signature for uart_emul_callback_tx_data_ready_set() function.
 

Functions

void uart_emul_callback_tx_data_ready_set (const struct device *dev, uart_emul_callback_tx_data_ready_t cb, void *user_data)
 Set the TX data ready callback.
 
uint32_t uart_emul_put_rx_data (const struct device *dev, const uint8_t *data, size_t size)
 Write (copy) data to RX buffer.
 
uint32_t uart_emul_get_tx_data (const struct device *dev, uint8_t *data, size_t size)
 Read data from TX buffer.
 
uint32_t uart_emul_flush_rx_data (const struct device *dev)
 Clear RX buffer content.
 
uint32_t uart_emul_flush_tx_data (const struct device *dev)
 Clear TX buffer content.
 
void uart_emul_set_errors (const struct device *dev, int errors)
 Sets one or more driver errors.
 
void uart_emul_set_release_buffer_on_timeout (const struct device *dev, bool release_on_timeout)
 Configures if rx buffer should be released on timeout, even when only partially filled.
 

Detailed Description

Backend API for emulated UART.

Typedef Documentation

◆ uart_emul_callback_tx_data_ready_t

typedef void(* uart_emul_callback_tx_data_ready_t) (const struct device *dev, size_t size, void *user_data)

Define the application callback function signature for uart_emul_callback_tx_data_ready_set() function.

Parameters
devUART device instance
sizeNumber of available bytes in TX buffer
user_dataArbitrary user data

Function Documentation

◆ uart_emul_callback_tx_data_ready_set()

void uart_emul_callback_tx_data_ready_set ( const struct device * dev,
uart_emul_callback_tx_data_ready_t cb,
void * user_data )

Set the TX data ready callback.

This sets up the callback that is called every time data was appended to the TX buffer.

Parameters
devThe emulated UART device instance
cbPointer to the callback function
user_dataData to pass to callback function

◆ uart_emul_flush_rx_data()

uint32_t uart_emul_flush_rx_data ( const struct device * dev)

Clear RX buffer content.

Parameters
devThe emulated UART device instance
Returns
Number of cleared bytes

◆ uart_emul_flush_tx_data()

uint32_t uart_emul_flush_tx_data ( const struct device * dev)

Clear TX buffer content.

Parameters
devThe emulated UART device instance
Returns
Number of cleared bytes

◆ uart_emul_get_tx_data()

uint32_t uart_emul_get_tx_data ( const struct device * dev,
uint8_t * data,
size_t size )

Read data from TX buffer.

Parameters
devThe emulated UART device instance
dataThe address of the output buffer
sizeNumber of bytes to read
Returns
Number of bytes written to the output buffer

◆ uart_emul_put_rx_data()

uint32_t uart_emul_put_rx_data ( const struct device * dev,
const uint8_t * data,
size_t size )

Write (copy) data to RX buffer.

Parameters
devThe emulated UART device instance
dataThe data to append
sizeNumber of bytes to append
Returns
Number of bytes appended

◆ uart_emul_set_errors()

void uart_emul_set_errors ( const struct device * dev,
int errors )

Sets one or more driver errors.

Parameters
devThe emulated UART device instance
errorsThe uart_rx_stop_reason errors to set

◆ uart_emul_set_release_buffer_on_timeout()

void uart_emul_set_release_buffer_on_timeout ( const struct device * dev,
bool release_on_timeout )

Configures if rx buffer should be released on timeout, even when only partially filled.

Parameters
devThe emulated UART device instance
release_on_timeoutWhen true, buffer will be released on timeout