Files added to Host CDC projects:
usb-host-cdc.h
usb-host-hub-cdc.h
usb-host-cdc.c
usb-host-cdc-acm.c
APIs provided:
USB_HOST_CDC_Open
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_CDC_Open opens the specified CDC device. Once opened, the application will access the device by the returned 'handle'. |
Host CDC Object ID | CDC Handle |
Example of opening a CDC Device
USB_HOST_CDC_HANDLE cdcHostHandle;
USB_HOST_CDC_OBJ cdcObj;
. . .
cdcHostHandle = USB_HOST_CDC_Open(cdcObj);
if(cdcHostHandle != USB_HOST_CDC_HANDLE_INVALID)
{
/* The driver was opened successfully. Set the event handler
* and then go to the next state. */
}
. . .
USB_HOST_CDC_Close
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_CDC_Close closes the association between the application entity that opened the device and device. The driver handle becomes invalid. |
CDC Handle | void |
Example of closing a CDC Device
USB_HOST_CDC_HANDLE cdcHostHandle;
. . .
USB_HOST_CDC_Open(cdHostHandle);
. . .
USB_HOST_CDC_AttachEventHandlerSet
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_AttachEventHandlerSet sets the function to be called when the enumeration process attaches the device. |
event handler context |
USB_HOST_CDC_RESULT |
Example of setting the Attach Event handler
USB_HOST_CDC_OBJ cdcObj;
. . .
void MyAttachFunction( USB_HOST_CDC_OBJ cdcObj, uintptr_t context);
{ … }
. . .
USB_HOST_CDC_AttachEventHandlerSet(MyAttachFunction, (uintptr_t) 0);
USB_HOST_CDC_EventHandlerSet
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_EventHandlerSet registers the CDC Host Client Driver event handler for the specific device. This event handler is called by the driver in response to data transfers by the client device. |
handle event handler context |
USB_HOST_CDC_RESULT |
Example of setting the Event handler
USB_HOST_CDC_HANDLE cdcHostHandle;
USB_HOST_CDC_OBJ cdcObj;
. . .
cdcHostHandle = USB_HOST_CDC_Open(cdcObj);
if(cdcHostHandle != USB_HOST_CDC_HANDLE_INVALID)
{
/* The driver was opened successfully. Set the event handler */
USB_HOST_CDC_EventHandlerSet(cdcHostHandle, MyEventHandler, (uintptr_t)0);
}
. . .
USB_HOST_CDC_Write
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_CDC_Write writes data to the specified device. |
handle &transfer handle &data length |
USB_HOST_CDC_RESULT |
Example of writing to a CDC Device
USB_HOST_CDC_HANDLE cdcHostHandle;
USB_HOST_CDC_RESULT result;
char prompt[] = "Good Morning" ;
. . .
result = USB_HOST_CDC_Write(cdcHostHandle, NULL, prompt, 13);
if(result == USB_HOST_CDC_RESULT_SUCCESS)
{
// transmit successfully initiated
}
. . .
USB_HOST_CDC_Read
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_CDC_Read reads data from the specified device. |
handle &transfer handle &data length |
USB_HOST_CDC_RESULT |
Example of reading from a CDC Device
USB_HOST_CDC_HANDLE cdcHostHandle;
USB_HOST_CDC_RESULT result;
char MyInputBuffer[0x20] ;
. . .
result = USB_HOST_CDC_Read(cdcHostHandle, NULL, MyInputBuffer, 0x20);
if(result == USB_HOST_CDC_EVENT_READ_COMPLETE)
{
// data was successfully received
}
. . .
USB_HOST_CDC_SerialStateNotificationGet
| Description | Inputs | Returns |
|---|---|---|
| USB_HOST_SerialNotifiationGet requests Serial State Notification from the attached device. If the request was accepted, transferHandle will contain a valid transfer handle, else it will contain USB_HOST_CDC_TRANSFER_HANDLE_INVALID. |
handle &transfer handle &serial state |
USB_HOST_CDC_RESULT |
Example of setting the getting the Serial State
USB_CDC_SERIAL_STATE state;
USB_HOST_CDC_HANDLE cdcHostHandle;
. . .
USB_HOST_CDC_SerialStateNotificationGet(cdcHostHandle, &transferhandle, state);

