Skip to content

Commit 3d1b55d

Browse files
author
Cruz Monrreal
authored
Merge pull request #9879 from c1728p9/usb_sleep_lock
Lock sleep when USB is initialized
2 parents 9d9a076 + 8ffbe5c commit 3d1b55d

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

usb/device/targets/TARGET_Freescale/USBPhy_Kinetis.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -106,7 +106,7 @@ USBPhy *get_usb_phy()
106
return &usbphy;
106
return &usbphy;
107
}
107
}
108

108

109-
USBPhyHw::USBPhyHw()
109+
USBPhyHw::USBPhyHw(): events(NULL)
110
{
110
{
111

111

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

117

118
void USBPhyHw::init(USBPhyEvents *events)
118
void USBPhyHw::init(USBPhyEvents *events)
119
{
119
{
120+
if (this->events == NULL) {
121+
sleep_manager_lock_deep_sleep();
122+
}
120
this->events = events;
123
this->events = events;
121

124

122
// Disable IRQ
125
// Disable IRQ
@@ -183,6 +186,11 @@ void USBPhyHw::deinit()
183
disconnect();
186
disconnect();
184
NVIC_DisableIRQ(USB0_IRQn);
187
NVIC_DisableIRQ(USB0_IRQn);
185
USB0->INTEN = 0;
188
USB0->INTEN = 0;
189+
190+
if (events != NULL) {
191+
sleep_manager_unlock_deep_sleep();
192+
}
193+
events = NULL;
186
}
194
}
187

195

188
bool USBPhyHw::powered()
196
bool USBPhyHw::powered()

usb/device/targets/TARGET_NXP/USBHAL_LPC17.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -369,7 +369,7 @@ USBPhy *get_usb_phy()
369
return &usbphy;
369
return &usbphy;
370
}
370
}
371

371

372-
USBPhyHw::USBPhyHw(void)
372+
USBPhyHw::USBPhyHw(void): events(NULL)
373
{
373
{
374

374

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

381

382
void USBPhyHw::init(USBPhyEvents *events)
382
void USBPhyHw::init(USBPhyEvents *events)
383
{
383
{
384+
if (this->events == NULL) {
385+
sleep_manager_lock_deep_sleep();
386+
}
384
this->events = events;
387
this->events = events;
385

388

386
// Disable IRQ
389
// Disable IRQ
@@ -440,6 +443,11 @@ void USBPhyHw::deinit()
440
NVIC_DisableIRQ(USB_IRQn);
443
NVIC_DisableIRQ(USB_IRQn);
441
events = NULL;
444
events = NULL;
442
opStarted = 0;
445
opStarted = 0;
446+
447+
if (events != NULL) {
448+
sleep_manager_unlock_deep_sleep();
449+
}
450+
events = NULL;
443
}
451
}
444

452

445
bool USBPhyHw::powered()
453
bool USBPhyHw::powered()

usb/device/targets/TARGET_RENESAS/TARGET_RZ_A1XX/USBPhy_RZ_A1.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -128,6 +128,9 @@ void USBPhyHw::init(USBPhyEvents *events)
128
{
128
{
129
volatile uint8_t dummy_read;
129
volatile uint8_t dummy_read;
130

130

131+
if (this->events == NULL) {
132+
sleep_manager_lock_deep_sleep();
133+
}
131
this->events = events;
134
this->events = events;
132

135

133
/* registers me */
136
/* registers me */
@@ -174,6 +177,11 @@ void USBPhyHw::deinit()
174
#endif
177
#endif
175
dummy_read = CPG.STBCR7;
178
dummy_read = CPG.STBCR7;
176
(void)dummy_read;
179
(void)dummy_read;
180+
181+
if (events != NULL) {
182+
sleep_manager_unlock_deep_sleep();
183+
}
184+
events = NULL;
177
}
185
}
178

186

179
bool USBPhyHw::powered()
187
bool USBPhyHw::powered()

usb/device/targets/TARGET_STM/USBPhy_STM32.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -168,6 +168,9 @@ void USBPhyHw::init(USBPhyEvents *events)
168
{
168
{
169
NVIC_DisableIRQ(USBHAL_IRQn);
169
NVIC_DisableIRQ(USBHAL_IRQn);
170

170

171+
if (this->events == NULL) {
172+
sleep_manager_lock_deep_sleep();
173+
}
171
this->events = events;
174
this->events = events;
172
sof_enabled = false;
175
sof_enabled = false;
173
memset(epComplete, 0, sizeof(epComplete));
176
memset(epComplete, 0, sizeof(epComplete));
@@ -333,6 +336,11 @@ void USBPhyHw::deinit()
333
{
336
{
334
HAL_PCD_DeInit(&hpcd);
337
HAL_PCD_DeInit(&hpcd);
335
NVIC_DisableIRQ(USBHAL_IRQn);
338
NVIC_DisableIRQ(USBHAL_IRQn);
339+
340+
if (events != NULL) {
341+
sleep_manager_unlock_deep_sleep();
342+
}
343+
events = NULL;
336
}
344
}
337

345

338
bool USBPhyHw::powered()
346
bool USBPhyHw::powered()

0 commit comments

Comments
 (0)