GIU\ZF

Dependencies:   MCP23017 WattBob_TextLCD mbed-rtos mbed

Fork of rtos_basic by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 RTOS car interface model. See readme.md
00003 Author: Gershom Agim | H00175564
00004 2018
00005 */
00006 #include "core.h"
00007 
00008 Thread thread;
00009 
00010 
00011 namespace runTimeParams{
00012     //Global variables contended by (almost) all tasks
00013     Mutex liveAccess;
00014     float brakeForce = 0.0f;
00015     float accelForce = 0.0f;
00016     float speed[3] = {0.0f};
00017     float avgSpeed = 0.0f;
00018     float odometer = 0.0f;
00019     
00020     #if DEBUG_MODE
00021     //Debug logs: double buffer so printing to pc doesn't hold up
00022     //tasks attempting to log
00023     Mutex debugAccess;
00024     string debugLogBuffer1 = "task,execution_time_ms,lastSleep,drift\n\r";
00025     string debugLogBuffer2 = "";
00026     string * debugLog = &debugLogBuffer1;
00027     #endif
00028 }
00029  
00030 int main() {
00031     //Launch threads
00032     task_group_1::thread.start(task_group_1::runTask);
00033     task_group_2::thread.start(task_group_2::runTask);
00034     enqueueMail::thread.start(enqueueMail::runTask);
00035     dequeueMail::thread.start(dequeueMail::runTask);
00036     
00037     while (true) {
00038         //indicate program still running
00039         //led1 = !led1;
00040         Thread::wait(500);
00041     }
00042 }