|
| 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_start_rx (USART_TypeDef *usart, volatile uint8_t *rxbuf, volatile uint32_t *rxbuflen) |
| | Start the receiver for the given USART module.
|
| |
| 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.
|
| |
|
void | USART1_IRQHandler () |
| |
|
void | USART2_IRQHandler () |
| |
|
void | USART3_IRQHandler () |
| |
| void | core_USART_update_disable (USART_TypeDef *usart) |
| | Disable updating the RX buffer for the given USART. Use this before reading from the buffer to which data is stored to prevent corruption.
|
| |
| void | core_USART_update_enable (USART_TypeDef *usart) |
| | Enable updating the RX buffer for the given USART.
|
| |
| bool | core_USART_transmit (USART_TypeDef *usart, uint8_t *txbuf, uint8_t txbuflen) |
| | Transmit data from a USART.
|
| |
| uint32_t | core_USART_receive (USART_TypeDef *usart, uint8_t *rxbuf, uint32_t rxbuflen, uint32_t timeout) |
| | Synchronously receive data from a USART.
|
| |
Core UART library.
This core library component is used to initialize USARTs, transmit data over USART, and asynchronously receive data over USART.
Initialization
To initialize a USART for transmitting, user code must call the function core_USART_init() and specify the desired baud rate. To initialize a USART for receiving, user code can use either the core_USART_start_rx() or the core_USART_register_callback() functions.
Receiving
And data received over the USART will be stored to an internal buffer. The USART is configured to raise an interrupt if no data has been received for a certain time. What happens with the received data depends on which function was used to start the receiver.
If the receiver was started with core_USART_start_rx(), then the contents of the internal buffer and the number of bytes read will be copied into the buffers provided to core_USART_start_rx(). In this configuration, the user code will generally initialize its buffer length variable to zero and wait for its value to change. Before processing the data, it should call core_USART_update_disable() to prevent the interrupt handler from overwriting the receive buffer while its contents are being buffered. After processing the data in the receive buffer, the user code should set the buffer length variable back to zero and call core_USART_update_enable().
If the receiver was started with core_USART_register_callback(), then the callback passed to core_USART_register_callback() will be called after a receiver timeout. A pointer to the internal buffer and the number of bytes received will be passed to the callback function. Note that the callback will be called from an ISR, so FreeRTOS operations may not work.
- Note
- If a receive timeout occurs while updating is disabled, then the data in the internal receive buffer will be lost.