2022-10-26 10:09 AM
I'm trying to use High speed USB HID to transfer bulk data from external SDRAM controlled via FMC.
I have achieved the basic transfer function by modifying the USB description file and related functions.
/******************** Descriptor of Custom HID endpoints ********************/
/* 27 */
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
0x02, /* bmAttributes: Bulk endpoint */
0x00, /* wMaxPacketSize: 512 Bytes max */
CUSTOM_HID_EPIN_SIZE>>8,
CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */
/* 34 */
0x07, /* bLength: Endpoint Descriptor size */
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
0x02, /* bmAttributes: Bulk endpoint */
0x00, /* wMaxPacketSize: 512 Bytes max */
CUSTOM_HID_EPOUT_SIZE>>8,
CUSTOM_HID_HS_BINTERVAL, /* bInterval: Polling Interval */
/* 41 */
/******************** Funciton of Sending Data ********************/
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
uint8_t *report, uint32_t len)
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
When I try to transfer data longer than 19-bit (0x7fff, 524287), it will cause the USB to fail to transfer.
If the oversized data is cut to a length of no more than 19-bit, the entire SDRAM (32MB) data can be transferred correctly.
Is it because of some limitation of the Custom HID Class that I don't know about?
Hope STM32CUBEIDE will provide USB Custom Class generation!!
2022-10-26 12:08 PM
HID devices do not have bulk endpoints.
See the spec, ch. 4.4.
2022-10-28 12:26 AM
Thank you for your reply
I know HID uses interrupt transfers, but I'm trying to use it as a custom HID device and it seems to work just fine unless large size data is transferred through these functions.
Splitting the data into smaller chunk sizes as I said works, but I'm wondering why?
Seems to be an interruption or process issue as some delay is required between each transfer
uint32_t ucMaxTxSize = 524287;
void vBspUsb_SendBuffer(uint8_t * ucpBuffer, uint32_t ulSize)
{
if(ulSize > 0)
{
if(ulSize > ucMaxTxSize)
{
fTransfertimes = (ulSize / ucMaxTxSize);
Remainsize = ulSize;
for (uint16_t i = 0; i < fTransfertimes; i++)
{
xUsbStatus = USBD_CUSTOM_HID_SendReport(&hUsbDeviceHS, ucpBuffer, ucMaxTxSize);
ucpBuffer = ucpBuffer + ucMaxTxSize;
Remainsize = Remainsize - ucMaxTxSize;
HAL_Delay(30);
}
xUsbStatus = USBD_CUSTOM_HID_SendReport(&hUsbDeviceHS, ucpBuffer, Remainsize);
HAL_Delay(200);
}
else
{
xUsbStatus = USBD_CUSTOM_HID_SendReport(&hUsbDeviceHS, ucpBuffer, ulSize);
HAL_Delay(200);
}
}
}
2022-10-28 02:07 AM
Another thing about HID is that the host figures out the report size(s) from the report descriptor.
Device cannot send more than the host is willing to receive.
Do you have a report descriptor? what is the longest report size there?
What you're doing looks like...
2022-10-30 08:53 PM
Thanks again for your reply
I know this is not a typical way of using USB HID. Previously, data transfer was done through the Custom Class provided by Keil, but for some reason, it was developed using STM32CubeIDE, but this class is not provided in this IDE.
Maybe you have USB experience in developing BULK transfer mode in this IDE to share?
I'm not quite sure which part of the report descriptor you are talking about?
2022-10-31 05:44 PM
A HID device does not send or receive bulk data, rather it sends or receives data structures known as reports.
The descriptors needed for a HID device are explained in the USB spec (see link above) ch. 5, from page 12. Also you can refer to the USB book, or something newer.
Bottom line: the host does not know how to receive data from your device without a proper descriptor.
If you want to send bulk data, make a composite device where one function is custom, another is HID (in case it is still needed).
2022-11-01 12:16 AM
Problem: "The host doesn't know how to receive data from your device without the correct descriptor."
This is a custom device with custom software, so at first I would send a fixed length of data telling the host "data size" and start sending data.
Unless the data size is larger than the 19-bit length (524287 bytes), the data can be sent correctly, but I can still slice through the data to make it smaller than this length and add a delay when sending multiple transfers to complete.
I've also tried identifying it as:
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
Transmission is still limited to the same size constraints
2023-01-12 03:00 AM
Hello, I am trying to do something like this, I have tried using MSC class driver and changed the Interface class to "255" which is vendor specific but unable to transmit the data. Could you share me your configuration description and the functions that you have modified. It would be really helpful for us.