-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17 in progress, additional board for mbed5 non-rtos testing.
- Loading branch information
dave
committed
Dec 3, 2020
1 parent
2840e53
commit 8461c14
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// This is an example of using mbed 5 without RTOS support | ||
// It demonstrates raising a few tasks for scheduling and an interrupt based event. | ||
// | ||
|
||
#include <TaskManagerIO.h> | ||
|
||
bool taskRunning = true; | ||
taskid_t millisJob; | ||
|
||
Serial serPort(USBTX, USBRX); | ||
|
||
void log(const char* toLog) { | ||
char sz[14]; | ||
itoa(millis(), sz, 10); | ||
serPort.write(sz, strlen(sz)); | ||
serPort.write(toLog, strlen(toLog)); | ||
} | ||
|
||
void setup() { | ||
serPort.baud(115200); | ||
taskManager.scheduleFixedRate(1, [] { | ||
log("One second job"); | ||
}, TIME_SECONDS); | ||
|
||
millisJob = taskManager.scheduleFixedRate(100, [] { | ||
log("1/10th sec"); | ||
}); | ||
|
||
taskManager.scheduleFixedRate(10, [] { | ||
log("Ten seconds up, remove millisecond job"); | ||
taskManager.cancelTask(millisJob); | ||
}, TIME_SECONDS); | ||
} | ||
|
||
int main() { | ||
setup(); | ||
|
||
while(taskRunning) { | ||
taskManager.runLoop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters