General Configuration
There are various configuration constants necessary to customize the CDC EEM subclass. These constants are located in the usbd_cfg
.h file. shows a description of each constant.
Class Instance Configuration
Before starting the communication phase, your application needs to initialize and configure the class to suit its needs. summarizes the initialization functions provided by the CDC EEM implementation. Please refer to the CDC EEM API reference for a full listing of the CDC EEM API.
To successfully initialize the CDC EEM subclass, you need to follow these steps:
- Call
USBD_CDC_EEM_Init()
This is the first function you should call, and it should be called only once regardless of the number of class instances you intend to have. This function will initialize all internal structures and variables that the class will need. - Call
USBD_CDC_EEM_Add()
This function will add a new instance of the CDC EEM subclass. - Call
USBD_CDC_EEM_CfgAdd()
Once the class instance is correctly configured and initialized, you will need to add it to a USB configuration. High speed devices will build two separate configurations, one for full speed and one for high speed by callingUSBD_CDC_EEM_CfgAdd()
for each speed configuration. - Add a network interface using CDC EEM as the physical link.
For more information on how to initialize the µC/TCP-IP stack, see UserManual.
shows how the latter functions are called during CDC EEM initialization and an example of creation and initialization of a CDC EEM network interface using µC/TCP-IP.
Class Instance Configuration by Network Driver
The network driver that interfaces with the CDC EEM subclass must initialize the class instance with its specific requirements. This is done by calling the function USBD_CDC_EEM_InstanceInit()
from the interface initialization function of the network driver. This function must be called only once. gives the prototype of the function USBD_CDC_EEM_InstanceInit()
.
Configuration of Network Driver
The network driver used to interact with the CDC EEM class MUST follow some guidelines for the configuration of its buffers.
- The size of the receive AND transmit buffers MUST be set to 1518 bytes or more (MTU including CRC).
- The alignment of transmit buffers MUST be a multiple of the alignment required by the USB controller.
- The transmit buffers MUST have an offset of two (2) bytes at the beginning. This is necessary as the CDC EEM subclass will prepend the header.
gives an example of configuration when the µC/TCP-IP's USBD_CDCEEM driver is used.