Skip to content

Commit 50abaa6

Browse files
authored
Merge pull request #11697 from hugueskamba/hk-fix-lock-deep-sleep-usb-cypress
USB-Cypress: Lock sleep when USB is initialized
2 parents da6b336 + 7e0b56f commit 50abaa6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "cy_usb_phy_hw.h"
1919
#include "mbed_assert.h"
20+
#include "mbed_power_mgmt.h"
2021

2122
#if defined(DEVICE_USBDEVICE)
2223

@@ -64,6 +65,10 @@ void USBPhyHw::init(USBPhyEvents *events)
6465
// Initialize instance to access class data
6566
instance = this;
6667

68+
if (this->events == NULL) {
69+
sleep_manager_lock_deep_sleep();
70+
}
71+
6772
// Store events
6873
instance->events = events;
6974

@@ -176,6 +181,12 @@ void USBPhyHw::usb_dev_execute_ep_callbacks(void)
176181
void USBPhyHw::deinit()
177182
{
178183
cyhal_usb_dev_free(&obj);
184+
185+
if (events != NULL) {
186+
sleep_manager_unlock_deep_sleep();
187+
}
188+
189+
events = NULL;
179190
}
180191

181192
bool USBPhyHw::powered()

0 commit comments

Comments
 (0)