Trident IoT Z-Wave SDK
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
zpal_uart.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Silicon Laboratories Inc. <https://www.silabs.com/>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
12#ifndef ZPAL_UART_H_
13#define ZPAL_UART_H_
14
15#include <stdbool.h>
16#include <stddef.h>
17#include "zpal_status.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
62#define ZPAL_UART_CONFIG_FLAG_BLOCKING (1 << 1)
63
73
83
94
98typedef void * zpal_uart_handle_t;
99
106typedef void (*zpal_uart_receive_callback_t)(zpal_uart_handle_t handle, size_t length);
107
114
132
141
149
157
171zpal_status_t zpal_uart_transmit(zpal_uart_handle_t handle, const uint8_t *data, size_t length,
173
181
190
199size_t zpal_uart_receive(zpal_uart_handle_t handle, uint8_t *data, size_t length);
200
206#ifdef __cplusplus
207}
208#endif
209
210#endif /* ZPAL_UART_H_ */
zpal_status_t
ZPAL statuses to be used by ZPAL APIs.
Definition zpal_status.h:38
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.
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.
Definition zpal_uart.h:106
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.
Definition zpal_uart.h:113
zpal_uart_stop_bits_t
IDs for each of the stop bits configuration.
Definition zpal_uart.h:88
zpal_uart_parity_bit_t
IDs for each of the parity mode.
Definition zpal_uart.h:78
bool zpal_uart_transmit_in_progress(zpal_uart_handle_t handle)
Returns whether transmission is in progress.
zpal_status_t zpal_uart_enable(zpal_uart_handle_t handle)
Enables a given UART.
void * zpal_uart_handle_t
UART handle type.
Definition zpal_uart.h:98
zpal_uart_id_t
IDs for each of the UARTs.
Definition zpal_uart.h:68
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.
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.
size_t zpal_uart_get_available(zpal_uart_handle_t handle)
Get the number of bytes ready for reading.
zpal_status_t zpal_uart_disable(zpal_uart_handle_t handle)
Disables a given UART.
@ ZPAL_UART_STOP_BITS_2
2 stop bits.
Definition zpal_uart.h:92
@ ZPAL_UART_STOP_BITS_1
1 stop bits.
Definition zpal_uart.h:90
@ ZPAL_UART_STOP_BITS_1P5
1.5 stop bits.
Definition zpal_uart.h:91
@ ZPAL_UART_STOP_BITS_0P5
0.5 stop bits.
Definition zpal_uart.h:89
@ ZPAL_UART_NO_PARITY
No parity.
Definition zpal_uart.h:79
@ ZPAL_UART_EVEN_PARITY
Even parity.
Definition zpal_uart.h:80
@ ZPAL_UART_ODD_PARITY
Odd parity.
Definition zpal_uart.h:81
@ ZPAL_UART1
ID of UART 1.
Definition zpal_uart.h:70
@ ZPAL_UART0
ID of UART 0.
Definition zpal_uart.h:69
@ ZPAL_UART2
ID of UART 2.
Definition zpal_uart.h:71
UART configuration.
Definition zpal_uart.h:118
uint8_t * rx_buffer
Poniter to receive buffer.
Definition zpal_uart.h:122
uint8_t flags
Configuration flags.
Definition zpal_uart.h:130
zpal_uart_receive_callback_t receive_callback
Expect this callback to be invoked in interrupt context.
Definition zpal_uart.h:128
size_t rx_buffer_len
Size of receive buffer.
Definition zpal_uart.h:123
zpal_uart_parity_bit_t parity_bit
Defines parity bit in the UART frame.
Definition zpal_uart.h:126
uint32_t baud_rate
Baud rate of UART.
Definition zpal_uart.h:124
size_t tx_buffer_len
Size of transmit buffer.
Definition zpal_uart.h:121
zpal_uart_stop_bits_t stop_bits
Define stop bit in the UART frame.
Definition zpal_uart.h:127
const void * ptr
This can be used for anything, but might not work for all platform implementations.
Definition zpal_uart.h:129
uint8_t * tx_buffer
Poniter to transmit buffer.
Definition zpal_uart.h:120
zpal_uart_id_t id
UART ID.
Definition zpal_uart.h:119
uint8_t data_bits
Defines amount of data bits in the UART frame.
Definition zpal_uart.h:125