diff options
| author | hathach <[email protected]> | 2020-08-04 14:18:12 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2020-08-04 14:18:12 +0700 |
| commit | 7d9efd06979f6cdde2a4093f0c26e8100312c92c (patch) | |
| tree | d620b296f08d0d78a6bbef6c9dcec9aed080b5e6 /src | |
| parent | 026a1e7ac86e73e5596d819eacc7dbff97f6d322 (diff) | |
manually submit unplugged event for nrf dcd_disconnect()
Diffstat (limited to 'src')
| -rw-r--r-- | src/portable/nordic/nrf5x/dcd_nrf5x.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index fdf56b6ca..cd35f2e5b 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -271,6 +271,10 @@ void dcd_disconnect(uint8_t rhport) { (void) rhport; NRF_USBD->USBPULLUP = 0; + + // Disable Pull-up does not trigger Power USB Removed, in fact it have no + // impact on the USB Power status at all -> need to submit unplugged event to the stack. + dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, false); } // connect by enabling internal pull-up resistor on D+/D- @@ -693,6 +697,8 @@ void tusb_hal_nrf_power_event (uint32_t event) switch ( event ) { case USB_EVT_DETECTED: + TU_LOG2("Power USB Detect\r\n"); + if ( !NRF_USBD->ENABLE ) { /* Prepare for READY event receiving */ @@ -743,6 +749,12 @@ void tusb_hal_nrf_power_event (uint32_t event) break; case USB_EVT_READY: + TU_LOG2("Power USB Ready\r\n"); + + // Skip if pull-up is enabled and HCLK is already running. + // Application probably call this more than necessary. + if ( NRF_USBD->USBPULLUP && hfclk_running() ) break; + /* Waiting for USBD peripheral enabled */ while ( !(USBD_EVENTCAUSE_READY_Msk & NRF_USBD->EVENTCAUSE) ) { } @@ -810,6 +822,7 @@ void tusb_hal_nrf_power_event (uint32_t event) break; case USB_EVT_REMOVED: + TU_LOG2("Power USB Removed\r\n"); if ( NRF_USBD->ENABLE ) { // Abort all transfers |
