Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SIO2HOST - USB

This module performs serial input/output functionalities via USB.

Macros

#define MAX_BYTES_FOR_USB_TX   (255)
 
#define USB_RX_BUF_SIZE   (100)
 
#define USB_TX_BUF_SIZE   (100)
 

Functions

uint8_t sio2host_getchar (void)
 This function performs a blocking character receive functionality. More...
 
int sio2host_getchar_nowait (void)
 This function performs a non-blocking character receive functionality. More...
 
void sio2host_init (void)
 Initializes the Serial IO Module of the Host Device. More...
 
uint8_t sio2host_rx (uint8_t *data, uint8_t max_length)
 Receives data from USB. More...
 
uint8_t sio2host_tx (uint8_t *data, uint8_t length)
 Transmits data via USB. More...
 
void usb_handler (void)
 Services data transmission or reception on USB. More...
 

#define MAX_BYTES_FOR_USB_TX   (255)

Referenced by usb_handler().

#define USB_RX_BUF_SIZE   (100)

Referenced by sio2host_rx(), and usb_getc().

#define USB_TX_BUF_SIZE   (100)

Referenced by sio2host_tx(), and usb_putc().

uint8_t sio2host_getchar ( void  )

This function performs a blocking character receive functionality.

Returns
returns the data which is received

References sio2host_rx().

int sio2host_getchar_nowait ( void  )

This function performs a non-blocking character receive functionality.

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

References sio2host_rx().

Referenced by range_test_tx_off_task(), and range_test_tx_on_task().

void sio2host_init ( void  )

Initializes the Serial IO Module of the Host Device.

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

References _read(), _write(), nop, USB_ALE_DDR, USB_ALE_PIN, USB_ALE_PORT, USB_CTRL_DDR, USB_CTRL_PIN, USB_CTRL_PORT, USB_CTRL_RD_HI, USB_CTRL_RD_LO, USB_DATA_PORT, USB_DATA_SETINP, USB_DATA_SETOUTP, USB_FIFO_AD, USB_INIT_NON_GENERIC, USB_RD, USB_RXF, USB_TXE, and USB_WR.

Referenced by performance_analyzer_init().

uint8_t sio2host_rx ( uint8_t *  data,
uint8_t  max_length 
)

Receives data from USB.

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 usb_handler(), usb_rx_buf, usb_rx_buf_head, USB_RX_BUF_SIZE, usb_rx_buf_tail, and usb_rx_count.

Referenced by serial_data_handler(), sio2host_getchar(), and sio2host_getchar_nowait().

uint8_t sio2host_tx ( uint8_t *  data,
uint8_t  length 
)

Transmits data via USB.

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 data, usb_handler(), usb_tx_buf, usb_tx_buf_head, USB_TX_BUF_SIZE, usb_tx_buf_tail, usb_tx_busy, and usb_tx_count.

Referenced by serial_data_handler().

void usb_handler ( void  )

Services data transmission or reception on USB.

This function polls for usb for completion of reception or transmission of a byte on USB.

References LOW, MAX_BYTES_FOR_USB_TX, USB_CTRL_PIN, usb_getc(), usb_putc(), USB_RXF, usb_tx_busy, usb_tx_count, and USB_TXE.

Referenced by sio2host_rx(), and sio2host_tx().