|
px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
|
Driver for the UART peripheral for serial communication.
File(s):
The driver must be configured by supplying a project specific "px_uart_cfg.h". "px_uart_cfg_template.h" can be copied, renamed and modified to supply compile time options.
Data Structures | |
| struct | px_uart_handle_t |
| Define UART handle. More... | |
Enumerations | |
| enum | px_uart_nr_t |
| Specify UART peripheral. More... | |
| enum | px_uart_parity_t |
| Specify UART parity (none, odd or even) More... | |
| enum | px_uart_data_bits_t |
| Specify number of data bits used (7..9) More... | |
| enum | px_uart_stop_bits_t |
| Specify number of stop bits (1/2) More... | |
Functions | |
| void | px_uart_init (void) |
| Initialise UART driver. More... | |
| bool | px_uart_open (px_uart_handle_t *handle, px_uart_nr_t uart_nr) |
| Open UART peripheral using predefined (default) parameters. More... | |
| 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. More... | |
| bool | px_uart_close (px_uart_handle_t *handle) |
| Close specified peripheral. More... | |
| void | px_uart_putchar (px_uart_handle_t *handle, char data) |
| Write one byte. More... | |
| bool | px_uart_wr_u8 (px_uart_handle_t *handle, uint8_t data) |
| Buffer one byte for transmission. More... | |
| size_t | px_uart_wr (px_uart_handle_t *handle, const void *data, size_t nr_of_bytes) |
| Buffer byte(s) for transmission. More... | |
| char | px_uart_getchar (px_uart_handle_t *handle) |
| Read one byte. More... | |
| 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. More... | |
| 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. More... | |
| bool | px_uart_wr_buf_is_full (px_uart_handle_t *handle) |
| See if transmit buffer can accept more data. More... | |
| bool | px_uart_wr_buf_is_empty (px_uart_handle_t *handle) |
| See if transmit buffer is empty. More... | |
| bool | px_uart_wr_is_done (px_uart_handle_t *handle) |
| See if all transmission has finished, including last byte. More... | |
| bool | px_uart_rd_buf_is_empty (px_uart_handle_t *handle) |
| See if there is received data in the receive buffer. More... | |
| bool | px_uart_change_baud (px_uart_handle_t *handle, uint32_t baud) |
| Change UART peripheral baud rate. More... | |
| bool | px_uart_change_data_format (px_uart_handle_t *handle, px_uart_data_bits_t data_bits, px_uart_parity_t parity, px_uart_stop_bits_t stop_bits) |
| Change UART peripheral data format. More... | |
| struct px_uart_handle_t |
| #define PX_UART_CFG_PER_COUNT |
Number of enabled peripherals.
| #define PX_UART_CFG_UART1_EN 1 |
Enable/disable support for UART1 peripheral.
Definition at line 35 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART2_EN 1 |
Enable/disable support for UART2 peripheral.
Definition at line 38 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART4_EN 1 |
Enable/disable support for UART4 peripheral.
Definition at line 41 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART5_EN 0 |
Enable/disable support for UART5 peripheral.
Definition at line 44 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_DEFAULT_BAUD 115200ul |
Default BAUD rate.
Definition at line 47 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART_TX_BUF_SIZE 64 |
General size of UART transmit buffer.
Definition at line 50 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART_RX_BUF_SIZE 64 |
General size of UART receive buffer.
Definition at line 52 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART1_TX_BUF_SIZE PX_UART_CFG_UART_TX_BUF_SIZE |
Size of UART1 transmit buffer.
Definition at line 55 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART1_RX_BUF_SIZE PX_UART_CFG_UART_RX_BUF_SIZE |
Size of UART1 receive buffer.
Definition at line 57 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART2_TX_BUF_SIZE PX_UART_CFG_UART_TX_BUF_SIZE |
Size of UART2 transmit buffer.
Definition at line 60 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART2_RX_BUF_SIZE PX_UART_CFG_UART_RX_BUF_SIZE |
Size of UART2 receive buffer.
Definition at line 62 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART4_TX_BUF_SIZE PX_UART_CFG_UART_TX_BUF_SIZE |
Size of UART4 transmit buffer.
Definition at line 65 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART4_RX_BUF_SIZE PX_UART_CFG_UART_RX_BUF_SIZE |
Size of UART4 receive buffer.
Definition at line 67 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART5_TX_BUF_SIZE PX_UART_CFG_UART_TX_BUF_SIZE |
Size of UART5 transmit buffer.
Definition at line 70 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART5_RX_BUF_SIZE PX_UART_CFG_UART_RX_BUF_SIZE |
Size of UART5 receive buffer.
Definition at line 72 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART1_CLK_HZ PX_BOARD_PER_CLK_HZ |
UART1 peripheral clock in Hz.
Definition at line 75 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART2_CLK_HZ PX_BOARD_PER_CLK_HZ |
UART2 peripheral clock in Hz.
Definition at line 77 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART3_CLK_HZ PX_BOARD_PER_CLK_HZ |
UART3 peripheral clock in Hz.
Definition at line 79 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART4_CLK_HZ PX_BOARD_PER_CLK_HZ |
UART4 peripheral clock in Hz.
Definition at line 81 of file px_uart_cfg_template.h.
| #define PX_UART_CFG_UART5_CLK_HZ PX_BOARD_PER_CLK_HZ |
UART5 peripheral clock in Hz.
Definition at line 83 of file px_uart_cfg_template.h.
| enum px_uart_nr_t |
| enum px_uart_parity_t |
| enum px_uart_data_bits_t |
| enum px_uart_stop_bits_t |
| bool px_uart_open | ( | px_uart_handle_t * | handle, |
| px_uart_nr_t | uart_nr | ||
| ) |
Open UART peripheral using predefined (default) parameters.
| handle | Pointer to handle data structure |
| uart_nr | UART peripheral number. |
| false | Error: peripheral was not opened |
| true | Success: peripheral was opened |
| 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.
| handle | Pointer to handle data structure |
| uart_nr | UART peripheral number. |
| baud | Baud rate in bits/s |
| data_bits | Data bits. |
| parity | Parity. |
| stop_bits | Stop bits. |
| false | Error: peripheral was not opened |
| true | Success: peripheral was opened |
| bool px_uart_close | ( | px_uart_handle_t * | handle | ) |
| void px_uart_putchar | ( | px_uart_handle_t * | handle, |
| char | data | ||
| ) |
| bool px_uart_wr_u8 | ( | px_uart_handle_t * | handle, |
| uint8_t | data | ||
| ) |
| size_t px_uart_wr | ( | px_uart_handle_t * | handle, |
| const void * | data, | ||
| size_t | nr_of_bytes | ||
| ) |
Buffer byte(s) for transmission.
| handle | Pointer to handle data structure | |
| [in] | data | Buffer containing data for transmission |
| [in] | nr_of_bytes | Number of bytes in buffer to be written |
| char px_uart_getchar | ( | px_uart_handle_t * | handle | ) |
| 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.
| handle | Pointer to handle data structure | |
| [out] | data | Pointer to location where data byte must be stored |
| true | Received byte is stored in specified location |
| false | No received data available (receive buffer empty) |
| 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.
| handle | Pointer to handle data structure | |
| [out] | buf | Buffer to copy received data into |
| [in] | nr_of_bytes | Maximum number of received bytes to copy into buffer |
| bool px_uart_wr_buf_is_full | ( | px_uart_handle_t * | handle | ) |
| bool px_uart_wr_buf_is_empty | ( | px_uart_handle_t * | handle | ) |
See if transmit buffer is empty.
| handle | Pointer to handle data structure |
| true | Transmit buffer is empty |
| false | Transmit buffer has space for at least one byte |
| bool px_uart_wr_is_done | ( | px_uart_handle_t * | handle | ) |
See if all transmission has finished, including last byte.
This functions is usefull for communication standards like RS-485 where the mode must be changed manually from TX to RX after transmission.
| handle | Pointer to handle data structure |
| true | Transmision completely finished |
| false | Busy with transmission |
| bool px_uart_rd_buf_is_empty | ( | px_uart_handle_t * | handle | ) |
| bool px_uart_change_baud | ( | px_uart_handle_t * | handle, |
| uint32_t | baud | ||
| ) |
| bool px_uart_change_data_format | ( | px_uart_handle_t * | handle, |
| px_uart_data_bits_t | data_bits, | ||
| px_uart_parity_t | parity, | ||
| px_uart_stop_bits_t | stop_bits | ||
| ) |
Change UART peripheral data format.
| handle | Pointer to handle data structure |
| data_bits | Data bits (7,8 or 9) |
| parity | Parity(NONE, ODD or EVEN) |
| stop_bits | Stop bits (1 or 2) |
| true | Success. data format was changed |
| false | Error. Requested data format invalid |