rust-embedded-community / usb-device

Experimental device-side USB framework for microcontrollers in Rust.
MIT License
414 stars 77 forks source link

CTR_RX is not being cleared. #72

Closed linasdev closed 3 years ago

linasdev commented 3 years ago

When the direction is IN and ep_setup and ep_out bits are false, the CTR_RX register is not being cleared, so my USB polling interrupt keeps firing and the program stalls. This might be completely an issue on my end but I would still appreciate some pointers in the general direction. As you can tell, I have little USB experience. I'm just making a tiny project and thought Rust would be a nice touch. I'm using usbd-hid, stm32-usbd (I'm running this on a stm32f103cbt6) and, obviously, usb-device itself.

https://github.com/mvirkkunen/usb-device/blob/b6037b0f98c933ff0a18a864fd34a42f89a6316a/src/device.rs#L206-L212

mvirkkunen commented 3 years ago

When the direction is IN, there should be no receiving going on as IN means device to host direction (TX not RX from the device's viewpoint).

In stm32-usbd, reading the packet from the endpoint clears the interrupt flag. Are you reading from the endpoints you're using (e.g. pull_raw_output in usbd-hid)?

linasdev commented 3 years ago

Hey, so, yeah, that was exactly it. I'm sorry for wasting your time. Closing the issue.

stappersg commented 3 years ago

On Mon, Jun 07, 2021 at 03:29:02PM -0700, Linas Nikiperavičius wrote:

Hey, so, yeah, that was exactly it. I'm sorry for wasting your time. Closing the issue.

Next time:

Hey, so, yeah, that was exactly it. Thanks for making it clear. I leave the issue open for a fews days, so more people gain from it.