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:ab967d7b4346, 2014-04-29 (annotated)
- Committer:
- pHysiX
- Date:
- Tue Apr 29 11:43:32 2014 +0000
- Revision:
- 2:ab967d7b4346
- Parent:
- 0:8c28fac22d27
- Child:
- 3:605fbcb54e75
Added in simple ESC initialise
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pHysiX | 0:8c28fac22d27 | 1 | #include "mbed.h" |
| pHysiX | 0:8c28fac22d27 | 2 | #include "rtos.h" |
| pHysiX | 0:8c28fac22d27 | 3 | #include "setup.h" |
| pHysiX | 0:8c28fac22d27 | 4 | #include "tasks.h" |
| pHysiX | 0:8c28fac22d27 | 5 | |
| pHysiX | 0:8c28fac22d27 | 6 | int main(void) |
| pHysiX | 0:8c28fac22d27 | 7 | { |
| pHysiX | 2:ab967d7b4346 | 8 | imu.debugSerial.baud(115200); |
| pHysiX | 2:ab967d7b4346 | 9 | imu.debugSerial.printf("hello\n"); |
| pHysiX | 0:8c28fac22d27 | 10 | bool error = false; |
| pHysiX | 2:ab967d7b4346 | 11 | |
| pHysiX | 0:8c28fac22d27 | 12 | /* Setup devices */ |
| pHysiX | 2:ab967d7b4346 | 13 | if (setup_ESC()) |
| pHysiX | 2:ab967d7b4346 | 14 | error = false; |
| pHysiX | 2:ab967d7b4346 | 15 | else { |
| pHysiX | 2:ab967d7b4346 | 16 | error = true; |
| pHysiX | 2:ab967d7b4346 | 17 | imu.debugSerial.printf("ESC FAILED!!!\n"); |
| pHysiX | 2:ab967d7b4346 | 18 | } |
| pHysiX | 2:ab967d7b4346 | 19 | |
| pHysiX | 0:8c28fac22d27 | 20 | if (setup_led()) |
| pHysiX | 0:8c28fac22d27 | 21 | error = false; |
| pHysiX | 0:8c28fac22d27 | 22 | else |
| pHysiX | 0:8c28fac22d27 | 23 | error = true; |
| pHysiX | 0:8c28fac22d27 | 24 | |
| pHysiX | 0:8c28fac22d27 | 25 | if (setup_bt()) { |
| pHysiX | 0:8c28fac22d27 | 26 | error = false; |
| pHysiX | 2:ab967d7b4346 | 27 | BT.printf("BT established!\n"); |
| pHysiX | 2:ab967d7b4346 | 28 | } else |
| pHysiX | 0:8c28fac22d27 | 29 | error = true; |
| pHysiX | 2:ab967d7b4346 | 30 | |
| pHysiX | 0:8c28fac22d27 | 31 | if (setup_mpu6050()) { |
| pHysiX | 0:8c28fac22d27 | 32 | error = false; |
| pHysiX | 2:ab967d7b4346 | 33 | BT.printf("MPU6050 established!\n"); |
| pHysiX | 2:ab967d7b4346 | 34 | } else error = true; |
| pHysiX | 0:8c28fac22d27 | 35 | |
| pHysiX | 0:8c28fac22d27 | 36 | if (!error) { |
| pHysiX | 2:ab967d7b4346 | 37 | imu.debugSerial.printf("Devices ready!\n"); |
| pHysiX | 0:8c28fac22d27 | 38 | /* Create threads */ |
| pHysiX | 0:8c28fac22d27 | 39 | RtosTimer thread1(Task1, osTimerPeriodic, NULL); |
| pHysiX | 0:8c28fac22d27 | 40 | RtosTimer thread2(Task2, osTimerPeriodic, NULL); |
| pHysiX | 0:8c28fac22d27 | 41 | RtosTimer thread3(Task3, osTimerPeriodic, (void *)0); |
| pHysiX | 2:ab967d7b4346 | 42 | RtosTimer thread4(Task4, osTimerPeriodic, (void *)0); |
| pHysiX | 0:8c28fac22d27 | 43 | |
| pHysiX | 0:8c28fac22d27 | 44 | /* Start threads */ |
| pHysiX | 0:8c28fac22d27 | 45 | thread1.start(TASK1_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 46 | thread2.start(TASK2_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 47 | thread3.start(TASK3_PERIOD); |
| pHysiX | 2:ab967d7b4346 | 48 | thread4.start(TASK4_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 49 | |
| pHysiX | 0:8c28fac22d27 | 50 | /* Execute state machine forever */ |
| pHysiX | 0:8c28fac22d27 | 51 | Thread::wait(osWaitForever); |
| pHysiX | 0:8c28fac22d27 | 52 | } else { |
| pHysiX | 0:8c28fac22d27 | 53 | imu.debugSerial.printf("Setup failed!\n"); |
| pHysiX | 0:8c28fac22d27 | 54 | return 0; |
| pHysiX | 0:8c28fac22d27 | 55 | } |
| pHysiX | 0:8c28fac22d27 | 56 | } |