Defines a platform abstraction layer for the Z-Wave UART. More...
Data Structures | |
struct | zpal_uart_config_t |
UART configuration. More... | |
Macros | |
#define | ZPAL_UART_CONFIG_FLAG_BLOCKING (1 << 1) |
Typedefs | |
typedef void * | zpal_uart_handle_t |
UART handle type. | |
typedef void(* | zpal_uart_receive_callback_t) (zpal_uart_handle_t handle, size_t length) |
Defines a type for the UART receive callback that is invoked whenever data is ready. | |
typedef void(* | zpal_uart_transmit_done_t) (zpal_uart_handle_t handle) |
Defines a type for the UART transmit done callback that is invoked when data has been transmitted. | |
Enumerations | |
enum | zpal_uart_id_t { ZPAL_UART0 = 0 , ZPAL_UART1 , ZPAL_UART2 } |
IDs for each of the UARTs. More... | |
enum | zpal_uart_parity_bit_t { ZPAL_UART_NO_PARITY , ZPAL_UART_EVEN_PARITY , ZPAL_UART_ODD_PARITY } |
IDs for each of the parity mode. More... | |
enum | zpal_uart_stop_bits_t { ZPAL_UART_STOP_BITS_0P5 , ZPAL_UART_STOP_BITS_1 , ZPAL_UART_STOP_BITS_1P5 , ZPAL_UART_STOP_BITS_2 } |
IDs for each of the stop bits configuration. More... | |
Functions | |
zpal_status_t | zpal_uart_init (const zpal_uart_config_t *config, zpal_uart_handle_t *handle) |
Initializes a UART based on the given configuration. | |
zpal_status_t | zpal_uart_enable (zpal_uart_handle_t handle) |
Enables a given UART. | |
zpal_status_t | zpal_uart_disable (zpal_uart_handle_t handle) |
Disables a given UART. | |
zpal_status_t | zpal_uart_transmit (zpal_uart_handle_t handle, const uint8_t *data, size_t length, zpal_uart_transmit_done_t tx_cb) |
Transmits data using a given UART. | |
bool | zpal_uart_transmit_in_progress (zpal_uart_handle_t handle) |
Returns whether transmission is in progress. | |
size_t | zpal_uart_get_available (zpal_uart_handle_t handle) |
Get the number of bytes ready for reading. | |
size_t | zpal_uart_receive (zpal_uart_handle_t handle, uint8_t *data, size_t length) |
Receive available data into buffer using a given UART. | |
Defines a platform abstraction layer for the Z-Wave UART.
How to use the UART API
The ZPAL UART API is used by only SerialAPI application, all functions are required.
The following outlines an example of use:
Requirements:
#define ZPAL_UART_CONFIG_FLAG_BLOCKING (1 << 1) |
Set this flag in the configuration if the UART must be configured as a blocking UART.
Example of use:
typedef void* zpal_uart_handle_t |
UART handle type.
typedef void(* zpal_uart_receive_callback_t) (zpal_uart_handle_t handle, size_t length) |
Defines a type for the UART receive callback that is invoked whenever data is ready.
[in] | handle | UART handle. |
[in] | length | Length of available data in bytes. |
typedef void(* zpal_uart_transmit_done_t) (zpal_uart_handle_t handle) |
Defines a type for the UART transmit done callback that is invoked when data has been transmitted.
[in] | handle | UART handle. |
enum zpal_uart_id_t |
zpal_status_t zpal_uart_disable | ( | zpal_uart_handle_t | handle | ) |
Disables a given UART.
[in] | handle | UART handle. |
zpal_status_t zpal_uart_enable | ( | zpal_uart_handle_t | handle | ) |
Enables a given UART.
[in] | handle | UART handle. |
size_t zpal_uart_get_available | ( | zpal_uart_handle_t | handle | ) |
Get the number of bytes ready for reading.
[in] | handle | UART handle. |
zpal_status_t zpal_uart_init | ( | const zpal_uart_config_t * | config, |
zpal_uart_handle_t * | handle ) |
Initializes a UART based on the given configuration.
[in] | config | Pointer to UART configuration. |
[out] | handle | Outputs a handle to a UART. |
size_t zpal_uart_receive | ( | zpal_uart_handle_t | handle, |
uint8_t * | data, | ||
size_t | length ) |
Receive available data into buffer using a given UART.
[in] | handle | UART handle. |
[out] | data | The data buffer to receive into |
[in] | length | the maximum number of bytes we'd like to read |
zpal_status_t zpal_uart_transmit | ( | zpal_uart_handle_t | handle, |
const uint8_t * | data, | ||
size_t | length, | ||
zpal_uart_transmit_done_t | tx_cb ) |
Transmits data using a given UART.
[in] | handle | UART handle. |
[in] | data | Pointer to data. |
[in] | length | Length of data. |
[in] | tx_cb | Transmission done callback. |
tx_cb
callback to be invoked in interrupt context. bool zpal_uart_transmit_in_progress | ( | zpal_uart_handle_t | handle | ) |
Returns whether transmission is in progress.
[in] | handle | UART handle. |