Showing results for 
Search instead for 
Did you mean: 

Stm32 F4 composite usb device 2 Bulk interfaces, correct FIFO settings ?

Associate III
Posted on August 24, 2017 at 04:41

I used STM32CubeMX version 4.22 to generate MSC usb device and modified it to have 2 custom bulk interfaces. I am using STM32F412, FS usb with internal Physical with maximum packet size of 64. Interface 0 has 2 BULK endpoints IN and OUT. Interface 1 have two alternate settings. Alt Setting 0 has 0 endpoints and Alt Setting 1 have 2 BULK endpoints IN and OUT.

Endpoints are defined as :

&sharpdefine INTERFACE0_IN_EP 0x81

&sharpdefine INTERFACE0_OUT_EP 0x01

&sharpdefine INTERFACE1_IN_EP 0x82

&sharpdefine INTERFACE1_OUT_EP 0x02

My device enumerates fine and Interface 0 works as expected. Host sends Set Interface 1, Alt Setting 1 request then i activate Interface 1 endpoints (0x82 and 0x02).

Interface 1 is not working as expected, i am sure it has something to do with my FIFO Settings. I get dataOut Call for INTERFACE1_OUT_EP but when i try to write INTERFACE1_IN_EP host only get 3 bytes back while i am writing 24 bytes. Immediately after this transaction i get CLEAR FEATURE request for interface 1 endpoints.

Here is my current FIFO Settings :

HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0xC0); //80

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); //EP0

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); //EP1

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40); //<-- If i don't add this line Host can not get any thing back, After adding this line host only receives 3 bytes on INTERFACE1_IN_EP.

Please help me to configure these FIFO settings properly so that second interface can also work as expected.

#usb-fifo-sttings #stm32f4 #usb-composite #stm32cubemx(hal) #usb-fs

Sorry, bumping old unanswered zombie threads off my feed

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..