This file defines a useful set of functions for the Serial interface on AVR XMEGA devices.
Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.
#include "compiler.h"
#include "sysclk.h"
#include "status_codes.h"
#include "usart.h"
#include "conf_usart_serial.h"
Typedefs | |
typedef USART_t * | usart_if |
This type can be used independently to refer to USART module for the architecture used. More... | |
typedef usart_rs232_options_t | usart_serial_options_t |
Functions | |
static void | usart_serial_getchar (usart_if usart, uint8_t *data) |
Waits until a character is received, and returns it. More... | |
static bool | usart_serial_init (usart_if usart, const usart_serial_options_t *options) |
Initializes the Usart in master mode. More... | |
static enum status_code | usart_serial_putchar (usart_if usart, uint8_t c) |
Sends a character with the USART. More... | |
status_code_t | usart_serial_read_packet (usart_if usart, uint8_t *data, size_t len) |
Receive a sequence of bytes from USART device. More... | |
status_code_t | usart_serial_write_packet (usart_if usart, const uint8_t *data, size_t len) |
Send a sequence of bytes to USART device. More... | |
This type can be used independently to refer to USART module for the architecture used.
It refers to the correct type definition for the architecture, ie. USART_t* for XMEGA or avr32_usart_t* for UC3.
|
inlinestatic |
Waits until a character is received, and returns it.
usart | Base address of the USART instance. |
data | Data to read |
References usart_getchar().
Referenced by gfx_mono_screen_dump(), stdio_serial_init(), and usart_serial_read_packet().
|
inlinestatic |
Initializes the Usart in master mode.
usart | Base address of the USART instance. |
options | Options needed to set up RS232 communication (see usart_serial_options_t). |
true | if the initialization was successful |
false | if 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_enable_module(), SYSCLK_PORT_C, SYSCLK_PORT_D, SYSCLK_PORT_E, SYSCLK_PORT_F, and usart_init_rs232().
Referenced by gfx_mono_screen_dump_init(), log_init(), main(), sio2ncp_init(), and stdio_serial_init().
|
inlinestatic |
Sends a character with the USART.
usart | Base address of the USART instance. |
c | Character to write. |
References usart_putchar().
Referenced by stdio_serial_init(), and usart_serial_write_packet().
status_code_t usart_serial_read_packet | ( | usart_if | usart, |
uint8_t * | data, | ||
size_t | len | ||
) |
Receive a sequence of bytes from USART device.
usart | Base address of the USART instance. |
data | Data buffer to write |
len | Length of data |
References STATUS_OK, and usart_serial_getchar().
status_code_t usart_serial_write_packet | ( | usart_if | usart, |
const uint8_t * | data, | ||
size_t | len | ||
) |
Send a sequence of bytes to USART device.
usart | Base address of the USART instance. |
data | Data buffer to read |
len | Length of data |
References STATUS_OK, and usart_serial_putchar().
Referenced by gfx_mono_screen_dump(), log_sha204(), log_sha204_title(), main(), mxt_handler(), sio2host_tx(), sio2ncp_tx(), and usart_write_crlf().