Skip to content

Commit eeeb9f2

Browse files
AGlass0fMilkhugueskamba
authored andcommitted
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#9879
1 parent 0b7904f commit eeeb9f2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

usb/device/targets/TARGET_NORDIC/TARGET_MCU_NRF52840/USBPhy_Nordic.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ USBPhyHw::~USBPhyHw()
7070
void USBPhyHw::init(USBPhyEvents *events)
7171
{
7272

73+
// Disable the USBD interrupts
74+
// Interrupts will be reenabled by the Nordic driver
75+
NRFX_IRQ_DISABLE(USBD_IRQn);
76+
77+
if(this->events == NULL) {
78+
sleep_manager_lock_deep_sleep();
79+
}
80+
7381
this->events = events;
7482

7583
ret_code_t ret;
@@ -125,6 +133,10 @@ void USBPhyHw::deinit()
125133
// Disable the power peripheral driver
126134
nrfx_power_uninit();
127135

136+
if(this->events != NULL) {
137+
sleep_manager_unlock_deep_sleep();
138+
}
139+
128140
// Clear the instance pointer
129141
instance = 0;
130142
}

0 commit comments

Comments
 (0)