USART driver for AVR XMEGA.
This file contains basic functions for the AVR XMEGA USART, with support for all modes, settings and clock speeds.
Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | usart_rs232_options |
Input parameters when initializing RS232 and similar modes. More... | |
struct | usart_spi_options |
Input parameters when initializing SPI master mode. More... | |
Macros | |
#define | USART_BAUD_1200 0x00 |
Offset in lookup table for baudrate 1200. More... | |
#define | USART_BAUD_19200 0x04 |
Offset in lookup table for baudrate 19200. More... | |
#define | USART_BAUD_2400 0x01 |
Offset in lookup table for baudrate 2400. More... | |
#define | USART_BAUD_38400 0x05 |
Offset in lookup table for baudrate 38400. More... | |
#define | USART_BAUD_4800 0x02 |
Offset in lookup table for baudrate 4800. More... | |
#define | USART_BAUD_57600 0x06 |
Offset in lookup table for baudrate 57600. More... | |
#define | USART_BAUD_9600 0x03 |
Offset in lookup table for baudrate 9600. More... | |
#define | USART_BAUD_UNDEFINED 0xFF |
Baudrate not in lookup table. More... | |
Typedefs | |
typedef struct usart_rs232_options | usart_rs232_options_t |
Input parameters when initializing RS232 and similar modes. More... | |
typedef struct usart_spi_options | usart_spi_options_t |
Input parameters when initializing SPI master mode. More... | |
Enumerations | |
enum | usart_int_level_t { USART_INT_LVL_OFF = 0x00, USART_INT_LVL_LO = 0x01, USART_INT_LVL_MED = 0x02, USART_INT_LVL_HI = 0x03 } |
USART interrupt levels. More... | |
Functions | |
static | PROGMEM_DECLARE (uint16_t, baudctrl_2mhz[]) |
Lookup table containing baudctrl values for CPU frequency 2 Mhz. More... | |
static | PROGMEM_DECLARE (uint16_t, baudctrl_32mhz[]) |
Lookup table containing baudctrl values for CPU frequency 32 Mhz. More... | |
static void | usart_clear_rx_complete (USART_t *usart) |
Clear RX complete interrupt flag. More... | |
static void | usart_clear_tx_complete (USART_t *usart) |
Clear TX complete interrupt flag. More... | |
static bool | usart_data_register_is_empty (USART_t *usart) |
Check if data register empty flag is set. More... | |
static void | usart_format_set (USART_t *usart, USART_CHSIZE_t charSize, USART_PMODE_t parityMode, bool twoStopBits) |
Configure the USART frame format. More... | |
static uint8_t | usart_get (USART_t *usart) |
Read a data to the USART data register. More... | |
uint8_t | usart_getchar (USART_t *usart) |
Receive a data with the USART module. More... | |
bool | usart_init_rs232 (USART_t *usart, const usart_rs232_options_t *opt) |
Initialize USART in RS232 mode. More... | |
void | usart_init_spi (USART_t *usart, const usart_spi_options_t *opt) |
Initialize USART in SPI master mode. More... | |
static void | usart_put (USART_t *usart, uint8_t txdata) |
Write a data to the USART data register. More... | |
enum status_code | usart_putchar (USART_t *usart, uint8_t c) |
Send a data with the USART module. More... | |
static void | usart_rx_disable (USART_t *usart) |
Disable USART receiver. More... | |
static void | usart_rx_enable (USART_t *usart) |
Enable USART receiver. More... | |
static bool | usart_rx_is_complete (USART_t *usart) |
Checks if the RX complete interrupt flag is set. More... | |
bool | usart_set_baudrate (USART_t *usart, uint32_t baud, uint32_t cpu_hz) |
Set the baudrate value in the USART module. More... | |
void | usart_set_baudrate_precalculated (USART_t *usart, uint32_t baud, uint32_t cpu_hz) |
Set the baudrate using precalculated BAUDCTRL values from PROGMEM. More... | |
void | usart_set_bsel_bscale_value (USART_t *usart, uint16_t bsel, uint8_t bscale) |
Set the baudrate by setting the BSEL and BSCALE values in the USART. More... | |
static void | usart_set_dre_interrupt_level (USART_t *usart, enum usart_int_level_t level) |
Set USART DRE interrupt level. More... | |
static void | usart_set_mode (USART_t *usart, USART_CMODE_t usartmode) |
Set the mode the USART run in. More... | |
static void | usart_set_rx_interrupt_level (USART_t *usart, enum usart_int_level_t level) |
Set USART RXD interrupt level. More... | |
static void | usart_set_tx_interrupt_level (USART_t *usart, enum usart_int_level_t level) |
Set USART TXD interrupt level. More... | |
void | usart_spi_set_baudrate (USART_t *usart, uint32_t baud, uint32_t cpu_hz) |
Set the baudrate value in the USART_SPI module. More... | |
static uint8_t | usart_spi_transmit (USART_t *usart, uint8_t txdata) |
Performs a data transfer on the USART in SPI mode. More... | |
static void | usart_tx_disable (USART_t *usart) |
Disable USART transmitter. More... | |
static void | usart_tx_enable (USART_t *usart) |
Enable USART transmitter. More... | |
static bool | usart_tx_is_complete (USART_t *usart) |
Checks if the TX complete interrupt flag is set. More... | |