Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB Host Interface (UHI) for Communication Class Device (CDC)

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:

API Overview

Interface with USB Host Core (UHC)

Definition and functions required by 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
Value:
{ \
.install = uhi_cdc_install, \
.enable = uhi_cdc_enable, \
.uninstall = uhi_cdc_uninstall, \
.sof_notify = uhi_cdc_sof, \
}
void uhi_cdc_sof(bool b_micro)
Signal that a SOF has occurred.
Definition: uhi_cdc.c:426
uhc_enum_status_t uhi_cdc_install(uhc_device_t *dev)
Install interface.
Definition: uhi_cdc.c:228
void uhi_cdc_enable(uhc_device_t *dev)
Enable the interface.
Definition: uhi_cdc.c:404
void uhi_cdc_uninstall(uhc_device_t *dev)
Uninstall the interface (if installed).
Definition: uhi_cdc.c:416

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.

Parameters
[in]portCommunication port number
portCommunication 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.

Parameters
[in]uhc_device_tDevice 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.

Parameters
[in]portCommunication port number
Returns
The number of data received.
Parameters
portCommunication port number
Returns
the number of data received

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.

Parameters
[in]portCommunication port number
Returns
Value read on CDC line.
Parameters
portCommunication port number
Returns
value read on CDC line

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().

bool uhi_cdc_is_rx_ready ( uint8_t  port)

This function checks if a character has been received on the CDC line.

Parameters
[in]portCommunication port number
Returns
true if a byte is ready to be read.
Parameters
portCommunication port number
Returns
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.

Parameters
[in]portCommunication port number
Returns
true if a new character can be sent.

This function checks if a new character sent is possible.

Parameters
portCommunication port number
Returns
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.

Parameters
[in]portCommunication port number
[in]configurationPointer on port configuration
Returns
true if the port is available.
Parameters
portCommunication port number
configurationPointer on port configuration
Returns
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.

Parameters
[in]portCommunication port number
[in]valueValue to put
Returns
true if function was successfully done, otherwise false.

Puts a byte on CDC line.

Parameters
portCommunication port number
valueValue to put
Returns
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.

Parameters
[in]portCommunication port number
[out]bufValues read
[in]sizeNumber of value read
Returns
The number of data remaining.
Parameters
portCommunication port number
bufValues read
sizeNumber of value read
Returns
the number of data remaining

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_uninstall ( uhc_device_t dev)

Uninstall the interface (if installed).

Parameters
[in]uhc_device_tDevice 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.

Parameters
[in]portCommunication port number
[in]bufValues to write
[in]sizeNumber of value to write
Returns
The number of data remaining.
Parameters
portCommunication port number
bufValues to write
sizeNumber of value to write
Returns
the number of data remaining

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().