USART driver for AVR MEGA.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include "compiler.h"
#include "usart_mega.h"
#include "sysclk.h"
#include "ioport.h"
#include "status_codes.h"
Functions | |
static void | usart_enable_module_clock (USART_t *usart) |
Enable the system clock to an USART module. More... | |
static uint8_t | usart_get_baud_offset (uint32_t baud) |
Get the offset for lookup in the baudrate table. 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... | |
status_code_t | usart_putchar (USART_t *usart, uint8_t c) |
Send a data with the USART module. 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... | |
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... | |
|
inlinestatic |
Enable the system clock to an USART module.
This function will enable the system clock to the provided
usart Pointer to an USART module.
References PRUSART0_bm, and sysclk_enable_module().
Referenced by usart_init_rs232(), and usart_init_spi().
|
static |
Get the offset for lookup in the baudrate table.
baud | The requested baudrate |
USART_BAUD_UNDEFINED | for baudrates not in lookup table |
References USART_BAUD_1200, USART_BAUD_19200, USART_BAUD_2400, USART_BAUD_38400, USART_BAUD_4800, USART_BAUD_57600, USART_BAUD_9600, and USART_BAUD_UNDEFINED.
Referenced by usart_set_baudrate_precalculated().