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 4771087bf2..1a459d0f08 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 @@ -70,6 +70,14 @@ USBPhyHw::~USBPhyHw() void USBPhyHw::init(USBPhyEvents *events) { + // Disable the USBD interrupts + // Interrupts will be reenabled by the Nordic driver + NRFX_IRQ_DISABLE(USBD_IRQn); + + if(this->events == NULL) { + sleep_manager_lock_deep_sleep(); + } + this->events = events; ret_code_t ret; @@ -125,6 +133,10 @@ void USBPhyHw::deinit() // Disable the power peripheral driver nrfx_power_uninit(); + if(this->events != NULL) { + sleep_manager_unlock_deep_sleep(); + } + // Clear the instance pointer instance = 0; }