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
pull/10689/head
George Beckstein 2019-03-15 11:10:33 -04:00 committed by aglass0fmilk
parent e006666527
commit cc4d8e6d75
1 changed files with 12 additions and 0 deletions

View File

@ -70,6 +70,14 @@ USBPhyHw::~USBPhyHw()
void USBPhyHw::init(USBPhyEvents *events) 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; this->events = events;
ret_code_t ret; ret_code_t ret;
@ -125,6 +133,10 @@ void USBPhyHw::deinit()
// Disable the power peripheral driver // Disable the power peripheral driver
nrfx_power_uninit(); nrfx_power_uninit();
if(this->events != NULL) {
sleep_manager_unlock_deep_sleep();
}
// Clear the instance pointer // Clear the instance pointer
instance = 0; instance = 0;
} }