From e94d11a5b39cae08f39722eaa5f6ac4d527a329b Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 31 Mar 2022 12:56:53 +0700 Subject: [PATCH] implement pio_usb_irq_handler --- lib/Pico-PIO-USB | 2 +- src/portable/raspberrypi/pio/hcd_pio.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/Pico-PIO-USB b/lib/Pico-PIO-USB index 92268187f..4220c05dc 160000 --- a/lib/Pico-PIO-USB +++ b/lib/Pico-PIO-USB @@ -1 +1 @@ -Subproject commit 92268187f3b0490a43d139ed2cb598b06258011f +Subproject commit 4220c05dc6b7ab7b4db33e5e05bb66be7b6c7156 diff --git a/src/portable/raspberrypi/pio/hcd_pio.c b/src/portable/raspberrypi/pio/hcd_pio.c index e4a4e2450..254acf1d2 100644 --- a/src/portable/raspberrypi/pio/hcd_pio.c +++ b/src/portable/raspberrypi/pio/hcd_pio.c @@ -101,7 +101,7 @@ void hcd_port_reset_end(uint8_t rhport) if (fullspeed_flag && get_port_pin_status(root) == PORT_PIN_FS_IDLE) { root->root_device = &usb_device[0]; if (!root->root_device->connected) { - configure_fullspeed_host(pp, &pio_host_config, root); +// configure_fullspeed_host(pp, &pio_host_config, root); root->root_device->is_fullspeed = true; root->root_device->is_root = true; root->root_device->connected = true; @@ -111,7 +111,7 @@ void hcd_port_reset_end(uint8_t rhport) } else if (!fullspeed_flag && get_port_pin_status(root) == PORT_PIN_LS_IDLE) { root->root_device = &usb_device[0]; if (!root->root_device->connected) { - configure_lowspeed_host(pp, &pio_host_config, root); +// configure_lowspeed_host(pp, &pio_host_config, root); root->root_device->is_fullspeed = false; root->root_device->is_root = true; root->root_device->connected = true; @@ -217,6 +217,7 @@ bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet return false; } + bool hcd_edpt_control_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8], uint8_t* data) { int ret; @@ -242,7 +243,6 @@ bool hcd_edpt_control_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t const setup return ret == 0; } - //bool hcd_edpt_busy(uint8_t dev_addr, uint8_t ep_addr) //{ // // EPX is shared, so multiple device addresses and endpoint addresses share that @@ -265,4 +265,24 @@ bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr) return true; } +// IRQ Handler +void pio_usb_irq_handler(uint8_t root_id) +{ + root_port_t* port = PIO_USB(root_id); + + if ( port->ints & PIO_USB_INTS_CONNECT_BITS ) + { + hcd_event_device_attach(root_id+1, true); + + port->ints &= ~PIO_USB_INTS_CONNECT_BITS; + } + + if ( port->ints & PIO_USB_INTS_DISCONNECT_BITS ) + { + hcd_event_device_remove(root_id+1, true); + + port->ints &= ~PIO_USB_INTS_DISCONNECT_BITS; + } +} + #endif