Skip to content

Commit

Permalink
Merge pull request #11697 from hugueskamba/hk-fix-lock-deep-sleep-usb…
Browse files Browse the repository at this point in the history
…-cypress

USB-Cypress: Lock sleep when USB is initialized
  • Loading branch information
0xc0170 committed Oct 31, 2019
2 parents da6b336 + 7e0b56f commit 50abaa6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp
Expand Up @@ -17,6 +17,7 @@

#include "cy_usb_phy_hw.h"
#include "mbed_assert.h"
#include "mbed_power_mgmt.h"

#if defined(DEVICE_USBDEVICE)

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

if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}

// Store events
instance->events = events;

Expand Down Expand Up @@ -176,6 +181,12 @@ void USBPhyHw::usb_dev_execute_ep_callbacks(void)
void USBPhyHw::deinit()
{
cyhal_usb_dev_free(&obj);

if (events != NULL) {
sleep_manager_unlock_deep_sleep();
}

events = NULL;
}

bool USBPhyHw::powered()
Expand Down

0 comments on commit 50abaa6

Please sign in to comment.