From 01f0880d652ea7187304eb7c989af935c7beafca Mon Sep 17 00:00:00 2001 From: George Beckstein Date: Fri, 15 Mar 2019 11:10:33 -0400 Subject: [PATCH] Lock sleep when USB is initialized Added logic to lock deep sleep when USB is initialized to prevent malfunctioning. This is consistent with the other drivers. See PR ARMmbed/mbed-os#9879 --- .../TARGET_MCU_NRF52840/USBPhy_Nordic.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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; }