Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Implementation of UHI Communication Device Class

Class internal implementation.

Data Structures

struct  uhi_cdc_buf_t
 Internal buffer information. More...
 
struct  uhi_cdc_dev_t
 USB CDC device information. More...
 
struct  uhi_cdc_line_t
 Communication line information. More...
 
struct  uhi_cdc_port_t
 Communication port information. More...
 

Internal defines and variables to manage CDC device

static uhi_cdc_dev_t uhi_cdc_dev
 Information about the enumerated USB CDC device. More...
 

Internal routines

static void uhi_cdc_free_device (void)
 Free all CDC device structures. More...
 
static uhi_cdc_port_tuhi_cdc_get_port (uint8_t port_num)
 Returns a port structure information. More...
 
static bool uhi_cdc_set_conf (uint8_t port, usb_cdc_line_coding_t *configuration)
 Changes the port configuration. More...
 
static bool uhi_cdc_set_ctrl_line (uint8_t port, le16_t wValue)
 Sends a control line command on the port. More...
 
static bool uhi_cdc_rx_update (uhi_cdc_line_t *line)
 Update the transfer endpoint IN (RX) Valid the reception of the previous transfer. More...
 
static void uhi_cdc_rx_received (usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transferred)
 Manage the end of RX transfer. More...
 
static bool uhi_cdc_tx_update (uhi_cdc_line_t *line)
 Update the transfer endpoint OUT (TX) Start a new transfer on endpoint OUT, if a data must be send and a new USB frame is occurred since last transfer. More...
 
static void uhi_cdc_tx_send (usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transferred)
 Manage the end of TX transfer. More...
 

static void uhi_cdc_free_device ( void  )
static
static uhi_cdc_port_t * uhi_cdc_get_port ( uint8_t  port_num)
static
static void uhi_cdc_rx_received ( usb_add_t  add,
usb_ep_t  ep,
uhd_trans_status_t  status,
iram_size_t  nb_transferred 
)
static

Manage the end of RX transfer.

Registered by uhd_ep_run() Callback called by USB interrupt after data transfer or abort (reset,...).

Parameters
addUSB address used by the transfer
statusTransfer status
nb_transferredNumber of data transfered

References uhi_cdc_line_t::b_trans_ongoing, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, uhi_cdc_dev_t::dev, uhi_cdc_line_t::ep_data, uhi_cdc_port_t::line_rx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::pos, uhi_cdc_line_t::sof, uhc_device_t::speed, uhd_get_frame_number(), uhd_get_microframe_number(), UHD_SPEED_HIGH, UHD_TRANS_NOERROR, UHD_TRANS_TIMEOUT, uhi_cdc_get_port(), uhi_cdc_rx_update(), and UNUSED.

Referenced by uhi_cdc_rx_update().

static bool uhi_cdc_rx_update ( uhi_cdc_line_t line)
static

Update the transfer endpoint IN (RX) Valid the reception of the previous transfer.

Start a new transfer on endpoint IN, if a RX buffer is free and a new USB frame is occurred since last transfer.

Parameters
lineRX communication line to manage
Returns
True, if a new transfer has been started

References uhc_device_t::address, uhi_cdc_line_t::b_trans_ongoing, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, cpu_irq_restore(), cpu_irq_save(), uhi_cdc_dev_t::dev, uhi_cdc_line_t::ep_data, uhi_cdc_buf_t::nb, uhi_cdc_buf_t::pos, uhi_cdc_buf_t::ptr, uhi_cdc_line_t::sof, uhc_device_t::speed, uhd_ep_run(), uhd_get_frame_number(), uhd_get_microframe_number(), UHD_SPEED_HIGH, UHI_CDC_RX_NOTIFY, and uhi_cdc_rx_received().

Referenced by uhi_cdc_getc(), uhi_cdc_read_buf(), uhi_cdc_rx_received(), and uhi_cdc_sof().

static bool uhi_cdc_set_conf ( uint8_t  port,
usb_cdc_line_coding_t configuration 
)
static
static bool uhi_cdc_set_ctrl_line ( uint8_t  port,
le16_t  wValue 
)
static
static void uhi_cdc_tx_send ( usb_add_t  add,
usb_ep_t  ep,
uhd_trans_status_t  status,
iram_size_t  nb_transferred 
)
static

Manage the end of TX transfer.

Registered by uhd_ep_run() Callback called by USB interrupt after data transfer or abort (reset,...).

Parameters
addUSB address used by the transfer
statusTransfer status
nb_transferredNumber of data transfered

References uhi_cdc_line_t::b_trans_ongoing, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, cpu_irq_restore(), cpu_irq_save(), uhi_cdc_dev_t::dev, uhi_cdc_line_t::ep_data, uhi_cdc_port_t::line_tx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_line_t::sof, uhc_device_t::speed, uhd_get_frame_number(), uhd_get_microframe_number(), UHD_SPEED_HIGH, UHD_TRANS_NOERROR, uhi_cdc_get_port(), uhi_cdc_tx_update(), and UNUSED.

Referenced by uhi_cdc_tx_update().

static bool uhi_cdc_tx_update ( uhi_cdc_line_t line)
static

Update the transfer endpoint OUT (TX) Start a new transfer on endpoint OUT, if a data must be send and a new USB frame is occurred since last transfer.

Parameters
lineTX communication line to manage
Returns
True, if a new transfer has been started

References uhc_device_t::address, uhi_cdc_line_t::b_trans_ongoing, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, cpu_irq_restore(), cpu_irq_save(), uhi_cdc_dev_t::dev, uhi_cdc_line_t::ep_data, uhi_cdc_buf_t::nb, uhi_cdc_buf_t::ptr, uhi_cdc_line_t::sof, uhc_device_t::speed, uhd_ep_run(), uhd_get_frame_number(), uhd_get_microframe_number(), UHD_SPEED_HIGH, and uhi_cdc_tx_send().

Referenced by uhi_cdc_sof(), and uhi_cdc_tx_send().

uhi_cdc_dev_t uhi_cdc_dev
static
Initial value:
= {
.dev = NULL,
.nb_port = 0,
}
#define NULL
Definition: src/include/lwip/def.h:47

Information about the enumerated USB CDC device.