Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@2:e0f1e8662b8c, 2015-09-28 (annotated)
- Committer:
- shimogamo
- Date:
- Mon Sep 28 10:33:07 2015 +0000
- Revision:
- 2:e0f1e8662b8c
- Parent:
- 0:2a15bd367891
- Child:
- 5:9a1ec02229dd
Standard
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimogamo | 0:2a15bd367891 | 1 | #include "mbed.h" |
shimogamo | 0:2a15bd367891 | 2 | #include "rtos.h" |
shimogamo | 0:2a15bd367891 | 3 | #include "Global.h" |
shimogamo | 0:2a15bd367891 | 4 | #include "ServoManager.h" |
shimogamo | 0:2a15bd367891 | 5 | #include "ControllerManager.h" |
shimogamo | 0:2a15bd367891 | 6 | #include "Trim.h" |
shimogamo | 0:2a15bd367891 | 7 | #include "Cadence.h" |
shimogamo | 0:2a15bd367891 | 8 | #include "Airspeed.h" |
shimogamo | 0:2a15bd367891 | 9 | #include "Altitude.h" |
shimogamo | 0:2a15bd367891 | 10 | #include "Display.h" |
shimogamo | 0:2a15bd367891 | 11 | #include "XBee.h" |
shimogamo | 0:2a15bd367891 | 12 | |
shimogamo | 0:2a15bd367891 | 13 | |
shimogamo | 0:2a15bd367891 | 14 | Display display(p9, p10); |
shimogamo | 0:2a15bd367891 | 15 | XBee xbee(p13, p14); |
shimogamo | 0:2a15bd367891 | 16 | Trim trim(p16, p17, p15); |
shimogamo | 0:2a15bd367891 | 17 | ControllerManager controllerManager(p18,p19,p20); |
shimogamo | 0:2a15bd367891 | 18 | ServoManager servoManager(p21, p22); |
shimogamo | 0:2a15bd367891 | 19 | Airspeed airspeed(p26, NC, NC); |
shimogamo | 0:2a15bd367891 | 20 | Cadence cadence(p29, p30, NC); |
shimogamo | 0:2a15bd367891 | 21 | |
shimogamo | 0:2a15bd367891 | 22 | |
shimogamo | 0:2a15bd367891 | 23 | void initializeTask(void const *pvParametersd){ |
shimogamo | 0:2a15bd367891 | 24 | while(1){ |
shimogamo | 0:2a15bd367891 | 25 | Thread::wait(50); |
shimogamo | 0:2a15bd367891 | 26 | } |
shimogamo | 0:2a15bd367891 | 27 | } |
shimogamo | 0:2a15bd367891 | 28 | |
shimogamo | 0:2a15bd367891 | 29 | void controlTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 30 | while(1){ |
shimogamo | 2:e0f1e8662b8c | 31 | trim.update(); |
shimogamo | 0:2a15bd367891 | 32 | controllerManager.update(); |
shimogamo | 0:2a15bd367891 | 33 | servoManager.update(); |
shimogamo | 0:2a15bd367891 | 34 | Thread::wait(50); |
shimogamo | 0:2a15bd367891 | 35 | } |
shimogamo | 0:2a15bd367891 | 36 | } |
shimogamo | 0:2a15bd367891 | 37 | |
shimogamo | 0:2a15bd367891 | 38 | void airspeedTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 39 | while(1){ |
shimogamo | 0:2a15bd367891 | 40 | airspeed.update(); |
shimogamo | 0:2a15bd367891 | 41 | Thread::wait(200); |
shimogamo | 0:2a15bd367891 | 42 | } |
shimogamo | 0:2a15bd367891 | 43 | } |
shimogamo | 0:2a15bd367891 | 44 | |
shimogamo | 0:2a15bd367891 | 45 | void cadenceTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 46 | while(1){ |
shimogamo | 0:2a15bd367891 | 47 | cadence.update(); |
shimogamo | 0:2a15bd367891 | 48 | Thread::wait(200); |
shimogamo | 0:2a15bd367891 | 49 | } |
shimogamo | 0:2a15bd367891 | 50 | } |
shimogamo | 0:2a15bd367891 | 51 | |
shimogamo | 0:2a15bd367891 | 52 | void displayTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 53 | while(1){ |
shimogamo | 0:2a15bd367891 | 54 | display.update(); |
shimogamo | 0:2a15bd367891 | 55 | Thread::wait(50); |
shimogamo | 0:2a15bd367891 | 56 | } |
shimogamo | 0:2a15bd367891 | 57 | } |
shimogamo | 0:2a15bd367891 | 58 | |
shimogamo | 0:2a15bd367891 | 59 | void xbeeTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 60 | while(1){ |
shimogamo | 0:2a15bd367891 | 61 | xbee.update(); |
shimogamo | 0:2a15bd367891 | 62 | Thread::wait(50); |
shimogamo | 0:2a15bd367891 | 63 | } |
shimogamo | 0:2a15bd367891 | 64 | } |
shimogamo | 0:2a15bd367891 | 65 | |
shimogamo | 0:2a15bd367891 | 66 | |
shimogamo | 0:2a15bd367891 | 67 | int main(void){ |
shimogamo | 0:2a15bd367891 | 68 | printf("start\n"); |
shimogamo | 0:2a15bd367891 | 69 | Global::timer.start(); |
shimogamo | 0:2a15bd367891 | 70 | Thread ControlTask(controlTask); |
shimogamo | 0:2a15bd367891 | 71 | Thread AirspeedTask(airspeedTask); |
shimogamo | 0:2a15bd367891 | 72 | Thread CadenceTask(cadenceTask); |
shimogamo | 0:2a15bd367891 | 73 | Thread DisplayTask(displayTask); |
shimogamo | 0:2a15bd367891 | 74 | Thread XbeeTask(xbeeTask); |
shimogamo | 0:2a15bd367891 | 75 | printf("Task end\n"); |
shimogamo | 0:2a15bd367891 | 76 | |
shimogamo | 0:2a15bd367891 | 77 | Thread::wait(osWaitForever); |
shimogamo | 0:2a15bd367891 | 78 | } |