USART functions for SAM-BA on SAM0.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | ACK 0x06 |
#define | CAN 0x18 |
#define | CRC16POLY 0x1021 |
#define | EOT 0x04 |
#define | ESC 0x1b |
#define | NAK 0x15 |
#define | PKTLEN_128 128 |
#define | SHARP_CHARACTER '#' |
#define | SOH 0x01 |
#define | USART_BUFFER_SIZE 128 |
#define | USART_DEFAULT_TIMEOUT 1000 |
Functions | |
unsigned short | add_crc (char ptr, unsigned short crc) |
Gets data from usart line using Xmodem protocol. More... | |
uint8_t | getPacket (uint8_t *pData, uint8_t sno) |
Used by Xdown to retrieve packets. More... | |
void | usart_close (void) |
Stops the USART. More... | |
int | usart_getc (void) |
Waits and gets a value on usart line. More... | |
uint32_t | usart_getdata (void *data, uint32_t length) |
Gets data from usart line. More... | |
uint32_t | usart_getdata_xmd (void *data, uint32_t length) |
Gets data from usart line using Xmodem protocol. More... | |
bool | usart_is_rx_ready (void) |
This function checks if a character has been received on the usart line. More... | |
void | usart_open (void) |
Open the given USART. More... | |
int | usart_putc (int value) |
Puts a byte on usart line. More... | |
uint32_t | usart_putdata (void const *data, uint32_t length) |
Send buffer on usart line. More... | |
uint32_t | usart_putdata_xmd (void const *data, uint32_t length) |
Send buffer on usart line using Xmodem protocol. More... | |
int | usart_readc (void) |
Gets a value on usart line. More... | |
int | usart_sharp_received (void) |
Returns true if the SAM-BA Uart received the sharp char. More... | |
#define ACK 0x06 |
Referenced by getPacket(), usart_getdata_xmd(), and usart_putdata_xmd().
#define CAN 0x18 |
Referenced by getPacket(), usart_getdata_xmd(), and usart_putdata_xmd().
#define CRC16POLY 0x1021 |
Referenced by add_crc().
#define EOT 0x04 |
Referenced by usart_getdata_xmd(), and usart_putdata_xmd().
#define ESC 0x1b |
Referenced by usart_getdata_xmd().
#define NAK 0x15 |
Referenced by usart_putdata_xmd().
#define PKTLEN_128 128 |
Referenced by getbytes(), getPacket(), putPacket(), usart_getdata_xmd(), and usart_putdata_xmd().
#define SHARP_CHARACTER '#' |
Referenced by usart_sharp_received().
#define SOH 0x01 |
Referenced by putPacket(), and usart_getdata_xmd().
#define USART_BUFFER_SIZE 128 |
Referenced by usart_readc().
#define USART_DEFAULT_TIMEOUT 1000 |
unsigned short add_crc | ( | char | ptr, |
unsigned short | crc | ||
) |
Gets data from usart line using Xmodem protocol.
data | pointer |
number | of data to get |
Gets data from usart line using Xmodem protocol.
References CRC16POLY.
Referenced by getbytes(), and putPacket().
uint8_t getPacket | ( | uint8_t * | pData, |
uint8_t | sno | ||
) |
Used by Xdown to retrieve packets.
References ACK, CAN, error_timeout, getbytes(), PKTLEN_128, usart_getc(), and usart_putc().
Referenced by usart_getdata_xmd().
void usart_close | ( | void | ) |
Stops the USART.
Stops the USART.
References usart_disable(), usart_disable_transceiver(), usart_sam_ba, USART_TRANSCEIVER_RX, and USART_TRANSCEIVER_TX.
int usart_getc | ( | void | ) |
Waits and gets a value on usart line.
References usart_is_rx_ready(), usart_read_wait(), and usart_sam_ba.
Referenced by getbytes(), getPacket(), putPacket(), usart_getdata(), usart_getdata_xmd(), usart_putdata_xmd(), and usart_sharp_received().
uint32_t usart_getdata | ( | void * | data, |
uint32_t | length | ||
) |
Gets data from usart line.
data | pointer |
number | of data to get |
Gets data from usart line.
References usart_getc().
uint32_t usart_getdata_xmd | ( | void * | data, |
uint32_t | length | ||
) |
Gets data from usart line using Xmodem protocol.
data | pointer |
number | of data to get |
Gets data from usart line using Xmodem protocol.
References ACK, CAN, CONF_CLOCK_GCLK_0_CLOCK_SOURCE, EOT, error_timeout, ESC, getPacket(), length, mode_of_transfer, PKTLEN_128, ptr_data, size_of_data, SOH, system_clock_source_get_hz(), usart_getc(), usart_is_rx_ready(), and usart_putc().
bool usart_is_rx_ready | ( | void | ) |
This function checks if a character has been received on the usart line.
1
if a byte is ready to be read. References BOOT_USART_MODULE.
Referenced by usart_getc(), usart_getdata_xmd(), and usart_sharp_received().
void usart_open | ( | void | ) |
Open the given USART.
References b_sharp_received, usart_config::baudrate, BOOT_USART_BAUDRATE, BOOT_USART_GCLK_SOURCE, BOOT_USART_MODULE, BOOT_USART_MUX_SETTINGS, BOOT_USART_PAD0, BOOT_USART_PAD1, error_timeout, usart_config::generator_source, idx_rx_read, idx_rx_write, idx_tx_read, idx_tx_write, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, STATUS_OK, usart_enable(), usart_enable_transceiver(), usart_get_config_defaults(), usart_init(), usart_sam_ba, USART_TRANSCEIVER_RX, and USART_TRANSCEIVER_TX.
Referenced by main().
int usart_putc | ( | int | value | ) |
Puts a byte on usart line.
value | Value to put |
1
if function was successfully done, otherwise 0
.Puts a byte on usart line.
value | Value to put |
1
if function was successfully done, otherwise 0
. References usart_sam_ba, and usart_write_wait().
Referenced by getPacket(), putPacket(), usart_getdata_xmd(), usart_putdata(), and usart_putdata_xmd().
uint32_t usart_putdata | ( | void const * | data, |
uint32_t | length | ||
) |
Send buffer on usart line.
data | pointer |
number | of data to send |
Send buffer on usart line.
References i, length, and usart_putc().
uint32_t usart_putdata_xmd | ( | void const * | data, |
uint32_t | length | ||
) |
Send buffer on usart line using Xmodem protocol.
data | pointer |
number | of data to send |
Send buffer on usart line using Xmodem protocol.
References ACK, CAN, EOT, error_timeout, length, mode_of_transfer, NAK, PKTLEN_128, ptr_data, putPacket(), size_of_data, usart_getc(), and usart_putc().
int usart_readc | ( | void | ) |
Gets a value on usart line.
References buffer_rx_usart, idx_rx_read, and USART_BUFFER_SIZE.
int usart_sharp_received | ( | void | ) |
Returns true if the SAM-BA Uart received the sharp char.
References SHARP_CHARACTER, usart_getc(), and usart_is_rx_ready().
Referenced by main().