Merge pull request #1835 from MasterQ32/otg_bringup

Implements deinit functions for host/device mode switch
This commit is contained in:
Ha Thach
2024-04-08 23:48:52 +07:00
committed by GitHub
33 changed files with 312 additions and 102 deletions

View File

@@ -407,6 +407,19 @@ void dcd_init(uint8_t rhport) {
dcd_connect(rhport);
}
bool dcd_deinit(uint8_t rhport) {
(void) rhport;
reset_non_control_endpoints();
irq_remove_handler(USBCTRL_IRQ, dcd_rp2040_irq);
// reset usb hardware into initial state
reset_block(RESETS_RESET_USBCTRL_BITS);
unreset_block_wait(RESETS_RESET_USBCTRL_BITS);
return true;
}
void dcd_int_enable(__unused uint8_t rhport) {
assert(rhport == 0);
irq_set_enabled(USBCTRL_IRQ, true);

View File

@@ -409,6 +409,16 @@ bool hcd_init(uint8_t rhport)
return true;
}
bool hcd_deinit(uint8_t rhport) {
(void) rhport;
irq_remove_handler(USBCTRL_IRQ, hcd_rp2040_irq);
reset_block(RESETS_RESET_USBCTRL_BITS);
unreset_block_wait(RESETS_RESET_USBCTRL_BITS);
return true;
}
void hcd_port_reset(uint8_t rhport)
{
(void) rhport;