microHAL
An abstraction layer for your future F4xx projects
|
Function defines for the USART driver. More...
#include "usart.h"
Functions | |
void | usart_start (const usart_peripheral_t usart, const uint32_t baudrate, const usart_mode_t mode) |
Initiates the USART peripheral with specified options. | |
void | usart_set_dma (const usart_peripheral_t usart, const _Bool forTX, const _Bool forRX) |
Configures the USART DMA functionality. | |
void | usart_set_interrupts (const usart_peripheral_t usart, const struct USARTISR config) |
Enables the specified USART interrupts. | |
void | usart_set_databits (const usart_peripheral_t usart, const usart_stopbits_t stopbits, const usart_databits_t databits) |
Sets the USART databits to the specified values. | |
void | usart_set_parity (const usart_peripheral_t usart, const usart_parity_t parity) |
Sets the USART parity to the specified mode. | |
void | usart_tx_message (const usart_peripheral_t usart, const char *message) |
Writes specified message to USART buffer. | |
uint16_t | usart_rx_byte (const usart_peripheral_t usart) |
Reads the received data from the USART buffer. | |
void | usart_stop (const usart_peripheral_t usart) |
Disable the USART interface. | |
Function defines for the USART driver.
This file contains all of the function definitions declared in usart.h.
uint16_t usart_rx_byte | ( | const usart_peripheral_t | usart | ) |
Reads the received data from the USART buffer.
In receive/transceive mode the data will be read from the DR register and the RXNE flag will be cleared. Beware that this method is very slow and may cause overrun errors if not used in conjuction with interrupts.
usart | The selected USART |
void usart_set_databits | ( | const usart_peripheral_t | usart, |
const usart_stopbits_t | stopbits, | ||
const usart_databits_t | databits ) |
Sets the USART databits to the specified values.
The available number of stopbits and databits for the USART are specified in usart_stopbits_t and usart_databits_t enums respectively. Any other value will be ignored.
usart | The selected USART |
stopbits | The number of stop bits |
databits | The word length |
void usart_set_dma | ( | const usart_peripheral_t | usart, |
const _Bool | forTX, | ||
const _Bool | forRX ) |
Configures the USART DMA functionality.
usart | The selected USART |
forTX | Enable / Disable DMA for TX |
forTX | Enable / Disable DMA for RX |
void usart_set_interrupts | ( | const usart_peripheral_t | usart, |
const struct USARTISR | config ) |
Enables the specified USART interrupts.
The available interrupts are located in the usart_isr struct.
usart | The selected USART |
config | The ISR configuration |
void usart_set_parity | ( | const usart_peripheral_t | usart, |
const usart_parity_t | parity ) |
Sets the USART parity to the specified mode.
The available parity modes for the USART are specified in usart_parity_t. Any other value will be ignored. Please note that setting the parity modes will automatically set the PCE (parity control) bit. If the mode is "off" it will be cleared.
usart | The selected USART |
parity | The selected parity |
void usart_start | ( | const usart_peripheral_t | usart, |
const uint32_t | baudrate, | ||
const usart_mode_t | mode ) |
Initiates the USART peripheral with specified options.
The available modes for the USART peripheral are specified in the usart_mode_t enum. Any other value will be ignored.
usart | The selected USART |
baudrate | The desired communication bitrate |
mode | The desired communication mode |
x8_oversample | Use x8 oversampling instead of x16 |
void usart_stop | ( | const usart_peripheral_t | usart | ) |
Disable the USART interface.
The function will wait until all transmissions are complete and turn off the specified USART peripheral.
usart | The selected USART |
void usart_tx_message | ( | const usart_peripheral_t | usart, |
const char * | message ) |
Writes specified message to USART buffer.
In transmit/transceive mode the data will be written to the DR register and be shifted out of the TX pin when ready. Using it without DMA is not recommended for multibyte messages.
usart | The selected USART |
character | Pointer to the message |