From 7e0b56fa0c2c4378b88479dd2c02640e10a3da4c Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Wed, 16 Oct 2019 13:23:26 +0100 Subject: [PATCH] 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 https://github.com/ARMmbed/mbed-os/commit/8ffbe5c6033 --- targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp b/targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp index 511c72f1ab..483c8fee66 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp +++ b/targets/TARGET_Cypress/TARGET_PSOC6/cy_usb_phy.cpp @@ -17,6 +17,7 @@ #include "cy_usb_phy_hw.h" #include "mbed_assert.h" +#include "mbed_power_mgmt.h" #if defined(DEVICE_USBDEVICE) @@ -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; @@ -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()