Microchip® Advanced Software Framework

sio2host.c File Reference

Event handling Serial I/O Functionalities.

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

#include "conf_sio2host.h"
#include "sio2host.h"
#include "board.h"
#include "stdio.h"

Macros

#define USB_CTRL_RD_HI()
 
#define USB_CTRL_RD_LO()
 
#define USB_CTRL_WR_HI()
 
#define USB_CTRL_WR_LO()
 
#define USB_DATA_SETINP()
 
#define USB_DATA_SETOUTP()
 

Typedefs

typedef enum pin_state_tag pin_state_t
 

Enumerations

enum  pin_state_tag {
  LOW,
  HIGH,
  LOW,
  HIGH
}
 

Functions

int _read (int *f)
 
int _write (char c, int *f)
 
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...
 
static void usb_getc (void)
 Gets a byte from USB FIFO. More...
 
void usb_handler (void)
 Services data transmission or reception on USB. More...
 
static void usb_putc (void)
 Puts a character onto USB FIFO. More...
 

Variables

uint8_t usb_rx_buf [USB_RX_BUF_SIZE]
 USB receive buffer. More...
 
static uint8_t usb_rx_buf_head
 Receive buffer head. More...
 
static uint8_t usb_rx_buf_tail
 Receive buffer tail. More...
 
static uint8_t usb_rx_count
 Number of bytes in receive buffer. More...
 
uint8_t usb_tx_buf [USB_TX_BUF_SIZE]
 USB transmit buffer. More...
 
static uint8_t usb_tx_buf_head
 Transmit buffer head. More...
 
static uint8_t usb_tx_buf_tail
 Transmit buffer tail. More...
 
static bool usb_tx_busy = false
 USB Tx busy flag: This is required in order to detect a Tx busy condition if the terminal program is not running, so that the FTDI chip cannot deliver its data. More...
 
static uint8_t usb_tx_count
 Number of bytes in transmit buffer. More...
 

#define USB_CTRL_RD_HI ( )
Value:
do { USB_CTRL_PORT |= USB_RD; } \
while (0)
#define USB_RD
Definition: atmegarfx_rcb.h:351
#define USB_CTRL_PORT
Definition: atmegarfx_rcb.h:336

Referenced by sio2host_init(), and usb_getc().

#define USB_CTRL_RD_LO ( )
Value:
do { USB_CTRL_PORT &= ~USB_RD; } \
while (0)
#define USB_RD
Definition: atmegarfx_rcb.h:351
#define USB_CTRL_PORT
Definition: atmegarfx_rcb.h:336

Referenced by sio2host_init(), and usb_getc().

#define USB_CTRL_WR_HI ( )
Value:
do { USB_CTRL_PORT |= USB_WR; } \
while (0)
#define USB_CTRL_PORT
Definition: atmegarfx_rcb.h:336
#define USB_WR
Definition: atmegarfx_rcb.h:354

Referenced by usb_putc().

#define USB_CTRL_WR_LO ( )
Value:
do { USB_CTRL_PORT &= ~USB_WR; } \
while (0)
#define USB_CTRL_PORT
Definition: atmegarfx_rcb.h:336
#define USB_WR
Definition: atmegarfx_rcb.h:354

Referenced by usb_putc().

#define USB_DATA_SETINP ( )
Value:
do { USB_DATA_DDR = 0x00; USB_DATA_PORT = 0x00; } \
while (0)
#define USB_DATA_DDR
Definition: atmegarfx_rcb.h:360
#define USB_DATA_PORT
Definition: atmegarfx_rcb.h:357

Referenced by sio2host_init(), usb_getc(), and usb_putc().

#define USB_DATA_SETOUTP ( )
Value:
do { USB_DATA_DDR = 0xFF; } \
while (0)
#define USB_DATA_DDR
Definition: atmegarfx_rcb.h:360

Referenced by sio2host_init(), and usb_putc().

typedef enum pin_state_tag pin_state_t

Enumerator
LOW 

Pin state low.

HIGH 

Pin state high.

LOW 

Pin state low.

HIGH 

Pin state high.

int _read ( int *  f)

Referenced by sio2host_init().

int _write ( char  c,
int *  f 
)

Referenced by sio2host_init().

static void usb_getc ( void  )
static

Gets a byte from USB FIFO.

This function receives a byte from usb.

References nop, USB_CTRL_RD_HI, USB_CTRL_RD_LO, USB_DATA_PIN, USB_DATA_SETINP, usb_rx_buf, USB_RX_BUF_SIZE, usb_rx_buf_tail, and usb_rx_count.

Referenced by usb_handler().

static void usb_putc ( void  )
static

Puts a character onto USB FIFO.

This function transmits a byte over usb.

References USB_CTRL_WR_HI, USB_CTRL_WR_LO, USB_DATA_PORT, USB_DATA_SETINP, USB_DATA_SETOUTP, usb_tx_buf, usb_tx_buf_head, USB_TX_BUF_SIZE, and usb_tx_count.

Referenced by usb_handler().

uint8_t usb_rx_buf[USB_RX_BUF_SIZE]

USB receive buffer.

Referenced by sio2host_rx(), and usb_getc().

uint8_t usb_rx_buf_head
static

Receive buffer head.

Referenced by sio2host_rx().

uint8_t usb_rx_buf_tail
static

Receive buffer tail.

Referenced by sio2host_rx(), and usb_getc().

uint8_t usb_rx_count
static

Number of bytes in receive buffer.

Referenced by sio2host_rx(), and usb_getc().

uint8_t usb_tx_buf[USB_TX_BUF_SIZE]

USB transmit buffer.

Referenced by sio2host_tx(), and usb_putc().

uint8_t usb_tx_buf_head
static

Transmit buffer head.

Referenced by sio2host_tx(), and usb_putc().

uint8_t usb_tx_buf_tail
static

Transmit buffer tail.

Referenced by sio2host_tx().

bool usb_tx_busy = false
static

USB Tx busy flag: This is required in order to detect a Tx busy condition if the terminal program is not running, so that the FTDI chip cannot deliver its data.

Referenced by sio2host_tx(), and usb_handler().

uint8_t usb_tx_count
static

Number of bytes in transmit buffer.

Referenced by sio2host_tx(), usb_handler(), and usb_putc().