USB Component  Version 6.6
MDK-Professional Middleware for USB Device and Host
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
CDC: Communication Device Class (ACM)

Implement application specific behavior of a Communication Device Class (CDC) USB Device using the sub-class Abstract Control Model (ACM). More...

Content

 User API
 User API reference of the Communication Device Class (ACM).
 
 Configuration
 Configuration of the USB Device CDC (ACM) Class in µVision.
 

Description

Implement application specific behavior of a Communication Device Class (CDC) USB Device using the sub-class Abstract Control Model (ACM).

The CDC (ACM) class in the USB Component is used for data communication. You can typically use it in applications that previously used a serial COM or UART communication.

Refer to:

The USB Component allows multiple instances of the CDC class. This feature is used to create USB Composite Devices. Each CDC class instance has a separate files and interface functions:

This documentation uses n as a placeholder for the instance number 0 - 3. Most applications only require one instance of a CDC ACM class. For the first CDC ACM class instance the instance number is 0:

Descriptor Requirements

The following descriptors are required in an USB CDC ACM Device:

The necessary descriptors are automatically generated by the USB Middleware Component. The page USB Descriptors provides more information on the topic.

Software Structure

The handling for the CDC class endpoint events is implemented in USBD_CDCn_Int_Thread and USBD_CDCn_Bulk_Thread which are started by USBD_Initialize. Each instance of a CDC class runs an instance of USBD_CDCn_Int_Thread and USBD_CDCn_Bulk_Thread.

The thread USBD_CDCn_Int_Thread handles Interrupt IN Endpoint whereas the USBD_CDCn_Bulk_Thread handles the Bulk IN and Bulk OUT Endpoints.

msc_inline_mscgraph_3

Implementation

To create an USB Device with a CDC ACM class:

User Code Template USBD_User_CDC_ACM_n.c

The following source code contains all the required callback functions and can be used to implement the application specific behavior of a USB CDC (ACM) Device.

/*------------------------------------------------------------------------------
* MDK Middleware - Component ::USB:Device
* Copyright (c) 2004-2015 ARM Germany GmbH. All rights reserved.
*------------------------------------------------------------------------------
* Name: USBD_User_CDC_ACM_n.c
* Purpose: USB Device Communication Device Class (CDC)
* Abstract Control Model (ACM) User module
* Rev.: V6.2
*----------------------------------------------------------------------------*/
#include <stdbool.h>
#include "rl_usb.h"
// Called during USBD_Initialize to initialize the USB CDC class instance (ACM).
// Add code for initialization
}
// Called during USBD_Uninitialize to de-initialize the USB CDC class instance (ACM).
// Add code for de-initialization
}
// Called upon USB Bus Reset Event.
void USBD_CDCn_ACM_Reset (void) {
// Add code for reset
}
// Called upon USB Host request to change communication settings.
// \param[in] line_coding pointer to \ref CDC_LINE_CODING structure.
// \return true set line coding request processed.
// \return false set line coding request not supported or not processed.
// Add code for set line coding
return true;
}
// Called upon USB Host request to retrieve communication settings.
// \param[out] line_coding pointer to \ref CDC_LINE_CODING structure.
// \return true get line coding request processed.
// \return false get line coding request not supported or not processed.
// Add code for get line coding
return true;
}
// Called upon USB Host request to set control line states.
// \param [in] state control line settings bitmap.
// - bit 0: DTR state
// - bit 1: RTS state
// \return true set control line state request processed.
// \return false set control line state request not supported or not processed.
bool USBD_CDCn_ACM_SetControlLineState (uint16_t state) {
// Add code for set control line state
return true;
}