Skip to content

Commit

Permalink
USBMSD: greatly reduce CPU occupation
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Dec 3, 2020
1 parent 6c36b42 commit 8952379
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions libraries/USBMSD/PluggableUSBMSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class USBMSD: public internal::PluggableUSBModule {

// Interrupt to thread deferral
events::PolledQueue _queue;
rtos::EventFlags _data_available;
events::Task<void()> _in_task;
events::Task<void()> _out_task;
mbed::Callback<void()> _reset_task;
Expand Down
3 changes: 3 additions & 0 deletions libraries/USBMSD/USBMSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void USBMSD::process()
{
while (1) {
if (_initialized) {
_data_available.wait_any(0xFF, 10);
_queue.dispatch();
//yield();
}
Expand Down Expand Up @@ -249,11 +250,13 @@ int USBMSD::disk_status()

void USBMSD::_isr_out()
{
_data_available.set(1);
_out_task.call();
}

void USBMSD::_isr_in()
{
_data_available.set(1);
_in_task.call();
}

Expand Down

0 comments on commit 8952379

Please sign in to comment.