Usart Serial driver for AVR UC3.
This file defines a useful set of functions for the Serial interface on AVR UC3 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"
Macros | |
Serial Management Configuration | |
#define | CONFIG_USART_SERIAL_MODE USART_NORMAL_CHMODE |
Default Usart Mode. More... | |
Typedefs | |
typedef volatile avr32_usart_t * | usart_if |
This type can be used independently to refer to USART module for the architecture used. More... | |
typedef usart_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 (volatile avr32_usart_t *usart, usart_serial_options_t *opt) |
Initializes the Usart in master mode. More... | |
static int | 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 to a 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 a USART device. More... | |
#define CONFIG_USART_SERIAL_MODE USART_NORMAL_CHMODE |
Default Usart Mode.
Referenced by usart_serial_init().
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 stdio_serial_init(), and usart_serial_read_packet().
|
inlinestatic |
Initializes the Usart in master mode.
usart | Base address of the USART instance. |
opt | Options needed to set up RS232 communication (see usart_options_t). |
true | if the initialization was successful |
false | if initialization failed (error in baud rate calculation) |
References usart_options_t::channelmode, CONFIG_USART_SERIAL_MODE, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), and usart_init_rs232().
Referenced by stdio_serial_init().
|
inlinestatic |
Sends a character with the USART.
usart | Base address of the USART instance. |
c | Character to write. |
1 | The character was written. |
0 | The function timed out before the USART transmitter became ready to send. |
References USART_SUCCESS, and usart_write_char().
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 to a USART device.
usart | Base address of the USART instance. |
data | data buffer to write |
len | Length of data |
Receive a sequence of bytes to a 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 a USART device.
usart | Base address of the USART instance. |
data | data buffer to write |
len | Length of data |
Send a sequence of bytes to a 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().