GIU\ZF
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Fork of rtos_basic by
main.cpp@16:0ada6cbd41e2, 2018-03-27 (annotated)
- Committer:
- ihexx
- Date:
- Tue Mar 27 22:03:07 2018 +0000
- Revision:
- 16:0ada6cbd41e2
- Parent:
- 15:524de2b2ef8e
- Child:
- 17:a29ce6fc667c
completed task merging of carSim, getControls, and engine switch;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ihexx | 12:90b5d8eae5ec | 1 | #include "core.h" |
ihexx | 12:90b5d8eae5ec | 2 | |
ihexx | 12:90b5d8eae5ec | 3 | DigitalOut led1(LED3); |
ihexx | 15:524de2b2ef8e | 4 | Thread thread; |
ihexx | 12:90b5d8eae5ec | 5 | |
ihexx | 12:90b5d8eae5ec | 6 | //Merge tasks with same frequency |
ihexx | 12:90b5d8eae5ec | 7 | namespace runTimeParams{ |
ihexx | 12:90b5d8eae5ec | 8 | Mutex liveAccess; |
ihexx | 12:90b5d8eae5ec | 9 | float brakeForce = 0.0f; |
ihexx | 12:90b5d8eae5ec | 10 | float accelForce = 0.0f; |
ihexx | 16:0ada6cbd41e2 | 11 | float newSpeed = 0.0f; |
ihexx | 12:90b5d8eae5ec | 12 | float avgSpeed = 0.0f; |
ihexx | 12:90b5d8eae5ec | 13 | float odometer = 0.0f; |
ihexx | 16:0ada6cbd41e2 | 14 | |
ihexx | 12:90b5d8eae5ec | 15 | #if DEBUG_MODE |
ihexx | 14:8a6c20435523 | 16 | string debugLog = "task,execution_time_ms,lastSleep,drift\n\r"; |
ihexx | 12:90b5d8eae5ec | 17 | #endif |
ihexx | 12:90b5d8eae5ec | 18 | } |
ihexx | 12:90b5d8eae5ec | 19 | |
ihexx | 13:ab52f46c98ab | 20 | int init(){ |
ihexx | 13:ab52f46c98ab | 21 | //Start task hotloops |
ihexx | 13:ab52f46c98ab | 22 | task_group_1::thread.start(task_group_1::runTask); |
ihexx | 15:524de2b2ef8e | 23 | task_group_2::thread.start(task_group_2::runTask); |
ihexx | 13:ab52f46c98ab | 24 | enqueueMail::thread.start(enqueueMail::runTask); |
ihexx | 13:ab52f46c98ab | 25 | dequeueMail::thread.start(dequeueMail::runTask); |
ihexx | 12:90b5d8eae5ec | 26 | return 0; |
ihexx | 12:90b5d8eae5ec | 27 | } |
emilmont | 1:491820ee784d | 28 | |
ihexx | 15:524de2b2ef8e | 29 | |
emilmont | 1:491820ee784d | 30 | |
emilmont | 1:491820ee784d | 31 | int main() { |
ihexx | 12:90b5d8eae5ec | 32 | init(); |
emilmont | 1:491820ee784d | 33 | |
emilmont | 1:491820ee784d | 34 | while (true) { |
emilmont | 1:491820ee784d | 35 | led1 = !led1; |
mbed_official | 11:0309bef74ba8 | 36 | Thread::wait(500); |
emilmont | 1:491820ee784d | 37 | } |
emilmont | 1:491820ee784d | 38 | } |