This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

missing entry in g_sCDCDevice struct in usb_dev_serial example code?

In the usb_dev_serial example code for the dk-tm4c129x dev kit, in the file usb_serial_structs.c, there is a definition of a struct variable named g_sCDCDevice.

The type of the variable is tUSBDCDCDevice, which requires 13 members. However, the variable is only initialized with 12 (and in fact there is a comma after the last initializer).

It appears that the intention was to have g_sCDCInstance be the final entry in the struct. Somehow the example still compiles and runs.

Is there indeed something missing here, or am I not understanding things correctly?

//***************************************************************************** // // The CDC device initialization and customization structures. In this case, // we are using USBBuffers between the CDC device class driver and the // application code. The function pointers and callback data values are set // to insert a buffer in each of the data channels, transmit and receive. // // With the buffer in place, the CDC channel callback is set to the relevant // channel function and the callback data is set to point to the channel // instance data. The buffer, in turn, has its callback set to the application // function and the callback data set to our CDC instance structure. // //***************************************************************************** tCDCSerInstance g_sCDCInstance; extern const tUSBBuffer g_sTxBuffer; extern const tUSBBuffer g_sRxBuffer; tUSBDCDCDevice g_sCDCDevice = { USB_VID_TI_1CBE, USB_PID_SERIAL, 0, USB_CONF_ATTR_SELF_PWR, ControlHandler, (void *)&g_sCDCDevice, USBBufferEventCallback, (void *)&g_sRxBuffer, USBBufferEventCallback, (void *)&g_sTxBuffer, g_pui8StringDescriptors, NUM_STRING_DESCRIPTORS,
// SHOULD BE ONE MORE ENTRY HERE!
};
  • OK, I think I understand what is going on. The struct is only partially initialized because the last entry is a structure used by the CDC to store stuff. But why is there a definition of g_sCDCInstance right before? That variable does not seem to get used anywhere.