47#include "px_uart_cfg.h"
50#if ( !defined(PX_UART_CFG_UART0_EN ) \
51 || !defined(PX_UART_CFG_UART1_EN ) \
52 || !defined(PX_UART_CFG_DEFAULT_BAUD ) \
53 || !defined(PX_UART_CFG_DEFAULT_UCSRC) \
54 || !defined(PX_UART_CFG_TX_BUF_SIZE ) \
55 || !defined(PX_UART_CFG_RX_BUF_SIZE ) )
56#error "One or more options not defined in 'px_uart_cfg.h'"
58#if ( (PX_UART_CFG_UART0_EN > 1) \
59 || (PX_UART_CFG_UART1_EN > 1) )
60#error "PX_UART_CFG_UARTx_EN must be 0 or 1"
64#define PX_UART_CFG_PER_COUNT ( PX_UART_CFG_UART0_EN \
65 + PX_UART_CFG_UART1_EN )
66#if (PX_UART_CFG_PER_COUNT == 0)
67#error "No peripherals enabled"
86 PX_UART_PARITY_NONE = 0,
94 PX_UART_DATA_BITS_5 = 5,
95 PX_UART_DATA_BITS_6 = 6,
96 PX_UART_DATA_BITS_7 = 7,
97 PX_UART_DATA_BITS_8 = 8,
103 PX_UART_STOP_BITS_1 = 1,
104 PX_UART_STOP_BITS_2 = 2,
110 struct px_uart_per_s * uart_per;
bool px_uart_rd_buf_is_empty(px_uart_handle_t *handle)
See if there is received data in the receive buffer.
bool px_uart_wr_u8(px_uart_handle_t *handle, uint8_t data)
Buffer one byte for transmission.
bool px_uart_open2(px_uart_handle_t *handle, px_uart_nr_t uart_nr, uint32_t baud, px_uart_data_bits_t data_bits, px_uart_parity_t parity, px_uart_stop_bits_t stop_bits)
Open UART peripheral using specified parameters.
bool px_uart_rd_u8(px_uart_handle_t *handle, uint8_t *data)
See if a received byte is available and store it in the specified location.
bool px_uart_close(px_uart_handle_t *handle)
Close specified peripheral.
px_uart_parity_t
Specify UART parity (none, odd or even)
px_uart_data_bits_t
Specify number of data bits used (7..9)
size_t px_uart_rd(px_uart_handle_t *handle, void *buf, size_t nr_of_bytes)
Copy received data from receive buffer into specified buffer.
void px_uart_putchar(px_uart_handle_t *handle, char data)
Write one byte.
bool px_uart_wr_buf_is_empty(px_uart_handle_t *handle)
See if transmit buffer is empty.
size_t px_uart_wr(px_uart_handle_t *handle, const void *data, size_t nr_of_bytes)
Buffer byte(s) for transmission.
px_uart_stop_bits_t
Specify number of stop bits (1/2)
px_uart_nr_t
Specify UART peripheral.
void px_uart_init(void)
Initialise UART driver.
bool px_uart_change_baud(px_uart_handle_t *handle, uint32_t baud)
Change UART peripheral baud rate.
char px_uart_getchar(px_uart_handle_t *handle)
Read one byte.
bool px_uart_wr_is_done(px_uart_handle_t *handle)
See if all transmission has finished, including last byte.
bool px_uart_wr_buf_is_full(px_uart_handle_t *handle)
See if transmit buffer can accept more data.
bool px_uart_open(px_uart_handle_t *handle, px_uart_nr_t uart_nr)
Open UART peripheral using predefined (default) parameters.