Files added to CDC Device projects:
USB-DEVICE-CDC (Header)
USB-CDC (Header)
USB-DEVICE-CDC (C)
USB-DEVICE-CDC-ACM (C)
APIs provided:
- USB_DEVICE_CDC_EventHandlerSet
- USB_DEVICE_CDC_Write
- USB_DEVICE_CDC_Read
- USB_DEVICE_CDC_SerialStateNotificationSend
USB_DEVICE_CDC_EventHandler Set
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_CDC_EventHandlerSet registers an event handler for a specified CDC Driver Instance. |
USB Device CDC Instance, Event Handler, Context |
Status of the transfer request |
Example:
USB_DEVICE_CDC_RESULT result;
…
result = USB_DEVICE_CDC_EventHandlerSet( USB_DEVICE_CDC_INDEX_0,
&EventHandlerFunction,
0);
if( result != USB_DEVICE_CDC_RESULT_OK)
{
//Handle error.
}
USB_DEVICE_CDC_Write
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_CDC_Write initiates a CDC write by sending a buffer of data to the CDC Driver. The data is sent out by the driver in response to the requests by the host. |
USB Device CDC Instance, Transfer Handle, Pointer to Data, Length, Transfer Flag* |
Status of the transfer request |
Note: The Transfer Flag indicates whether or not the transfer should continue to the next USB frame or end. It is defined in the enum USB_DEVICE_TRANSFER_FLAG.
Example:
USB_DEVICE_CDC_RESULT result;
…
// Transfers 15 bytes of data from data-buffer.
result = USB_DEVICE_CDC_Write( USB_DEVICE_CDC_INDEX_0,
&transferhandle,
data-buffer,
15,
USB_DEVICE_CDC_TRANSFER_FLAGS_DATA_COMPLETE);
if( result != USB_DEVICE_CDC_RESULT_OK)
{
//Handle error.
}
USB_DEVICE_CDC_Read
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_CDC_Read requests data to be read from the CDC Function driver layer. The request will be fulfilled as data from the host becomes available. |
USB Device CDC Instance, Transfer Handle, Pointer Input Buffer, Length, |
Status of the transfer request |
Example:
USB_DEVICE_CDC_RESULT result;
…
// Receiving 127 bytes of data into input-buffer via the CDC interface
result = USB_DEVICE_CDC_Read( USB_DEVICE_CDC_INDEX_0,
&EventHandlerFunction,
input-buffer,
127 );
if( result != USB_DEVICE_CDC_RESULT_OK)
{
//Handle error.
}
USB_DEVICE_CDC_SerialStateNotificationSend
Description | Inputs | Returns |
---|---|---|
USB_DEVICE_CDC_SerialStateNotificationSend sends a request to the CDC driver to send a Serial State Notification to the host. |
USB Device CDC Instance, Transfer Handle, Notification Data |
Status of the request |
Example:
USB_DEVICE_CDC_RESULT result;
USB_CDC_SERIAL_STATE notification;
…
result = USB_DEVICE_CDC_SerialStateNotificationSend( USB_DEVICE_CDC_INDEX_0,
&transferfunction,
¬ification);
if( result != USB_DEVICE_CDC_RESULT_OK)
{
//Handle error.
}