libopencm3 icon indicating copy to clipboard operation
libopencm3 copied to clipboard

usb: avoid modulo operation

Open agners opened this issue 5 years ago • 4 comments

The current code uses modulo using a divisor which is not necessarily a power of two. This pulls in __aeabi_idivmod and other libgcc provided functions dealing with division.

The code can be rewritten to determine if a zero-length packet is actually required once we are transfering the last packet. This improves runtime as well as code size.

agners avatar Dec 27 '20 14:12 agners

Successfully tested against the gadget-zero test case:

# python test_gadget0.py
Running (user) tests for DUT:  stm32f072disco
............ss.................
----------------------------------------------------------------------
Ran 31 tests in 0.333s

OK (skipped=2)

agners avatar Dec 27 '20 14:12 agners

This looks good, thanks :)

karlp avatar Jan 02 '21 13:01 karlp

Is there anything on my side to get this merged?

agners avatar May 30 '21 20:05 agners

no, this is blocked at my end.

karlp avatar May 31 '21 09:05 karlp