CDC Configuration

Some constants are available to customize the CDC base class. These constants are located in the USB device configuration file, usbd_cfg.h. Table - CDC Class Configuration Constants shows their description.

Table - CDC Class Configuration Constants
ConstantDescriptionPossible Values
USBD_CDC_CFG_MAX_NBR_DEVConfigures the maximum number of class instances. Each associated subclass also defines a maximum number of subclass instances. The sum of all the maximum numbers of subclass instances must not be greater than USBD_CDC_CFG_MAX_NBR_DEV.From 1 to 254. Default value is 1.
USBD_CDC_CFG_MAX_NBR_CFGConfigures the maximum number of configurations in which CDC class is used. Keep in mind that if you use a high-speed device, two configurations will be built, one for full-speed and another for high-speed.From 1 (low- and full-speed) or 2 (high-speed) to 254. Default value is 2.
USBD_CDC_CFG_MAX_NBR_DATA_IFConfigures the maximum number of Data interfaces.From 1 to 254. The default value is 1.


Listing - CDC Initialization Example shows the App_USBD_CDC_Init() function defined in the application template file app_usbd_cdc.c. This function performs CDC and associated subclass initialization.

CPU_BOOLEAN  App_USBD_CDC_Init (CPU_INT08U  dev_nbr,
                                CPU_INT08U  cfg_hs,
                                CPU_INT08U  cfg_fs)
{
    USBD_ERR  err;


    USBD_CDC_Init(&err);                                                      (1)
 	
    ...                                                                       (2)
}

(1) Initialize CDC internal structures and variables. This is the first function you should call and you should do it only once.

(2) Call all the required functions to initialize the subclass(es). Refer to the ACM Subclass Configuration section for ACM subclass initialization.