See Quick start guide for USART module.
This is a driver for configuring, enabling, disabling and use of the on-chip USART.
The USART module depends on the following modules:
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the USART module (USART). | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the USART module (USART). | |
Data Structures | |
struct | usart_rs232_options |
struct | usart_spi_options |
struct | USART_struct |
Macros | |
#define | USART_BAUD_1200 0x00 |
#define | USART_BAUD_19200 0x04 |
#define | USART_BAUD_2400 0x01 |
#define | USART_BAUD_38400 0x05 |
#define | USART_BAUD_4800 0x02 |
#define | USART_BAUD_57600 0x06 |
#define | USART_BAUD_9600 0x03 |
#define | USART_BAUD_UNDEFINED 0xFF |
#define | USART_CHSIZE00_bm 0x02 /* Character Size 00 bit 1 mask. */ |
#define | USART_CHSIZE00_bp 1 /* Character Size bit 00 position. */ |
#define | USART_CHSIZE01_bm 0x04 /* Character Size 10 bit 1 mask. */ |
#define | USART_CHSIZE01_bp 2 /* Character Size 10 bit position. */ |
#define | USART_CHSIZE01C_gm 0x06 /* Character Size 10 bit 1 mask. */ |
#define | USART_CHSIZE01C_gp 1 /* Character Size 10 bit position. */ |
#define | USART_CHSIZE2_bm 0x04 /* Character Size bit mask. */ |
#define | USART_CHSIZE2_bp 2 /* Character Size bit position. */ |
#define | USART_DOR_bm 0x08 /* Data Over Run bit mask.*/ |
#define | USART_DOR_bp 3 /* Data Over Run bit position.*/ |
#define | USART_DORD_bm 0x04 /* Data order bit mask. */ |
#define | USART_DORD_bp 2 /* Data order bit position. */ |
#define | USART_DRE_bm 0x20 /* DATA Register Empty Bit mask.*/ |
#define | USART_DRE_bp 5 /* DATA Register Empty bit position.*/ |
#define | USART_DRIE_bm 0x20 /* Data register empty interrupt Enable bit mask.*/ |
#define | USART_DRIE_bp 5 /* Data register empty interrupt Enable bit position.*/ |
#define | USART_FE_bm 0x10 /* Frame Error bit mask.*/ |
#define | USART_FE_bp 4 /*Frame error bit position.*/ |
#define | USART_MPCM_bm 0x01 /* Multi Processor bit mask.*/ |
#define | USART_MPMC_bp 0 /* Multi processor bit position.*/ |
#define | USART_PMODE00_bm 0x10 /* USART Parity Mode Select 00 bit mask.*/ |
#define | USART_PMODE00_bp 4 /* USART Parity Mode Select 00 bit position.*/ |
#define | USART_PMODE01_bm 0x20 /* USART Parity Mode Select 01 bit mask.*/ |
#define | USART_PMODE01_bp 5 /* USART Parity Mode Select 01 bit position.*/ |
#define | USART_PMODE_gm 0x30 /* USART Parity Mode Select grp mask.*/ |
#define | USART_PMODE_gp 4 /* USART Parity Mode Select grp position.*/ |
#define | USART_RXB8_bm 0x02 /* Transmit bit 8 bit mask. */ |
#define | USART_RXB8_bp 1 /* Transmit bit 8 bit position. */ |
#define | USART_RXC_bm 0x80 /* RX complete bit mask.*/ |
#define | USART_RXC_bp 7 /* RX complete bit position.*/ |
#define | USART_RXCIE_bm 0x80 /* RX complete interrupt Enable bit mask.*/ |
#define | USART_RXCIE_bp 7 /* RX complete interrupt Enable bit position.*/ |
#define | USART_RXEN_bm 0x10 /* Receiver Enable bit mask. */ |
#define | USART_RXEN_bp 4 /* Receiver Enable bit position. */ |
#define | USART_STOPB_bm 0x08 /* USART stop bit mask.*/ |
#define | USART_STOPB_bp 3 /* USART stop bit Position.*/ |
#define | USART_TXB8_bm 0x01 /* Transmit bit 8 bit mask. */ |
#define | USART_TXB8_bp 0 /* Transmit bit 8 bit position. */ |
#define | USART_TXC_bm 0x40 /* TX complete bit mask.*/ |
#define | USART_TXC_bp 6 /* TX complete bit position.*/ |
#define | USART_TXCIE_bm 0x40 /* TX complete interrupt Enable bit mask.*/ |
#define | USART_TXCIE_bp 6 /* TX complete interrupt Enable bit position.*/ |
#define | USART_TXEN_bm 0x08 /* Transmitter Enable bit mask. */ |
#define | USART_TXEN_bp 3 /* Transmitter Enable bit position. */ |
#define | USART_U2X_bm 0x02 /* Double TX speed bit mask.*/ |
#define | USART_U2X_bp 1 /* Double TX speed bit position.*/ |
#define | USART_UCPHA_bm 0x02 /* Clock Phase bit mask. */ |
#define | USART_UCPHA_bp 1 /* Clock Phase bit position. */ |
#define | USART_UCPOL_bm 0x01 /* Sync mode Pol bit 1 mask. */ |
#define | USART_UCPOL_bp 0 /*Sync mode Pol bit 0 position */ |
#define | USART_UMSEL00_bm 0x40 /* USART Mode Select 00 bit mask.*/ |
#define | USART_UMSEL00_bp 6 /* USART Mode Select 00 bit position.*/ |
#define | USART_UMSEL01_bm 0x80 /* USART Mode Select 01 bit mask.*/ |
#define | USART_UMSEL01_bp 7 /* USART Mode Select 01 bit position.*/ |
#define | USART_UMSEL01_gm 0xC0 /* USART Mode Select 01 grp mask.*/ |
#define | USART_UMSEL01_gp 6 /* USART Mode Select 01 grp position.*/ |
#define | USART_UPE_bm 0x04 /* Parity error bit mask.*/ |
#define | USART_UPE_bp 2 /* Parity error bit position.*/ |
#define | USARTA0 |
#define | USARTA1 |
Typedefs | |
typedef volatile uint16_t | register16_t |
typedef volatile uint8_t | register8_t |
typedef enum USART_CHSIZE_enum | USART_CHSIZE_t |
typedef enum USART_CMODE_enum | USART_CMODE_t |
typedef enum USART_PMODE_enum | USART_PMODE_t |
typedef struct usart_rs232_options | usart_rs232_options_t |
typedef struct usart_spi_options | usart_spi_options_t |
typedef struct USART_struct | USART_t |
Enumerations | |
enum | USART_CHSIZE_enum { USART_CHSIZE_5BIT_gc = (0x00), USART_CHSIZE_6BIT_gc = (0x01), USART_CHSIZE_7BIT_gc = (0x02), USART_CHSIZE_8BIT_gc = (0x03), USART_CHSIZE_9BIT_gc = (0x07), USART_CHSIZE_5BIT_gc = (0x00), USART_CHSIZE_6BIT_gc = (0x01), USART_CHSIZE_7BIT_gc = (0x02), USART_CHSIZE_8BIT_gc = (0x03), USART_CHSIZE_9BIT_gc = (0x07) } |
enum | USART_CMODE_enum { USART_CMODE_ASYNCHRONOUS_gc = (0x00 << USART_UMSEL01_gp), USART_CMODE_SYNCHRONOUS_gc = (0x01 << USART_UMSEL01_gp), USART_CMODE_IRDA_gc = (0x02 << USART_UMSEL01_gp), USART_CMODE_MSPI_gc = (0x03 << USART_UMSEL01_gp), USART_CMODE_ASYNCHRONOUS_gc = (0x00 << USART_UMSEL01_gp), USART_CMODE_SYNCHRONOUS_gc = (0x01 << USART_UMSEL01_gp), USART_CMODE_IRDA_gc = (0x02 << USART_UMSEL01_gp), USART_CMODE_MSPI_gc = (0x03 << USART_UMSEL01_gp) } |
enum | USART_PMODE_enum { USART_PMODE_DISABLED_gc = (0x00 << USART_PMODE_gp), USART_PMODE_EVEN_gc = (0x02 << USART_PMODE_gp), USART_PMODE_ODD_gc = (0x03 << USART_PMODE_gp), USART_PMODE_DISABLED_gc = (0x00 << USART_PMODE_gp), USART_PMODE_EVEN_gc = (0x02 << USART_PMODE_gp), USART_PMODE_ODD_gc = (0x03 << USART_PMODE_gp) } |
Functions | |
static | PROGMEM_DECLARE (uint16_t, baudctrl_1mhz[]) |
static | PROGMEM_DECLARE (uint16_t, baudctrl_8mhz[]) |
static | PROGMEM_DECLARE (uint16_t, baudctrl_16mhz[]) |
static void | usart_clear_tx_complete (USART_t *usart) |
Clear TX complete interrupt flag. More... | |
static void | usart_data_empty_interrupt_disable (USART_t *usart) |
Disable USART data register empty interrupt. More... | |
static void | usart_data_empty_interrupt_enable (USART_t *usart) |
Enable USART data register empty interrupt. More... | |
static bool | usart_data_register_is_empty (USART_t *usart) |
Check if data register empty flag is set. More... | |
static void | usart_double_baud_disable (USART_t *usart) |
Disable the Doubling of USART transmission speed. More... | |
static void | usart_double_baud_enable (USART_t *usart) |
Double the USART transmission speed. 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... | |
status_code_t | usart_putchar (USART_t *usart, uint8_t c) |
Send a data with the USART module. More... | |
static void | usart_rx_complete_interrupt_disable (USART_t *usart) |
Disable USART receive complete interrupt. More... | |
static void | usart_rx_complete_interrupt_enable (USART_t *usart) |
Enable USART receive complete interrupt. 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 pre calculated BAUDCTRL values stored in program memory. More... | |
static void | usart_set_mode (USART_t *usart, USART_CMODE_t usartmode) |
Set the mode the USART run in. 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_complete_interrupt_disable (USART_t *usart) |
Disable USART transmit complete interrupt. More... | |
static void | usart_tx_complete_interrupt_enable (USART_t *usart) |
Enable USART transmit complete interrupt. 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... | |
In this use case, the USART module is configured for:
The following configuration must be added to the project (typically to a conf_usart_example.h file, but it can also be added to your main application file.)
Add to application initialization:
Add to application C-file:
A variable for the received byte must be added:
Add to application initialization:
Add to, e.g., main loop in application C-file:
#define USART_BAUD_1200 0x00 |
#define USART_BAUD_19200 0x04 |
#define USART_BAUD_2400 0x01 |
#define USART_BAUD_38400 0x05 |
#define USART_BAUD_4800 0x02 |
#define USART_BAUD_57600 0x06 |
#define USART_BAUD_9600 0x03 |
#define USART_BAUD_UNDEFINED 0xFF |
#define USART_CHSIZE00_bm 0x02 /* Character Size 00 bit 1 mask. */ |
#define USART_CHSIZE00_bp 1 /* Character Size bit 00 position. */ |
#define USART_CHSIZE01_bm 0x04 /* Character Size 10 bit 1 mask. */ |
#define USART_CHSIZE01_bp 2 /* Character Size 10 bit position. */ |
#define USART_CHSIZE01C_gm 0x06 /* Character Size 10 bit 1 mask. */ |
Referenced by usart_format_set().
#define USART_CHSIZE01C_gp 1 /* Character Size 10 bit position. */ |
Referenced by usart_format_set().
#define USART_CHSIZE2_bm 0x04 /* Character Size bit mask. */ |
Referenced by usart_format_set().
#define USART_CHSIZE2_bp 2 /* Character Size bit position. */ |
Referenced by usart_format_set().
#define USART_DOR_bm 0x08 /* Data Over Run bit mask.*/ |
#define USART_DOR_bp 3 /* Data Over Run bit position.*/ |
#define USART_DORD_bm 0x04 /* Data order bit mask. */ |
#define USART_DORD_bp 2 /* Data order bit position. */ |
#define USART_DRE_bm 0x20 /* DATA Register Empty Bit mask.*/ |
Referenced by usart_data_register_is_empty().
#define USART_DRE_bp 5 /* DATA Register Empty bit position.*/ |
#define USART_DRIE_bm 0x20 /* Data register empty interrupt Enable bit mask.*/ |
Referenced by usart_data_empty_interrupt_disable(), and usart_data_empty_interrupt_enable().
#define USART_DRIE_bp 5 /* Data register empty interrupt Enable bit position.*/ |
#define USART_FE_bm 0x10 /* Frame Error bit mask.*/ |
#define USART_FE_bp 4 /*Frame error bit position.*/ |
#define USART_MPCM_bm 0x01 /* Multi Processor bit mask.*/ |
#define USART_MPMC_bp 0 /* Multi processor bit position.*/ |
#define USART_PMODE00_bm 0x10 /* USART Parity Mode Select 00 bit mask.*/ |
#define USART_PMODE00_bp 4 /* USART Parity Mode Select 00 bit position.*/ |
#define USART_PMODE01_bm 0x20 /* USART Parity Mode Select 01 bit mask.*/ |
#define USART_PMODE01_bp 5 /* USART Parity Mode Select 01 bit position.*/ |
#define USART_PMODE_gm 0x30 /* USART Parity Mode Select grp mask.*/ |
Referenced by usart_format_set().
#define USART_PMODE_gp 4 /* USART Parity Mode Select grp position.*/ |
#define USART_RXB8_bm 0x02 /* Transmit bit 8 bit mask. */ |
#define USART_RXB8_bp 1 /* Transmit bit 8 bit position. */ |
#define USART_RXC_bm 0x80 /* RX complete bit mask.*/ |
#define USART_RXC_bp 7 /* RX complete bit position.*/ |
#define USART_RXCIE_bm 0x80 /* RX complete interrupt Enable bit mask.*/ |
#define USART_RXCIE_bp 7 /* RX complete interrupt Enable bit position.*/ |
#define USART_RXEN_bm 0x10 /* Receiver Enable bit mask. */ |
Referenced by usart_rx_disable(), and usart_rx_enable().
#define USART_RXEN_bp 4 /* Receiver Enable bit position. */ |
#define USART_STOPB_bm 0x08 /* USART stop bit mask.*/ |
Referenced by usart_format_set().
#define USART_STOPB_bp 3 /* USART stop bit Position.*/ |
Referenced by usart_format_set().
#define USART_TXB8_bm 0x01 /* Transmit bit 8 bit mask. */ |
#define USART_TXB8_bp 0 /* Transmit bit 8 bit position. */ |
#define USART_TXC_bm 0x40 /* TX complete bit mask.*/ |
#define USART_TXC_bp 6 /* TX complete bit position.*/ |
#define USART_TXCIE_bm 0x40 /* TX complete interrupt Enable bit mask.*/ |
#define USART_TXCIE_bp 6 /* TX complete interrupt Enable bit position.*/ |
#define USART_TXEN_bm 0x08 /* Transmitter Enable bit mask. */ |
Referenced by usart_tx_disable(), and usart_tx_enable().
#define USART_TXEN_bp 3 /* Transmitter Enable bit position. */ |
#define USART_U2X_bm 0x02 /* Double TX speed bit mask.*/ |
Referenced by usart_double_baud_disable(), and usart_double_baud_enable().
#define USART_U2X_bp 1 /* Double TX speed bit position.*/ |
#define USART_UCPHA_bm 0x02 /* Clock Phase bit mask. */ |
#define USART_UCPHA_bp 1 /* Clock Phase bit position. */ |
#define USART_UCPOL_bm 0x01 /* Sync mode Pol bit 1 mask. */ |
#define USART_UCPOL_bp 0 /*Sync mode Pol bit 0 position */ |
#define USART_UMSEL00_bm 0x40 /* USART Mode Select 00 bit mask.*/ |
#define USART_UMSEL00_bp 6 /* USART Mode Select 00 bit position.*/ |
#define USART_UMSEL01_bm 0x80 /* USART Mode Select 01 bit mask.*/ |
#define USART_UMSEL01_bp 7 /* USART Mode Select 01 bit position.*/ |
#define USART_UMSEL01_gm 0xC0 /* USART Mode Select 01 grp mask.*/ |
Referenced by usart_set_mode().
#define USART_UMSEL01_gp 6 /* USART Mode Select 01 grp position.*/ |
#define USART_UPE_bm 0x04 /* Parity error bit mask.*/ |
#define USART_UPE_bp 2 /* Parity error bit position.*/ |
#define USARTA0 |
#define USARTA1 |
typedef volatile uint16_t register16_t |
typedef volatile uint8_t register8_t |
typedef enum USART_CHSIZE_enum USART_CHSIZE_t |
typedef enum USART_CMODE_enum USART_CMODE_t |
typedef enum USART_PMODE_enum USART_PMODE_t |
typedef struct usart_rs232_options usart_rs232_options_t |
typedef struct usart_spi_options usart_spi_options_t |
typedef struct USART_struct USART_t |
enum USART_CHSIZE_enum |
enum USART_CMODE_enum |
enum USART_PMODE_enum |
|
static |
|
static |
|
static |
|
inlinestatic |
Clear TX complete interrupt flag.
TX flag is clear after complete transmission, automatically.
usart | The USART module. |
References USART_struct::UCSRnA, and USART_TXC_bm.
Referenced by usart_spi_transmit().
|
inlinestatic |
Disable USART data register empty interrupt.
usart | Pointer to the USART module. |
References USART_DRIE_bm.
|
inlinestatic |
Enable USART data register empty interrupt.
usart | Pointer to the USART module. |
References USART_DRIE_bm.
|
inlinestatic |
Check if data register empty flag is set.
usart | The USART module. |
References USART_DRE_bm.
Referenced by usart_spi_transmit().
|
inlinestatic |
Disable the Doubling of USART transmission speed.
usart | The USART module. |
References USART_struct::UCSRnA, and USART_U2X_bm.
|
inlinestatic |
Double the USART transmission speed.
usart | The USART module. |
References USART_struct::UCSRnA, and USART_U2X_bm.
|
inlinestatic |
Configure the USART frame format.
Sets the frame format, Frame Size, parity mode and number of stop bits.
usart | Pointer to the USART module |
charSize | The character size. Use USART_CHSIZE_t type. |
parityMode | The parity Mode. Use USART_PMODE_t type. |
twoStopBits | Enable two stop bit mode. Use bool type. |
References USART_CHSIZE01C_gm, USART_CHSIZE01C_gp, USART_CHSIZE2_bm, USART_CHSIZE2_bp, USART_PMODE_gm, USART_STOPB_bm, and USART_STOPB_bp.
|
inlinestatic |
Read a data to the USART data register.
usart | The USART module. |
Referenced by usart_spi_transmit().
uint8_t usart_getchar | ( | USART_t * | usart | ) |
Receive a data with the USART module.
This function returns the received data from the USART module.
usart | The USART module. |
References USART_struct::UDR, and usart_rx_is_complete().
Referenced by main(), run_loopback_syncmode_test(), run_loopback_test(), and usart_serial_getchar().
bool usart_init_rs232 | ( | USART_t * | usart, |
const usart_rs232_options_t * | opt | ||
) |
Initialize USART in RS232 mode.
This function initializes the USART module in RS232 mode using the usart_rs232_options_t configuration structure and CPU frequency.
usart | The USART module. |
opt | The RS232 configuration option. |
true | if the initialization was successful |
false | if the initialization failed (error in baud rate calculation) |
References usart_rs232_options::baudrate, usart_rs232_options::charlength, usart_rs232_options::paritytype, usart_rs232_options::stopbits, sysclk_get_source_clock_hz(), USART_CMODE_ASYNCHRONOUS_gc, usart_enable_module_clock(), usart_format_set(), usart_rx_enable(), usart_set_baudrate(), usart_set_mode(), and usart_tx_enable().
Referenced by main(), run_check_registers_test(), run_loopback_test(), and usart_serial_init().
void usart_init_spi | ( | USART_t * | usart, |
const usart_spi_options_t * | opt | ||
) |
Initialize USART in SPI master mode.
This function initializes the USART module in SPI master mode using the usart_spi_options_t configuration structure and CPU frequency.
usart | The USART module. |
opt | The RS232 configuration option. |
References usart_spi_options::baudrate, usart_spi_options::data_order, ioport_configure_port_pin(), IOPORT_CREATE_PIN, IOPORT_DIR_OUTPUT, IOPORT_INIT_HIGH, ioport_pin_to_mask(), ioport_pin_to_port(), usart_spi_options::spimode, sysclk_get_source_clock_hz(), USART_struct::UBRR, USART_struct::UCSRnC, USART_CMODE_MSPI_gc, USART_DORD_bm, usart_enable_module_clock(), usart_rx_enable(), usart_set_mode(), usart_spi_set_baudrate(), usart_tx_enable(), USART_UCPHA_bm, and USART_UCPOL_bm.
Referenced by usart_spi_setup_device().
|
inlinestatic |
Write a data to the USART data register.
usart | The USART module. |
txdata | The data to be transmitted. |
Referenced by usart_spi_transmit().
status_code_t usart_putchar | ( | USART_t * | usart, |
uint8_t | c | ||
) |
Send a data with the USART module.
This function outputs a data using the USART module.
usart | The USART module. |
c | The data to send. |
References STATUS_OK, USART_struct::UDR, and usart_data_register_is_empty().
Referenced by example_cmp1_int_cb(), example_cmp2_int_cb(), example_cmp3_int_cb(), example_ovf_int_cb(), main(), run_loopback_syncmode_test(), run_loopback_test(), and usart_serial_putchar().
|
inlinestatic |
Disable USART receive complete interrupt.
usart | Pointer to the USART module. |
References USART_RXC_bm.
|
inlinestatic |
Enable USART receive complete interrupt.
usart | Pointer to the USART module. |
References USART_RXC_bm.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Checks if the RX complete interrupt flag is set.
Checks if the RX complete interrupt flag is set.
usart | The USART module. |
References USART_RXC_bm.
bool usart_set_baudrate | ( | USART_t * | usart, |
uint32_t | baud, | ||
uint32_t | cpu_hz | ||
) |
Set the baudrate value in the USART module.
This function sets the baudrate register with scaling regarding the CPU frequency and makes sure the baud rate is supported by the hardware. The function can be used if you don't want to calculate the settings yourself or changes to baudrate at runtime is required.
usart | The USART module. |
baud | The baudrate. |
cpu_hz | The CPU frequency. |
true | if the hardware supports the baud rate |
false | if the hardware does not support the baud rate (i.e. it's either too high or too low.) |
References USART_struct::UBRR, USART_struct::UCSRnA, and USART_U2X_bm.
Referenced by run_baudrate_test(), and usart_init_rs232().
void usart_set_baudrate_precalculated | ( | USART_t * | usart, |
uint32_t | baud, | ||
uint32_t | cpu_hz | ||
) |
Set the baudrate using pre calculated BAUDCTRL values stored in program memory.
usart | The USART module. |
baud | The baudrate. |
cpu_hz | The CPU frequency. |
References Assert, PROGMEM_READ_WORD, USART_struct::UBRR, USART_BAUD_UNDEFINED, and usart_get_baud_offset().
|
inlinestatic |
Set the mode the USART run in.
Set the mode the USART run in. The default mode is asynchronous mode.
usart | Pointer to the USART module register section. |
usartmode | Selects the USART mode. Use USART_CMODE_t type. |
USART modes:
References USART_UMSEL01_gm.
void usart_spi_set_baudrate | ( | USART_t * | usart, |
uint32_t | baud, | ||
uint32_t | cpu_hz | ||
) |
Set the baudrate value in the USART_SPI module.
This function sets the baudrate register regarding the CPU frequency.
usart | The USART(SPI) module. |
baud | The baudrate. |
cpu_hz | The CPU frequency. |
References USART_struct::UBRR.
Referenced by run_loopback_syncmode_test(), and usart_init_spi().
|
inlinestatic |
Performs a data transfer on the USART in SPI mode.
usart | The USART module. |
txdata | The data to be transmitted. |
References usart_clear_tx_complete(), usart_data_register_is_empty(), usart_get(), usart_put(), and usart_tx_is_complete().
|
inlinestatic |
Disable USART transmit complete interrupt.
usart | Pointer to the USART module. |
References USART_TXC_bm.
|
inlinestatic |
Enable USART transmit complete interrupt.
usart | Pointer to the USART module. |
References USART_TXC_bm.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Checks if the TX complete interrupt flag is set.
Checks if the TX complete interrupt flag is set.
usart | The USART module. |
References USART_TXC_bm.
Referenced by usart_spi_transmit().