|
Core
|
Core UART library. More...
Go to the source code of this file.
Data Structures | |
| struct | core_USART_module_s |
Macros | |
| #define | CORE_USART1_UPDATE 0x01 |
| #define | CORE_USART2_UPDATE 0x02 |
| #define | CORE_USART3_UPDATE 0x04 |
Typedefs | |
| typedef struct core_USART_module_s | core_USART_module_t |
Functions | |
| bool | core_USART_init (USART_TypeDef *usart, uint32_t baud) |
| Initialize a USART module in asynchronous mode with the given baud rate. | |
| bool | core_USART_transmit (USART_TypeDef *usart, uint8_t *txbuf, uint8_t txbuflen) |
| Transmit data from a USART. | |
| bool | core_USART_register_callback (USART_TypeDef *usart, void(*callback)(uint8_t *, uint32_t)) |
| Set the RX callback and start the receiver for the given USART module. | |
| uint32_t | core_USART_receive (USART_TypeDef *usart, uint8_t *rxbuf, uint32_t rxbuflen, uint32_t timeout) |
| Synchronously receive data from a USART. | |
| int | uprintf (USART_TypeDef *usart, const char *format,...) |
| Print a formatted string to a USART. | |
Core UART library.
This core library component is used to initialize USARTs, transmit data over USART, and asynchronously receive data over USART.
To initialize a USART for transmitting, user code must call the function core_USART_init() and specify the desired baud rate.
To receive data, the user must call core_USART_register_callback() with a pointer to a function that will be called when data has been received. If no data has been received for CORE_USART_TIMEOUT bit periods, then the callback function is called with a pointer to the internal buffer as well as the number of received bytes.
| bool core_USART_init | ( | USART_TypeDef * | usart, |
| uint32_t | baud ) |
Initialize a USART module in asynchronous mode with the given baud rate.
| usart | The USART module to initialize |
| baud | Baud rate |
| 0 | if the given USART is not valid of if the initialization failed |
| 1 | otherwise |
| uint32_t core_USART_receive | ( | USART_TypeDef * | usart, |
| uint8_t * | rxbuf, | ||
| uint32_t | rxbuflen, | ||
| uint32_t | timeout ) |
Synchronously receive data from a USART.
| usart | The USART module |
| rxbuf | Location where the data to be received is stored |
| rxbuflen | Size of the RX buffer |
| timeout | RX timeout in microseconds |
| bool core_USART_register_callback | ( | USART_TypeDef * | usart, |
| void(* | callback )(uint8_t *, uint32_t) ) |
Set the RX callback and start the receiver for the given USART module.
| usart | The USART module |
| callback | Function to be called after data is received (the RX timeout elapses). The function must take a pointer to a byte array as the first argument and a uint32_t length as the second argument |
| 0 | if the given USART is not valid |
| 1 | otherwise |
| bool core_USART_transmit | ( | USART_TypeDef * | usart, |
| uint8_t * | txbuf, | ||
| uint8_t | txbuflen ) |
Transmit data from a USART.
| usart | The USART module |
| txbuf | Location where the data to be transmitted is read from |
| txbuflen | Number of bytes to transmit |
| 1 | if transmission was successful |
| 0 | otherwise |
| int uprintf | ( | USART_TypeDef * | usart, |
| const char * | format, | ||
| ... ) |
Print a formatted string to a USART.
| usart | The USART module |
| format | Format string |
| txbuflen | Number of bytes to transmit |