Y
Y
Yaroslav Korchevsky2021-01-17 10:26:22
Microcontrollers
Yaroslav Korchevsky, 2021-01-17 10:26:22

Why does only one endpoint work in a composite USB device on stm32f407 (CubeIDE)?

Made a composite device.
I used the article Composite CDC + MSC
Everything would be fine, but depending on the purpose of the endpoints, it works

on the STM32F4xx platform, FIFO queues are configured differently.
Found another useful link : also did not help.

My code is here
CDC works very simply
- works almost like an echo. You connect the terminal - and on any keystroke you get
"aba01" HID in response - it sends "HID"
once a second under Linux, this can be seen cat / dev / hidraw0 Depending on the purpose Endpoint #if 0 #define CUSTOM_HID_EPIN_ADDR 0x82U

#define CUSTOM_HID_EPOUT_ADDR 0x02U
#define CDC_IN_EP 0x81U /* EP1 for data IN */
#define CDC_OUT_EP 0x01U /* EP1 for data OUT */
#define CDC_CMD_EP 0x83U /* EP2 for CDC commands */
#else
#define CUSTOM_HID_EPIN_ADDR 0x81U_ADHID
#define CUSTOM_HID_EPIN_ADDR 0x81U_ADHID
#define CDC_IN_EP 0x82U /* EP1 for data IN */
#define CDC_OUT_EP 0x02U /* EP1 for data OUT */
#define CDC_CMD_EP 0x83U /* EP2 for CDC commands */
#endif

Either HID or CDC works. ENDPOINT's magic number is 0x81 - it works

If you replace HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1/*FIFO count*/, 0x80);
to HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2/*FIFO count*/, 0x80);
On the advice of StackOverflow

The situation is changing.
Either HID or CDC works. But already with ENDPOINT - 0x82

I don't understand how to make both endpoints work.
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2/*FIFO count*/, 0x40);
It doesn't help either.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Korchevsky, 2021-01-18
@yslav

Wow, I got it.
I slowed down and did not understand how HAL_PCDEx_SetTxFiFo(...) works .
It turns out that it needs to be set for each endpoint individually.
Problem solved!!!

W
WeiLin, 2021-01-17
@veydlin

The library from ST is a living hell, nothing works there, even I found errors in it
I ended up using tinyusb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question