rust-embedded-community / usb-device

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

Add `free` function to UsbAllocator #137

Open jnthbdn opened 6 months ago

jnthbdn commented 6 months ago

Allowing users to free the UsbBus from the UsbAllocator.

ryan-summers commented 5 months ago

Yeah I'm also not sure this makes sense to allow. Can you elaborate on what the necessary use case is here?

jnthbdn commented 5 months ago

Hello,

Thank you for your feedback. I've added this function to make the link with the PR725 (https://github.com/rp-rs/rp-hal/pull/725) from rp-hal. The problem is that creating a UsbBus requires ownership of two peripherals (USBCTRL_REGS and USBCTRL_DPRAM) and a clock. But if you want to stop the USB, it's not possible to recover these resources, and you end up, for example, with a Partially move error (in my case from the clockManager).