Skip to content

Lock sleep when USB is initialized #9879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion usb/device/targets/TARGET_Freescale/USBPhy_Kinetis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ USBPhy *get_usb_phy()
return &usbphy;
}

USBPhyHw::USBPhyHw()
USBPhyHw::USBPhyHw(): events(NULL)
{

}
Expand All @@ -117,6 +117,9 @@ USBPhyHw::~USBPhyHw()

void USBPhyHw::init(USBPhyEvents *events)
{
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events;

// Disable IRQ
Expand Down Expand Up @@ -183,6 +186,11 @@ void USBPhyHw::deinit()
disconnect();
NVIC_DisableIRQ(USB0_IRQn);
USB0->INTEN = 0;

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

bool USBPhyHw::powered()
Expand Down
10 changes: 9 additions & 1 deletion usb/device/targets/TARGET_NXP/USBHAL_LPC17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ USBPhy *get_usb_phy()
return &usbphy;
}

USBPhyHw::USBPhyHw(void)
USBPhyHw::USBPhyHw(void): events(NULL)
{

}
Expand All @@ -381,6 +381,9 @@ USBPhyHw::~USBPhyHw(void)

void USBPhyHw::init(USBPhyEvents *events)
{
if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events;

// Disable IRQ
Expand Down Expand Up @@ -440,6 +443,11 @@ void USBPhyHw::deinit()
NVIC_DisableIRQ(USB_IRQn);
events = NULL;
opStarted = 0;

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

bool USBPhyHw::powered()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ void USBPhyHw::init(USBPhyEvents *events)
{
volatile uint8_t dummy_read;

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

/* registers me */
Expand Down Expand Up @@ -174,6 +177,11 @@ void USBPhyHw::deinit()
#endif
dummy_read = CPG.STBCR7;
(void)dummy_read;

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

bool USBPhyHw::powered()
Expand Down
8 changes: 8 additions & 0 deletions usb/device/targets/TARGET_STM/USBPhy_STM32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ void USBPhyHw::init(USBPhyEvents *events)
{
NVIC_DisableIRQ(USBHAL_IRQn);

if (this->events == NULL) {
sleep_manager_lock_deep_sleep();
}
this->events = events;
sof_enabled = false;
memset(epComplete, 0, sizeof(epComplete));
Expand Down Expand Up @@ -333,6 +336,11 @@ void USBPhyHw::deinit()
{
HAL_PCD_DeInit(&hpcd);
NVIC_DisableIRQ(USBHAL_IRQn);

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

bool USBPhyHw::powered()
Expand Down