Why is USBD CDC Data OUT Receive callback passed RxLength as a pointer instead of as a value?
Regarding the definition of the Receive callback in usbd_cdc.h:
typedef struct _USBD_CDC_Itf
{
// ...
int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
// ...
} USBD_CDC_ItfTypeDef; Passing length as a pointer implies that the callback is supposed to edit this value, but I don't see where the USB library makes use of a modified RxLength (maybe the ECM and RNDIS USB libraries expect this to be edited in the callback, but that's still unclear). For basic CDC operation:
- Are we even supposed to edit RxLength in the callback?
- If not, why does the library pass this as a pointer? Passing it as a value would be clearer.
For context, here's where USBD_CDC_DataOut calls the user-provided Receive callback.
I didn't find any clarification about this in UM1734 Rev 4. Search for CDC_Itf_Receive.
I added some additional details in this gist. It's pretty taxing wrestling with the limited formatting tools in this forum. Has ST considered migrating to something with a better UX, such as discourse?
