CDC Class APIs for Harmony v2

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_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,
&notification);


if( result != USB_DEVICE_CDC_RESULT_OK)
{
//Handle error.

}


© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.