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@9:d1fc0805ec7d, 2015-10-14 (annotated)
- Committer:
- shimogamo
- Date:
- Wed Oct 14 13:44:32 2015 +0000
- Revision:
- 9:d1fc0805ec7d
- Parent:
- 8:ca92cb674004
- Child:
- 10:0a4bf8c82493
Init??????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimogamo | 9:d1fc0805ec7d | 1 | //@todo ソフトウェアシリアルの確認 |
shimogamo | 8:ca92cb674004 | 2 | |
shimogamo | 8:ca92cb674004 | 3 | //@todo androidとの通信 |
shimogamo | 8:ca92cb674004 | 4 | //@todo xbeeとの通信 |
shimogamo | 8:ca92cb674004 | 5 | |
shimogamo | 8:ca92cb674004 | 6 | //@todo 高度計の追加 |
shimogamo | 8:ca92cb674004 | 7 | |
shimogamo | 0:2a15bd367891 | 8 | #include "mbed.h" |
shimogamo | 0:2a15bd367891 | 9 | #include "rtos.h" |
shimogamo | 0:2a15bd367891 | 10 | #include "Global.h" |
shimogamo | 9:d1fc0805ec7d | 11 | #include "Init.h" |
shimogamo | 0:2a15bd367891 | 12 | #include "ServoManager.h" |
shimogamo | 0:2a15bd367891 | 13 | #include "ControllerManager.h" |
shimogamo | 0:2a15bd367891 | 14 | #include "Trim.h" |
shimogamo | 0:2a15bd367891 | 15 | #include "Cadence.h" |
shimogamo | 0:2a15bd367891 | 16 | #include "Airspeed.h" |
shimogamo | 0:2a15bd367891 | 17 | #include "Altitude.h" |
shimogamo | 0:2a15bd367891 | 18 | #include "Display.h" |
shimogamo | 0:2a15bd367891 | 19 | #include "XBee.h" |
shimogamo | 5:9a1ec02229dd | 20 | |
shimogamo | 5:9a1ec02229dd | 21 | |
shimogamo | 5:9a1ec02229dd | 22 | RawSerial pc(USBTX, USBRX); |
shimogamo | 0:2a15bd367891 | 23 | |
shimogamo | 0:2a15bd367891 | 24 | |
shimogamo | 0:2a15bd367891 | 25 | Display display(p9, p10); |
shimogamo | 0:2a15bd367891 | 26 | XBee xbee(p13, p14); |
shimogamo | 8:ca92cb674004 | 27 | Trim trim(p16, p17); |
shimogamo | 0:2a15bd367891 | 28 | ControllerManager controllerManager(p18,p19,p20); |
shimogamo | 0:2a15bd367891 | 29 | ServoManager servoManager(p21, p22); |
shimogamo | 0:2a15bd367891 | 30 | Airspeed airspeed(p26, NC, NC); |
shimogamo | 0:2a15bd367891 | 31 | Cadence cadence(p29, p30, NC); |
shimogamo | 0:2a15bd367891 | 32 | |
shimogamo | 0:2a15bd367891 | 33 | |
shimogamo | 5:9a1ec02229dd | 34 | void pc_rx(){ |
shimogamo | 5:9a1ec02229dd | 35 | while(pc.readable()==1){ |
shimogamo | 9:d1fc0805ec7d | 36 | char buf = (char)pc.getc(); |
shimogamo | 9:d1fc0805ec7d | 37 | Global::queue.put((char*)buf); |
shimogamo | 0:2a15bd367891 | 38 | } |
shimogamo | 0:2a15bd367891 | 39 | } |
shimogamo | 0:2a15bd367891 | 40 | |
shimogamo | 5:9a1ec02229dd | 41 | |
shimogamo | 9:d1fc0805ec7d | 42 | |
shimogamo | 9:d1fc0805ec7d | 43 | void initializeTask(void const *pvParameters){ |
shimogamo | 5:9a1ec02229dd | 44 | while(1){ |
shimogamo | 9:d1fc0805ec7d | 45 | Init::getSerial(); |
shimogamo | 5:9a1ec02229dd | 46 | } |
shimogamo | 5:9a1ec02229dd | 47 | } |
shimogamo | 5:9a1ec02229dd | 48 | |
shimogamo | 0:2a15bd367891 | 49 | void controlTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 50 | while(1){ |
shimogamo | 2:e0f1e8662b8c | 51 | trim.update(); |
shimogamo | 0:2a15bd367891 | 52 | controllerManager.update(); |
shimogamo | 0:2a15bd367891 | 53 | servoManager.update(); |
shimogamo | 0:2a15bd367891 | 54 | Thread::wait(50); |
shimogamo | 0:2a15bd367891 | 55 | } |
shimogamo | 0:2a15bd367891 | 56 | } |
shimogamo | 0:2a15bd367891 | 57 | |
shimogamo | 0:2a15bd367891 | 58 | void airspeedTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 59 | while(1){ |
shimogamo | 0:2a15bd367891 | 60 | airspeed.update(); |
shimogamo | 9:d1fc0805ec7d | 61 | Thread::wait(500); |
shimogamo | 0:2a15bd367891 | 62 | } |
shimogamo | 0:2a15bd367891 | 63 | } |
shimogamo | 0:2a15bd367891 | 64 | |
shimogamo | 0:2a15bd367891 | 65 | void cadenceTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 66 | while(1){ |
shimogamo | 0:2a15bd367891 | 67 | cadence.update(); |
shimogamo | 9:d1fc0805ec7d | 68 | Thread::wait(500); |
shimogamo | 0:2a15bd367891 | 69 | } |
shimogamo | 0:2a15bd367891 | 70 | } |
shimogamo | 0:2a15bd367891 | 71 | |
shimogamo | 0:2a15bd367891 | 72 | void displayTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 73 | while(1){ |
shimogamo | 0:2a15bd367891 | 74 | display.update(); |
shimogamo | 9:d1fc0805ec7d | 75 | Thread::wait(500); |
shimogamo | 0:2a15bd367891 | 76 | } |
shimogamo | 0:2a15bd367891 | 77 | } |
shimogamo | 0:2a15bd367891 | 78 | |
shimogamo | 0:2a15bd367891 | 79 | void xbeeTask(void const *pvParameters){ |
shimogamo | 0:2a15bd367891 | 80 | while(1){ |
shimogamo | 0:2a15bd367891 | 81 | xbee.update(); |
shimogamo | 9:d1fc0805ec7d | 82 | Thread::wait(500); |
shimogamo | 0:2a15bd367891 | 83 | } |
shimogamo | 0:2a15bd367891 | 84 | } |
shimogamo | 0:2a15bd367891 | 85 | |
shimogamo | 0:2a15bd367891 | 86 | |
shimogamo | 0:2a15bd367891 | 87 | int main(void){ |
shimogamo | 0:2a15bd367891 | 88 | printf("start\n"); |
shimogamo | 5:9a1ec02229dd | 89 | |
shimogamo | 5:9a1ec02229dd | 90 | pc.attach(pc_rx,Serial::RxIrq); |
shimogamo | 5:9a1ec02229dd | 91 | |
shimogamo | 6:0d9fa7152934 | 92 | Global::initialize(); |
shimogamo | 5:9a1ec02229dd | 93 | Thread InitializeTask(initializeTask); |
shimogamo | 9:d1fc0805ec7d | 94 | Thread ControlTask(controlTask, NULL, osPriorityRealtime); |
shimogamo | 0:2a15bd367891 | 95 | Thread AirspeedTask(airspeedTask); |
shimogamo | 0:2a15bd367891 | 96 | Thread CadenceTask(cadenceTask); |
shimogamo | 0:2a15bd367891 | 97 | Thread DisplayTask(displayTask); |
shimogamo | 0:2a15bd367891 | 98 | Thread XbeeTask(xbeeTask); |
shimogamo | 0:2a15bd367891 | 99 | printf("Task end\n"); |
shimogamo | 0:2a15bd367891 | 100 | |
shimogamo | 0:2a15bd367891 | 101 | Thread::wait(osWaitForever); |
shimogamo | 0:2a15bd367891 | 102 | } |