Symbols
loading (1/3)...
Files
loading (1/3)...

cdc_acm_host sample sample

cdc_acm_host sample is a sample project defining the following symbols:

Most used functions

Name
Location
Summary
Open CDC-ACM device The driver first looks for CDC compliant descriptor, if it is not found the driver checks if the interface has 2 Bulk endpoints that can be used for data Use CDC_HOST_ANY_* macros to signal that you don't care about the device's VID and PID. In this case, first USB device will be opened. It is recommended to use this feature if only one device can ever be in the system (there is no USB HUB connected).
Install CDC-ACM driver - USB Host Library must already be installed before calling this function (via usb_host_install()) - This function should be called before calling any other CDC driver functions
GetLineCoding function @see Chapter 6.3.11, USB CDC-PSTN specification rev. 1.2
Send command to CTRL endpoint Sends Control transfer as described in USB specification chapter 9. This function can be used by device drivers that use custom/vendor specific commands. These commands can either extend or replace commands defined in USB CDC-PSTN specification rev. 1.2.
Send CDC specific request Helper function that will send CDC specific request to default endpoint. Both IN and OUT requests are sent through this API, depending on the in_transfer parameter. @see Chapter 6.2, USB CDC specification rev. 1.2
SetControlLineState function @see Chapter 6.3.12, USB CDC-PSTN specification rev. 1.2
SetLineCoding function @see Chapter 6.3.10, USB CDC-PSTN specification rev. 1.2
Close CDC device and release its resources
Print device's descriptors Device and full Configuration descriptors are printed in human readable format to stdout.
SendBreak function This function will block until the duration_ms has passed. @see Chapter 6.3.13, USB CDC-PSTN specification rev. 1.2
Free USB transfers used by this device
Reset IN transfer In in_xfer_cb() we can modify IN transfer parameters, this function resets the transfer to its defaults
Register new USB device callback The callback will be called for every new USB device, not just CDC-ACM class.
Uninstall CDC-ACM driver - Users must ensure that all CDC devices must be closed via cdc_acm_host_close() before calling this function
Get protocols defined in USB-CDC interface descriptors
Parse CDC interface descriptor #. Check if the required interface exists #. Parse the interface descriptor #. Check if the device is CDC compliant #. For CDC compliant devices also parse second interface descriptor and functional descriptors
Print CDC specific descriptor in human readable form This is a callback function that is called from USB Host library, when it wants to print full configuration descriptor to stdout.
Helper function that releases resources claimed by CDC device Close underlying USB device, free device driver memory
Cancel transfer and reset endpoint This function will cancel ongoing transfer a reset its endpoint to ready state.
Device event callback Apart from handling device disconnection it doesn't do anything useful
USB Host library handling task
Start CDC device After this call, USB host peripheral will continuously poll IN endpoints.
Open USB device with requested VID/PID This function has two regular return paths: 1. USB device with matching VID/PID is already opened by this driver: allocate new CDC device on top of the already opened USB device. 2. USB device with matching VID/PID is NOT opened by this driver yet: poll USB connected devices until it is found.
CDC-ACM driver handling task USB host client registration and deregistration is handled here.
Data received callback Data (bulk) IN transfer is submitted at the end of this function to ensure continuous poll of IN endpoint.
Notification received callback Notification (interrupt) IN transfer is submitted at the end of this function to ensure periodic poll of IN endpoint.
USB Host Client event callback Handling of USB device connection/disconnection to/from root HUB.
Data send callback Reused for bulk OUT and CTRL transfers
Check finished transfer status Return to on transfer completed OK. Cancel the transfer and issue user's callback in case of an error.
Searches interface by index and verifies its CDC-compliance
Parse CDC functional descriptors @attention The driver must take care of memory freeing

Other commonly used symbols

Name
Location
Summary
Configuration structure of CDC-ACM device
Line Coding structure @see Table 17, USB CDC-PSTN specification rev. 1.2
CDC-ACM Device Event data structure
USB CDC Header Functional Descriptor @see Table 15, USB CDC specification rev. 1.2
Configuration structure of USB Host CDC-ACM driver
UART State Bitmap @see Table 31, USB CDC-PSTN specification rev. 1.2
Device's data RX callback function. Can be NULL for write-only devices
New USB device callback Provides already opened usb_dev, that will be closed after this callback returns. This is useful for peeking device's descriptors, e.g. peeking VID/PID and loading proper driver. @attention This callback is called from USB Host context, so the CDC device can't be opened here.
USB CDC Union Functional Descriptor @see Table 16, USB CDC specification rev. 1.2
USB CDC PSTN Call Descriptor @see Table 3, USB CDC-PSTN specification rev. 1.2
USB CDC PSTN Abstract Control Model Descriptor @see Table 4, USB CDC-PSTN specification rev. 1.2
Device's event callback function. Can be NULL
Data receive callback type
Timeout for USB device connection in [ms]
User's argument that will be passed to the callbacks
List of open pseudo devices
Maximum size of USB bulk in transfer
Maximum size of USB bulk out transfer, set to 0 for read-only devices
Stack size of the driver's task
Priority of the driver's task
Core affinity of the driver's task
New USB device connected callback. Can be NULL.
Default CDC-ACM driver configuration This configuration is used when user passes NULL to config pointer during device open.
USB Host handle reused for all CDC-ACM devices in the system

Dependencies

cdc_acm_host sample depends on the following libraries: