GIU\ZF

Dependencies:   MCP23017 WattBob_TextLCD mbed-rtos mbed

Fork of rtos_basic by mbed official

Committer:
ihexx
Date:
Wed Mar 28 14:34:34 2018 +0000
Revision:
20:202e0046527e
Parent:
18:d48324fd3440
LAST MINUTE CHJECKS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ihexx 18:d48324fd3440 1 /*
ihexx 18:d48324fd3440 2 RTOS car interface model. See readme.md
ihexx 18:d48324fd3440 3 Author: Gershom Agim | H00175564
ihexx 18:d48324fd3440 4 2018
ihexx 18:d48324fd3440 5 */
ihexx 12:90b5d8eae5ec 6 #include "core.h"
ihexx 12:90b5d8eae5ec 7
ihexx 15:524de2b2ef8e 8 Thread thread;
ihexx 12:90b5d8eae5ec 9
ihexx 18:d48324fd3440 10
ihexx 12:90b5d8eae5ec 11 namespace runTimeParams{
ihexx 18:d48324fd3440 12 //Global variables contended by (almost) all tasks
ihexx 12:90b5d8eae5ec 13 Mutex liveAccess;
ihexx 12:90b5d8eae5ec 14 float brakeForce = 0.0f;
ihexx 12:90b5d8eae5ec 15 float accelForce = 0.0f;
ihexx 17:a29ce6fc667c 16 float speed[3] = {0.0f};
ihexx 12:90b5d8eae5ec 17 float avgSpeed = 0.0f;
ihexx 12:90b5d8eae5ec 18 float odometer = 0.0f;
ihexx 16:0ada6cbd41e2 19
ihexx 12:90b5d8eae5ec 20 #if DEBUG_MODE
ihexx 18:d48324fd3440 21 //Debug logs: double buffer so printing to pc doesn't hold up
ihexx 18:d48324fd3440 22 //tasks attempting to log
ihexx 17:a29ce6fc667c 23 Mutex debugAccess;
ihexx 17:a29ce6fc667c 24 string debugLogBuffer1 = "task,execution_time_ms,lastSleep,drift\n\r";
ihexx 17:a29ce6fc667c 25 string debugLogBuffer2 = "";
ihexx 17:a29ce6fc667c 26 string * debugLog = &debugLogBuffer1;
ihexx 12:90b5d8eae5ec 27 #endif
ihexx 18:d48324fd3440 28 }
ihexx 18:d48324fd3440 29
ihexx 18:d48324fd3440 30 int main() {
ihexx 18:d48324fd3440 31 //Launch threads
ihexx 13:ab52f46c98ab 32 task_group_1::thread.start(task_group_1::runTask);
ihexx 15:524de2b2ef8e 33 task_group_2::thread.start(task_group_2::runTask);
ihexx 13:ab52f46c98ab 34 enqueueMail::thread.start(enqueueMail::runTask);
ihexx 13:ab52f46c98ab 35 dequeueMail::thread.start(dequeueMail::runTask);
emilmont 1:491820ee784d 36
emilmont 1:491820ee784d 37 while (true) {
ihexx 18:d48324fd3440 38 //indicate program still running
ihexx 20:202e0046527e 39 //led1 = !led1;
mbed_official 11:0309bef74ba8 40 Thread::wait(500);
emilmont 1:491820ee784d 41 }
emilmont 1:491820ee784d 42 }