HAL_PCDEx_SetTxFiFo and fifo number/order
- February 26, 2019
- 8 replies
- 6885 views
Hi, I'm having a hard time understanding the HAL_PCDEx_SetTxFiFo() function that I should call inside the USBD_LL_Init() function for my Stm32L476. I have attach my descriptor results from USBTreeView. But here the highlight:
My composite device have multiple interface:
- 1 HID interface
- 1 interrupt IN EP 0x83
- 1 interface for application
- 1 Bulk IN EP 0x84
- 1 Bulk OUT EP 0x04
- 1 interrupt IN EP 0x85
- 1 ISO IN EP 0x86
- IAD Link both CDC interfaces
- 1 CDC Control interface
- 1 Interrupt IN EP 0x82
- 1 CDC Data interface
- 1 Bulk IN EP 0x81
- 1 Bulk OUT EP 0x01
- 1 CDC Control interface
I did keep the IAD and CDC as the last into the descriptor since it seem to confuse some COM driver. But I still have a hard time with my endpoints and the call to init the TX buffer, I'm not sure I do the right thing.
Does HAL_PCDEx_SetTxFiFo() use for the fifo 2nd argument :
- the endpoint id without the direction (& ~0x80)?
- the order they appear into descriptor and interface number?
What is it represent exactly? Can I skip some? How much can be used, is 6 too much?
It seem like if I remove my application endpoints my CDC work normally and when I add them my write cannot be perform since the
CDC_Transmit_FS()
if (hcdc->TxState != 0){
return USBD_BUSY;
}
The TXState is always busy. This even if no driver and I do nothing with the other endpoints, the CDC stop working. I suspeect I don't do the rith thing with my tx buffer init with HAL_PCDEx_SetTxFiFo
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); /* Default control EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x40); /* CDC bulk EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x10); /* CDC interrupt EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 3, 0x10); /* HID interrupt EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 4, 0x40); /* App bulk EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 5, 0x40); /* App interrupt EP */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 6, 0x40); /* App isochronous EP */
Maybe I got this wrong, I'm just not sure how this get link to the proper endpoint or if I overflow the RX space (I have read the F4 only support 0..5, not sure if this is true for the L4?).
Does the descriptor order and interface order and endpoint numbering have any requirements? like does the lowest interfaces should have the lowest endpoints numbers?
