dmitrystu / libusb_stm32

Lightweight USB device Stack for STM32 microcontrollers
Apache License 2.0
721 stars 165 forks source link

Calculating _rxcnt in usbd_stm32l433_devfs.c wrong? #69

Closed lulle2007200 closed 4 years ago

lulle2007200 commented 4 years ago

What is going on here? https://github.com/dmitrystu/libusb_stm32/blob/master/src/usbd_stm32l433_devfs.c#L245 If endpoint size is greater than 62, we should align it by 32. Then left shift by 5 bits to get number of blocks in bits 10:14, then set bit 15 to 1 to indicate block size of 32 bytes and substract 0x400 (reduce NUM_BLOCK by one, because NUM_BLOCK=Number of 32 byte blocks - 1) So should't it be _rxcnt = 0x8000 - 0x400 + (epsize << 5)? Or am i missing something?

dmitrystu commented 4 years ago

Yes, probably you are right. I need to recheck code, also asm.

dmitrystu commented 4 years ago

Yes, you are right. It was a typo. But actually result is the same since bitfield COUNTn_RX[9:0] is r/o. Will be fixed.

dmitrystu commented 4 years ago

BTW. According to USB FS specs, EP size greater than 64 bytes is disallowed.

lulle2007200 commented 4 years ago

Thanks for looking into it. Also im aware that EP greater size 64 bytes is illegal. Makes me wonder why they even have that weird system to allow EP size greater than 62 bytes, but thats offtopic.

dmitrystu commented 4 years ago

I've been wondered so many times by ST's solutions that I no longer ask myself "why did they do that way?".

7134956 commented 4 years ago

I use 128 to little increase speed. Worked in windows 10.