File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
features/unsupported/USBDevice/targets/TARGET_Silicon_Labs Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change 23
23
#include " em_usbtypes.h"
24
24
#include " em_usbhal.h"
25
25
#include " em_usbd.h"
26
-
27
- #include " sleepmodes.h"
26
+ #include " mbed_sleep.h"
28
27
29
28
enum USBISRCommand {
30
29
CMD_HANDLED = 0 ,
@@ -134,11 +133,6 @@ USBHAL::USBHAL(void)
134
133
// be dynamically removed/reinstated to allow deeper sleep.
135
134
usbhal_allow_em2 (false );
136
135
137
- // When in suspend / Vbus off we can go to EM2, but never below
138
- // that as long as USB is being used. Despite the name the call here
139
- // blocks entering modes _below_ EM2, but allows EM2.
140
- blockSleepMode (EM2);
141
-
142
136
epCallback[EP0OUT] = NULL ;
143
137
epCallback[EP0IN ] = NULL ;
144
138
epCallback[EP1OUT] = &USBHAL::EP1_OUT_callback;
@@ -193,17 +187,17 @@ USBHAL::~USBHAL(void)
193
187
usbhal_free_buffers ();
194
188
195
189
usbhal_allow_em2 (true );
196
- unblockSleepMode (EM2);
197
190
}
198
191
199
192
extern " C" void usbhal_allow_em2 (bool allow_em2)
200
193
{
201
- if (allow_em2) {
202
- // unblockSleepMode is safe to call even if we would unblock
203
- // an already unblocked mode, so no checks here.
204
- unblockSleepMode (EM1);
205
- } else {
206
- blockSleepMode (EM1);
194
+ static bool blocked = false ;
195
+ if (allow_em2 && blocked) {
196
+ sleep_manager_unlock_deep_sleep ();
197
+ blocked = false ;
198
+ } else if (!blocked) {
199
+ sleep_manager_lock_deep_sleep ();
200
+ blocked = true ;
207
201
}
208
202
}
209
203
You can’t perform that action at this time.
0 commit comments