GIU\ZF

Dependencies:   MCP23017 WattBob_TextLCD mbed-rtos mbed

Fork of rtos_basic by mbed official

Committer:
ihexx
Date:
Tue Mar 27 16:11:18 2018 +0000
Revision:
14:8a6c20435523
Parent:
13:ab52f46c98ab
Child:
15:524de2b2ef8e
fixed debug framework

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ihexx 12:90b5d8eae5ec 1 #include "core.h"
ihexx 12:90b5d8eae5ec 2
ihexx 12:90b5d8eae5ec 3 DigitalOut led1(LED3);
emilmont 1:491820ee784d 4 DigitalOut led2(LED2);
ihexx 12:90b5d8eae5ec 5 Thread thread,thread_group_2HZ,thread_group_1HZ;
ihexx 12:90b5d8eae5ec 6
ihexx 12:90b5d8eae5ec 7 //Merge tasks with same frequency
ihexx 12:90b5d8eae5ec 8 namespace runTimeParams{
ihexx 12:90b5d8eae5ec 9 Mutex liveAccess;
ihexx 12:90b5d8eae5ec 10 float brakeForce = 0.0f;
ihexx 12:90b5d8eae5ec 11 float accelForce = 0.0f;
ihexx 12:90b5d8eae5ec 12 float avgSpeed = 0.0f;
ihexx 12:90b5d8eae5ec 13 float odometer = 0.0f;
ihexx 12:90b5d8eae5ec 14 #if DEBUG_MODE
ihexx 14:8a6c20435523 15 string debugLog = "task,execution_time_ms,lastSleep,drift\n\r";
ihexx 12:90b5d8eae5ec 16 #endif
ihexx 12:90b5d8eae5ec 17 }
ihexx 12:90b5d8eae5ec 18
ihexx 13:ab52f46c98ab 19 int init(){
ihexx 13:ab52f46c98ab 20 //Start task hotloops
ihexx 13:ab52f46c98ab 21 task_group_1::thread.start(task_group_1::runTask);
ihexx 13:ab52f46c98ab 22 enqueueMail::thread.start(enqueueMail::runTask);
ihexx 13:ab52f46c98ab 23 dequeueMail::thread.start(dequeueMail::runTask);
ihexx 12:90b5d8eae5ec 24
ihexx 12:90b5d8eae5ec 25 // getControls::thread.start(getControls::runTask);
ihexx 12:90b5d8eae5ec 26 return 0;
ihexx 12:90b5d8eae5ec 27 }
emilmont 1:491820ee784d 28
geky 7:8d9919175929 29 void led2_thread() {
emilmont 1:491820ee784d 30 while (true) {
emilmont 1:491820ee784d 31 led2 = !led2;
mbed_official 11:0309bef74ba8 32 Thread::wait(1000);
emilmont 1:491820ee784d 33 }
emilmont 1:491820ee784d 34 }
emilmont 1:491820ee784d 35
emilmont 1:491820ee784d 36 int main() {
ihexx 12:90b5d8eae5ec 37 init();
geky 7:8d9919175929 38 thread.start(led2_thread);
emilmont 1:491820ee784d 39
emilmont 1:491820ee784d 40 while (true) {
emilmont 1:491820ee784d 41 led1 = !led1;
mbed_official 11:0309bef74ba8 42 Thread::wait(500);
emilmont 1:491820ee784d 43 }
emilmont 1:491820ee784d 44 }