From f00053820bb5af08a2bf831fb739c22b88a8fdeb Mon Sep 17 00:00:00 2001 From: George Beckstein Date: Wed, 26 Dec 2018 19:15:28 -0500 Subject: [PATCH] Removed disable from disconnect to see if it affects the success of the soft reset test. --- .../TARGET_MCU_NRF52840/USBPhy_Nordic.cpp | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/usb/device/targets/TARGET_NORDIC/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp b/usb/device/targets/TARGET_NORDIC/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp index 666a15df05..10313bcc24 100644 --- a/usb/device/targets/TARGET_NORDIC/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp +++ b/usb/device/targets/TARGET_NORDIC/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp @@ -139,6 +139,10 @@ void USBPhyHw::connect() { // when the internal regulator has settled if(!nrf_drv_usbd_is_enabled()) nrf_drv_usbd_enable(); + + if(nrf_drv_power_usbstatus_get() == NRF_DRV_POWER_USB_STATE_READY + && !nrf_drv_usbd_is_started()) + nrf_drv_usbd_start(false);//nrf_drv_usbd_start(true); } } @@ -148,8 +152,8 @@ void USBPhyHw::disconnect() { if(nrf_drv_usbd_is_started()) nrf_drv_usbd_stop(); - if(nrf_drv_usbd_is_enabled()) - nrf_drv_usbd_disable(); +// if(nrf_drv_usbd_is_enabled()) +// nrf_drv_usbd_disable(); } void USBPhyHw::configure() { @@ -232,7 +236,16 @@ void USBPhyHw::ep0_read(uint8_t *data, uint32_t size) { transfer->p_data.rx = data; transfer->size = size; - // Update the number of bytes remaining in the setup data stage +// if((setup_total == 1) && ((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0)) +// { +// setup_remaining -= size; +// } +// else +// { +// // Update the number of bytes remaining in the setup data stage +// setup_remaining -= size; +// } + setup_remaining -= size; nrf_drv_usbd_setup_data_clear(); // tell the hardware to receive another OUT packet @@ -412,10 +425,10 @@ void USBPhyHw::process() { if(setup_buf.wLength == 0) { nrf_drv_usbd_setup_clear(); } - else if((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0) { - // HOST->DEVICE transfer, need to notify hardware of Data OUT stage - nrf_drv_usbd_setup_data_clear(); - } +// else if((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0) { +// // HOST->DEVICE transfer, need to notify hardware of Data OUT stage +// nrf_drv_usbd_setup_data_clear(); +// } // Notify the Mbed stack events->ep0_setup(); @@ -496,6 +509,10 @@ void USBPhyHw::_reset(void) // Disable all endpoints except for control endpoints nrf_drv_usbd_ep_default_config(); + nrf_drv_usbd_setup_clear(); + + usb_event_type = USB_HW_EVENT_NONE; + // TODO - Clear all endpoint interrupts? }