Microchip® Advanced Software Framework

uart_serial.h File Reference

Uart Serial for SAM.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "sysclk.h"
#include "uart.h"
#include "usart.h"
#include "conf_uart_serial.h"

Data Structures

struct  uart_rs232_options
 Input parameters when initializing RS232 and similar modes. More...
 

Typedefs

typedef Usart * usart_if
 This type can be used independently to refer to USART module for the architecture used. More...
 
typedef struct uart_rs232_options usart_rs232_options_t
 Input parameters when initializing RS232 and similar modes. More...
 
typedef usart_rs232_options_t usart_serial_options_t
 

Functions

static void usart_serial_getchar (usart_if p_usart, uint8_t *data)
 Waits until a character is received, and returns it. More...
 
static void usart_serial_init (usart_if p_usart, usart_serial_options_t *opt)
 Initializes the Usart in master mode. More...
 
static uint32_t usart_serial_is_rx_ready (usart_if p_usart)
 Check if Received data is ready. More...
 
static int usart_serial_putchar (usart_if p_usart, const 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...
 

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.

Input parameters when initializing RS232 and similar modes.

static void usart_serial_getchar ( usart_if  p_usart,
uint8_t *  data 
)
inlinestatic

Waits until a character is received, and returns it.

Parameters
p_usartBase address of the USART instance.
dataData to read

References UART, UNUSED, and usart_read().

Referenced by get_input_value(), main(), stdio_serial_init(), and usart_serial_read_packet().

static void usart_serial_init ( usart_if  p_usart,
usart_serial_options_t opt 
)
inlinestatic
static uint32_t usart_serial_is_rx_ready ( usart_if  p_usart)
inlinestatic

Check if Received data is ready.

Parameters
p_usartBase address of the USART instance.
Return values
1One data has been received.
0No data has been received.

References UART, and usart_is_rx_ready().

static int usart_serial_putchar ( usart_if  p_usart,
const uint8_t  c 
)
inlinestatic

Sends a character with the USART.

Parameters
p_usartBase address of the USART instance.
cCharacter to write.
Returns
Status.
Return values
1The character was written.
0The function timed out before the USART transmitter became ready to send.

References UART, and usart_write().

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.

Parameters
usartBase address of the USART instance.
datadata buffer to write
lenLength of data

Receive a sequence of bytes to a USART device.

Parameters
usartBase address of the USART instance.
dataData buffer to write
lenLength 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.

Parameters
usartBase address of the USART instance.
datadata buffer to write
lenLength of data

Send a sequence of bytes to a USART device.

Parameters
usartBase address of the USART instance.
dataData buffer to read
lenLength of data

References STATUS_OK, and usart_serial_putchar().

Referenced by main(), sio2host_tx(), and sio2ncp_tx().