USB Host Interface (UHI) for Communication Class Device (CDC) provides an interface for the configuration and management of USB CDC serial host.
The outline of this documentation is as follows:
For more details for Atmel® Software Framework (ASF) USB Host Stack, refer to following application note:
Interface with USB Host Core (UHC) | |
#define | UHI_CDC |
Global definition which contains standard UHI API for UHC. More... | |
Functions Required by UHC | |
uhc_enum_status_t | uhi_cdc_install (uhc_device_t *dev) |
Install interface. More... | |
void | uhi_cdc_enable (uhc_device_t *dev) |
Enable the interface. More... | |
void | uhi_cdc_uninstall (uhc_device_t *dev) |
Uninstall the interface (if installed). More... | |
void | uhi_cdc_sof (bool b_micro) |
Signal that a SOF has occurred. More... | |
UHI for Communication Device Class | |
Common APIs used by high level application to use this USB host class. These routines are used by memory to transfer its data to/from USB CDC endpoint. | |
bool | uhi_cdc_open (uint8_t port, usb_cdc_line_coding_t *configuration) |
Open a port of UHI CDC interface. More... | |
void | uhi_cdc_close (uint8_t port) |
Close a port. More... | |
bool | uhi_cdc_is_rx_ready (uint8_t port) |
This function checks if a character has been received on the CDC line. More... | |
iram_size_t | uhi_cdc_get_nb_received (uint8_t port) |
This function returns the number of character available on the CDC line. More... | |
int | uhi_cdc_getc (uint8_t port) |
Waits and gets a value on CDC line. More... | |
iram_size_t | uhi_cdc_read_buf (uint8_t port, void *buf, iram_size_t size) |
Reads a RAM buffer on CDC line. More... | |
bool | uhi_cdc_is_tx_ready (uint8_t port) |
This function checks if a new character sent is possible. More... | |
int | uhi_cdc_putc (uint8_t port, int value) |
Puts a byte on CDC line. More... | |
iram_size_t | uhi_cdc_write_buf (uint8_t port, const void *buf, iram_size_t size) |
Writes a RAM buffer on CDC line. More... | |
#define UHI_CDC |
Global definition which contains standard UHI API for UHC.
It must be added in USB_HOST_UHI define from conf_usb_host.h file.
void uhi_cdc_close | ( | uint8_t | port | ) |
Close a port.
[in] | port | Communication port number |
port | Communication port number |
References uhi_cdc_set_ctrl_line().
void uhi_cdc_enable | ( | uhc_device_t * | dev | ) |
Enable the interface.
Enable a USB interface corresponding to UHI.
[in] | uhc_device_t | Device to request |
References uhi_cdc_dev_t::b_enabled, uhi_cdc_dev_t::dev, UHI_CDC_CHANGE, and uhi_cdc_sof().
iram_size_t uhi_cdc_get_nb_received | ( | uint8_t | port | ) |
This function returns the number of character available on the CDC line.
[in] | port | Communication port number |
port | Communication port number |
References buf, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_port_t::line_rx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::pos, and uhi_cdc_get_port().
Referenced by uhi_cdc_is_rx_ready().
int uhi_cdc_getc | ( | uint8_t | port | ) |
Waits and gets a value on CDC line.
[in] | port | Communication port number |
port | Communication port number |
References usb_cdc_line_coding_t::bDataBits, buf, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_port_t::conf, uhi_cdc_port_t::line_rx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::pos, uhi_cdc_buf_t::ptr, rx_data, uhi_cdc_get_port(), and uhi_cdc_rx_update().
Referenced by uart_rx_notify(), and usart_tx_callback().
uhc_enum_status_t uhi_cdc_install | ( | uhc_device_t * | dev | ) |
Install interface.
Allocate interface endpoints if supported.
[in] | uhc_device_t | Device to request |
References uhc_device_t::address, Assert, uhi_cdc_dev_t::b_enabled, uhi_cdc_line_t::b_trans_ongoing, usb_iface_desc_t::bDescriptorType, usb_iface_desc_t::bInterfaceClass, usb_iface_desc_t::bInterfaceNumber, usb_iface_desc_t::bInterfaceProtocol, usb_iface_desc_t::bInterfaceSubClass, usb_iface_desc_t::bLength, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, CDC_CLASS_COMM, CDC_CLASS_DATA, CDC_CS_INTERFACE, CDC_PROTOCOL_V25TER, CDC_SCS_CALL_MGMT, CDC_SUBCLASS_ACM, uhc_device_t::conf_desc, uhi_cdc_dev_t::dev, dev, uhi_cdc_port_t::ep_comm_in, uhi_cdc_line_t::ep_data, i, uhi_cdc_port_t::iface_comm, uhi_cdc_port_t::iface_data, le16_to_cpu, uhi_cdc_port_t::line_rx, uhi_cdc_port_t::line_tx, Max, uhi_cdc_buf_t::nb, uhi_cdc_dev_t::nb_port, NULL, uhi_cdc_dev_t::port, uhi_cdc_buf_t::pos, uhi_cdc_buf_t::ptr, uhc_device_t::speed, UHC_ENUM_HARDWARE_LIMIT, UHC_ENUM_SOFTWARE_LIMIT, UHC_ENUM_SUCCESS, UHC_ENUM_UNSUPPORTED, uhd_ep_alloc(), UHI_CDC_BUFFER_SIZE, uhi_cdc_free_device(), USB_DT_ENDPOINT, USB_DT_INTERFACE, USB_EP_DIR_IN, USB_EP_TYPE_BULK, USB_EP_TYPE_INTERRUPT, while(), and usb_conf_desc_t::wTotalLength.
bool uhi_cdc_is_rx_ready | ( | uint8_t | port | ) |
This function checks if a character has been received on the CDC line.
[in] | port | Communication port number |
true
if a byte is ready to be read.port | Communication port number |
true
if a byte is ready to be read. References uhi_cdc_get_nb_received().
Referenced by usart_tx_callback().
bool uhi_cdc_is_tx_ready | ( | uint8_t | port | ) |
This function checks if a new character sent is possible.
The type int is used to support scanf redirection from compiler LIB.
[in] | port | Communication port number |
true
if a new character can be sent.This function checks if a new character sent is possible.
port | Communication port number |
true
if a new character can be sent References uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, uhi_cdc_port_t::line_tx, uhi_cdc_buf_t::nb, NULL, and uhi_cdc_get_port().
Referenced by usart_rx_callback().
bool uhi_cdc_open | ( | uint8_t | port, |
usb_cdc_line_coding_t * | configuration | ||
) |
Open a port of UHI CDC interface.
[in] | port | Communication port number |
[in] | configuration | Pointer on port configuration |
true
if the port is available.port | Communication port number |
configuration | Pointer on port configuration |
true
if the port is available References CDC_CTRL_SIGNAL_DTE_PRESENT, uhi_cdc_set_conf(), and uhi_cdc_set_ctrl_line().
int uhi_cdc_putc | ( | uint8_t | port, |
int | value | ||
) |
Puts a byte on CDC line.
The type int is used to support printf redirection from compiler LIB.
[in] | port | Communication port number |
[in] | value | Value to put |
true
if function was successfully done, otherwise false
.Puts a byte on CDC line.
port | Communication port number |
value | Value to put |
true
if function was successfully done, otherwise false
. References usb_cdc_line_coding_t::bDataBits, buf, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, uhi_cdc_port_t::conf, cpu_irq_restore(), cpu_irq_save(), uhi_cdc_port_t::line_tx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::ptr, and uhi_cdc_get_port().
Referenced by usart_rx_callback().
iram_size_t uhi_cdc_read_buf | ( | uint8_t | port, |
void * | buf, | ||
iram_size_t | size | ||
) |
Reads a RAM buffer on CDC line.
[in] | port | Communication port number |
[out] | buf | Values read |
[in] | size | Number of value read |
port | Communication port number |
buf | Values read |
size | Number of value read |
References uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_port_t::line_rx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::pos, uhi_cdc_buf_t::ptr, uhi_cdc_get_port(), and uhi_cdc_rx_update().
void uhi_cdc_sof | ( | bool | b_micro | ) |
Signal that a SOF has occurred.
References uhi_cdc_dev_t::b_enabled, uhi_cdc_dev_t::dev, uhi_cdc_port_t::line_rx, uhi_cdc_port_t::line_tx, NULL, port, uhi_cdc_get_port(), uhi_cdc_rx_update(), uhi_cdc_tx_update(), and UNUSED.
Referenced by uhi_cdc_enable().
void uhi_cdc_uninstall | ( | uhc_device_t * | dev | ) |
Uninstall the interface (if installed).
[in] | uhc_device_t | Device to request |
References uhi_cdc_dev_t::dev, NULL, UHI_CDC_CHANGE, and uhi_cdc_free_device().
iram_size_t uhi_cdc_write_buf | ( | uint8_t | port, |
const void * | buf, | ||
iram_size_t | size | ||
) |
Writes a RAM buffer on CDC line.
[in] | port | Communication port number |
[in] | buf | Values to write |
[in] | size | Number of value to write |
port | Communication port number |
buf | Values to write |
size | Number of value to write |
References usb_cdc_line_coding_t::bDataBits, uhi_cdc_line_t::buf_sel, uhi_cdc_line_t::buffer, uhi_cdc_line_t::buffer_size, uhi_cdc_port_t::conf, cpu_irq_restore(), cpu_irq_save(), uhi_cdc_port_t::line_tx, uhi_cdc_buf_t::nb, NULL, uhi_cdc_buf_t::ptr, and uhi_cdc_get_port().