Microchip® Advanced Software Framework

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

Class internal implementation.

Routines to control serial line

static uint8_t udi_cdc_setup_to_port (void)
 Returns the port number corresponding at current setup request. More...
 
static void udi_cdc_line_coding_received (void)
 Sends line coding to application. More...
 
static void udi_cdc_ctrl_state_change (uint8_t port, bool b_set, le16_t bit_mask)
 Records new state. More...
 
static void udi_cdc_ctrl_state_notify (uint8_t port, udd_ep_id_t ep)
 Check and eventually notify the USB host of new state. More...
 
static void udi_cdc_serial_state_msg_sent (udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
 Ack sent of serial state message Callback called after serial state message sent. More...
 

Routines to process data transfer

static bool udi_cdc_rx_start (uint8_t port)
 Enable the reception of data from the USB host. More...
 
static void udi_cdc_data_received (udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
 Update rx buffer management with a new data Callback called after data reception on USB line. More...
 
static void udi_cdc_data_sent (udd_ep_status_t status, iram_size_t n, udd_ep_id_t ep)
 Ack sent of tx buffer Callback called after data transfer on USB line. More...
 
static void udi_cdc_tx_send (uint8_t port)
 Send buffer on line or wait a SOF event. More...
 

static void udi_cdc_ctrl_state_change ( uint8_t  port,
bool  b_set,
le16_t  bit_mask 
)
static
static void udi_cdc_ctrl_state_notify ( uint8_t  port,
udd_ep_id_t  ep 
)
static

Check and eventually notify the USB host of new state.

Parameters
portCommunication port number to manage
epPort communication endpoint

References udd_ep_run(), udi_cdc_serial_state_msg_ongoing, udi_cdc_serial_state_msg_sent(), udi_cdc_state, uid_cdc_state_msg, value, and usb_cdc_notify_serial_state_t::value.

Referenced by udi_cdc_ctrl_state_change(), and udi_cdc_serial_state_msg_sent().

static void udi_cdc_data_received ( udd_ep_status_t  status,
iram_size_t  n,
udd_ep_id_t  ep 
)
static

Update rx buffer management with a new data Callback called after data reception on USB line.

Parameters
statusUDD_EP_TRANSFER_OK, if transfer finish
statusUDD_EP_TRANSFER_ABORT, if transfer aborted
nnumber of data received

References MREPEAT, udd_ep_run(), UDD_EP_TRANSFER_OK, UDI_CDC_DATA_EP_OUT_TO_PORT, UDI_CDC_PORT_NB, udi_cdc_rx_buf, udi_cdc_rx_buf_nb, udi_cdc_rx_buf_sel, UDI_CDC_RX_BUFFERS, udi_cdc_rx_start(), and udi_cdc_rx_trans_ongoing.

Referenced by udi_cdc_rx_start().

static void udi_cdc_data_sent ( udd_ep_status_t  status,
iram_size_t  n,
udd_ep_id_t  ep 
)
static

Ack sent of tx buffer Callback called after data transfer on USB line.

Parameters
statusUDD_EP_TRANSFER_OK, if transfer finished
statusUDD_EP_TRANSFER_ABORT, if transfer aborted
nnumber of data transfered

References MREPEAT, UDD_EP_TRANSFER_OK, UDI_CDC_DATA_EP_IN_TO_PORT, UDI_CDC_PORT_NB, udi_cdc_tx_both_buf_to_send, udi_cdc_tx_buf_nb, udi_cdc_tx_buf_sel, UDI_CDC_TX_EMPTY_NOTIFY, udi_cdc_tx_send(), udi_cdc_tx_trans_ongoing, and UNUSED.

Referenced by udi_cdc_tx_send().

static void udi_cdc_line_coding_received ( void  )
static

Sends line coding to application.

Called after SETUP request when line coding data is received.

References UDI_CDC_SET_CODING_EXT, udi_cdc_setup_to_port(), and UNUSED.

Referenced by udi_cdc_comm_setup().

static bool udi_cdc_rx_start ( uint8_t  port)
static

Enable the reception of data from the USB host.

The value udi_cdc_rx_trans_sel indicate the RX buffer to fill.

Parameters
portCommunication port number to manage
Returns
1 if function was successfully done, otherwise 0.

References cpu_irq_restore(), cpu_irq_save(), MREPEAT, udd_ep_run(), UDI_CDC_DATA_EP_OUT_0, udi_cdc_data_received(), udi_cdc_multi_is_rx_ready(), UDI_CDC_PORT_NB, UDI_CDC_PORT_TO_DATA_EP_OUT, udi_cdc_rx_buf, udi_cdc_rx_buf_nb, udi_cdc_rx_buf_sel, UDI_CDC_RX_BUFFERS, UDI_CDC_RX_NOTIFY, udi_cdc_rx_pos, and udi_cdc_rx_trans_ongoing.

Referenced by udi_cdc_data_enable(), udi_cdc_data_received(), udi_cdc_multi_getc(), udi_cdc_multi_read_buf(), and udi_cdc_multi_read_no_polling().

static void udi_cdc_serial_state_msg_sent ( udd_ep_status_t  status,
iram_size_t  n,
udd_ep_id_t  ep 
)
static

Ack sent of serial state message Callback called after serial state message sent.

Parameters
statusUDD_EP_TRANSFER_OK, if transfer finished
statusUDD_EP_TRANSFER_ABORT, if transfer aborted
nnumber of data transfered

References CDC_SERIAL_STATE_BREAK, CDC_SERIAL_STATE_FRAMING, CDC_SERIAL_STATE_OVERRUN, CDC_SERIAL_STATE_PARITY, CDC_SERIAL_STATE_RING, MREPEAT, udi_cdc_ctrl_state_notify(), UDI_CDC_GET_PORT_FROM_COMM_EP, UDI_CDC_PORT_NB, udi_cdc_serial_state_msg_ongoing, udi_cdc_state, uid_cdc_state_msg, UNUSED, and usb_cdc_notify_serial_state_t::value.

Referenced by udi_cdc_ctrl_state_notify().

static uint8_t udi_cdc_setup_to_port ( void  )
static

Returns the port number corresponding at current setup request.

Returns
port number

References MREPEAT, udd_ctrl_request_t::req, udd_g_ctrlreq, UDI_CDC_IFACE_COMM_TO_PORT, UDI_CDC_PORT_NB, and usb_setup_req_t::wIndex.

Referenced by udi_cdc_comm_setup(), and udi_cdc_line_coding_received().