Skip to content

Commit 8952379

Browse files
committed
USBMSD: greatly reduce CPU occupation
1 parent 6c36b42 commit 8952379

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

libraries/USBMSD/PluggableUSBMSD.h

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ class USBMSD: public internal::PluggableUSBModule {
268268

269269
// Interrupt to thread deferral
270270
events::PolledQueue _queue;
271+
rtos::EventFlags _data_available;
271272
events::Task<void()> _in_task;
272273
events::Task<void()> _out_task;
273274
mbed::Callback<void()> _reset_task;

libraries/USBMSD/USBMSD.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ void USBMSD::process()
185185
{
186186
while (1) {
187187
if (_initialized) {
188+
_data_available.wait_any(0xFF, 10);
188189
_queue.dispatch();
189190
//yield();
190191
}
@@ -249,11 +250,13 @@ int USBMSD::disk_status()
249250

250251
void USBMSD::_isr_out()
251252
{
253+
_data_available.set(1);
252254
_out_task.call();
253255
}
254256

255257
void USBMSD::_isr_in()
256258
{
259+
_data_available.set(1);
257260
_in_task.call();
258261
}
259262

0 commit comments

Comments
 (0)