Microchip® Advanced Software Framework

usart_serial.h File Reference

USART Serial wrapper service for the SAM D/L/C/R devices.

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

#include "compiler.h"
#include "status_codes.h"
#include "usart.h"

Serial Management Configuration

typedef Sercom * usart_inst_t
 
static bool usart_serial_init (struct usart_module *const module, usart_inst_t const hw, const struct usart_config *const config)
 Initializes the Usart in serial mode. More...
 
static enum status_code usart_serial_putchar (struct usart_module *const module, uint8_t c)
 Sends a character with the USART. More...
 
static void usart_serial_getchar (struct usart_module *const module, uint8_t *c)
 Waits until a character is received, and returns it. More...
 
static enum status_code usart_serial_write_packet (struct usart_module *const module, const uint8_t *tx_data, uint16_t length)
 Send a sequence of bytes to USART device. More...
 
static enum status_code usart_serial_read_packet (struct usart_module *const module, uint8_t *rx_data, uint16_t length)
 Receive a sequence of bytes from USART device. More...
 

typedef Sercom* usart_inst_t

static void usart_serial_getchar ( struct usart_module *const  module,
uint8_t *  c 
)
inlinestatic

Waits until a character is received, and returns it.

Parameters
[in,out]moduleSoftware instance of the USART.
[out]cDestination for the read character.

References STATUS_OK, and usart_read_wait().

static bool usart_serial_init ( struct usart_module *const  module,
usart_inst_t const  hw,
const struct usart_config *const  config 
)
inlinestatic

Initializes the Usart in serial mode.

Parameters
[in,out]moduleSoftware instance of the USART to initialize.
[in]hwBase address of the hardware USART.
[in]configConfiguration settings for the USART.
Return values
trueif the initialization was successful
falseif initialization failed (error in baud rate calculation)

References STATUS_OK, and usart_init().

static enum status_code usart_serial_putchar ( struct usart_module *const  module,
uint8_t  c 
)
inlinestatic

Sends a character with the USART.

Parameters
[in,out]moduleSoftware instance of the USART.
[in]cCharacter to write.
Returns
Status code

References STATUS_OK, and usart_write_wait().

static enum status_code usart_serial_read_packet ( struct usart_module *const  module,
uint8_t *  rx_data,
uint16_t  length 
)
inlinestatic

Receive a sequence of bytes from USART device.

Parameters
[in,out]moduleSoftware instance of the USART.
[out]rx_dataData buffer to store the read data into.
[in]lengthLength of data to read.

References usart_read_buffer_wait().

static enum status_code usart_serial_write_packet ( struct usart_module *const  module,
const uint8_t *  tx_data,
uint16_t  length 
)
inlinestatic

Send a sequence of bytes to USART device.

Parameters
[in,out]moduleSoftware instance of the USART.
[in]tx_dataData buffer to read the data to write from.
[in]lengthLength of data to write.

References usart_write_buffer_wait().

Referenced by sio2host_tx().