Microchip® Advanced Software Framework

buffered_uart_ultra.h File Reference

SAM D21 UART API Declaration Implementations.

Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries.

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

Macros

#define HOST_SERCOM_MUX_SETTING   USART_RX_1_TX_0_XCK_1
 
#define HOST_SERCOM_PINMUX_PAD0   PINMUX_PA22C_SERCOM3_PAD0
 
#define HOST_SERCOM_PINMUX_PAD1   PINMUX_PA23C_SERCOM3_PAD1
 
#define HOST_SERCOM_PINMUX_PAD2   PINMUX_UNUSED
 
#define HOST_SERCOM_PINMUX_PAD3   SERCOM3_DMAC_ID_RX
 
#define SERIAL_RX_BUF_SIZE_HOST   256
 
#define USART_HOST   SERCOM3
 UART Interface. More...
 
#define USART_HOST_BAUDRATE   115200
 Baudrate setting. More...
 
#define USART_HOST_RX_ISR_ENABLE()
 

Functions

uint8_t buffered_uart_getchar (void)
 This function performs a blocking character receive functionality. More...
 
int buffered_uart_getchar_nowait (void)
 This function performs a non-blocking character receive functionality. More...
 
void buffered_uart_init (uint32_t baudrate)
 Initializes the Buffered Serial IO Module. More...
 
int buffered_uart_is_empty (void)
 check if the uart buffer is empty or not. More...
 
void buffered_uart_putchar (uint8_t)
 This function prints the character to the host. More...
 
uint8_t buffered_uart_rx (uint8_t *data, uint8_t max_length)
 Receives data from UART. More...
 
void buffered_uart_term (void)
 Terminate the Buffered Serial IO Module. More...
 
uint8_t buffered_uart_tx (uint8_t *data, uint32_t length)
 Transmits data via UART. More...
 
void USART_HOST_ISR_VECT (void)
 

#define HOST_SERCOM_MUX_SETTING   USART_RX_1_TX_0_XCK_1
#define HOST_SERCOM_PINMUX_PAD0   PINMUX_PA22C_SERCOM3_PAD0
#define HOST_SERCOM_PINMUX_PAD1   PINMUX_PA23C_SERCOM3_PAD1
#define HOST_SERCOM_PINMUX_PAD2   PINMUX_UNUSED
#define HOST_SERCOM_PINMUX_PAD3   SERCOM3_DMAC_ID_RX
#define SERIAL_RX_BUF_SIZE_HOST   256
#define USART_HOST   SERCOM3
#define USART_HOST_BAUDRATE   115200

Baudrate setting.

Referenced by sio2host_init().

#define USART_HOST_RX_ISR_ENABLE ( )
Value:
do { \
USART_HOST->USART.INTENSET.reg = SERCOM_USART_INTENSET_RXC;\
NVIC_EnableIRQ(SERCOM3_IRQn);\
} while (0)
void USART_HOST_ISR_VECT(void)
Definition: buffered_uart_ultra.c:153
#define USART_HOST
UART Interface.
Definition: buffered_uart_ultra.h:43
void _sercom_set_handler(const uint8_t instance, const sercom_handler_t interrupt_handler)
Definition: sercom_interrupt.c:65

Referenced by buffered_uart_init(), and sio2host_init().

uint8_t buffered_uart_getchar ( void  )

This function performs a blocking character receive functionality.

Returns
returns the data which is received

References buffered_uart_getchar_nowait(), and c.

int buffered_uart_getchar_nowait ( void  )

This function performs a non-blocking character receive functionality.

Returns
'-1' if no data is received or returns the data if a character is received

References c, cpu_irq_disable, cpu_irq_enable, serial_rx_buf, serial_rx_buf_head, SERIAL_RX_BUF_SIZE_HOST, and serial_rx_buf_tail.

Referenced by buffered_uart_getchar().

int buffered_uart_is_empty ( void  )

check if the uart buffer is empty or not.

Returns
non zero if empy. not initialized
uint8_t buffered_uart_rx ( uint8_t *  data,
uint8_t  max_length 
)

Receives data from UART.

Parameters
datapointer to the buffer where the received data is to be stored
max_lengthmaximum length of data to be received
Returns
actual number of bytes received

References cpu_irq_disable, cpu_irq_enable, serial_rx_buf, serial_rx_buf_head, SERIAL_RX_BUF_SIZE_HOST, and serial_rx_buf_tail.

Referenced by enter_wifi_firmware_download(), and serial_bridge_frame_receive().

void buffered_uart_term ( void  )

Terminate the Buffered Serial IO Module.

Returns
STATUS_OK for successful initialization and FAILURE in case the IO is not initialized

References host_uart_module, and usart_disable().

Referenced by serial_bridge_process_reconfigure().

uint8_t buffered_uart_tx ( uint8_t *  data,
uint32_t  length 
)

Transmits data via UART.

Parameters
dataPointer to the buffer where the data to be transmitted is present
lengthNumber of bytes to be transmitted
Returns
Number of bytes actually transmitted

References buffered_uart_putchar(), length, status, and STATUS_OK.

Referenced by serial_bridge_process_read_block().

void USART_HOST_ISR_VECT ( void  )