GIU\ZF
Dependencies: MCP23017 WattBob_TextLCD mbed-rtos mbed
Fork of rtos_basic by
main.cpp@15:524de2b2ef8e, 2018-03-27 (annotated)
- Committer:
- ihexx
- Date:
- Tue Mar 27 18:55:43 2018 +0000
- Revision:
- 15:524de2b2ef8e
- Parent:
- 14:8a6c20435523
- Child:
- 16:0ada6cbd41e2
Created and tested basic car simulator; scheduled accel/brake controls
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); |
emilmont | 1:491820ee784d | 4 | DigitalOut led2(LED2); |
ihexx | 15:524de2b2ef8e | 5 | Thread thread; |
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 | 15:524de2b2ef8e | 14 | float newSpeed = 0.0f; |
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 | } |