Skip to content

Commit 7e0b56f

Browse files
committed
USB-Cypress: Lock sleep when USB is initialized
None of the USB drivers currently support entering deep sleep mode while USB is active. To protect USB from malfunctioning lock deep sleep in USBPhyHw::init.This is done for similar This was done for all other implementations as part of 8ffbe5c6033
1 parent 16568da commit 7e0b56f

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)