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@0:8c28fac22d27, 2014-04-29 (annotated)
- Committer:
- pHysiX
- Date:
- Tue Apr 29 10:36:33 2014 +0000
- Revision:
- 0:8c28fac22d27
- Child:
- 2:ab967d7b4346
MPU6050: DMP, RTOS
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 | 0:8c28fac22d27 | 8 | bool error = false; |
| pHysiX | 0:8c28fac22d27 | 9 | |
| pHysiX | 0:8c28fac22d27 | 10 | /* Setup devices */ |
| pHysiX | 0:8c28fac22d27 | 11 | if (setup_led()) |
| pHysiX | 0:8c28fac22d27 | 12 | error = false; |
| pHysiX | 0:8c28fac22d27 | 13 | else |
| pHysiX | 0:8c28fac22d27 | 14 | error = true; |
| pHysiX | 0:8c28fac22d27 | 15 | |
| pHysiX | 0:8c28fac22d27 | 16 | if (setup_bt()) { |
| pHysiX | 0:8c28fac22d27 | 17 | error = false; |
| pHysiX | 0:8c28fac22d27 | 18 | BT.printf("test\n"); |
| pHysiX | 0:8c28fac22d27 | 19 | } |
| pHysiX | 0:8c28fac22d27 | 20 | else |
| pHysiX | 0:8c28fac22d27 | 21 | error = true; |
| pHysiX | 0:8c28fac22d27 | 22 | |
| pHysiX | 0:8c28fac22d27 | 23 | if (setup_mpu6050()) { |
| pHysiX | 0:8c28fac22d27 | 24 | error = false; |
| pHysiX | 0:8c28fac22d27 | 25 | BT.printf("Setup done!\n"); |
| pHysiX | 0:8c28fac22d27 | 26 | } |
| pHysiX | 0:8c28fac22d27 | 27 | else error = true; |
| pHysiX | 0:8c28fac22d27 | 28 | |
| pHysiX | 0:8c28fac22d27 | 29 | if (!error) { |
| pHysiX | 0:8c28fac22d27 | 30 | /* Create threads */ |
| pHysiX | 0:8c28fac22d27 | 31 | RtosTimer thread1(Task1, osTimerPeriodic, NULL); |
| pHysiX | 0:8c28fac22d27 | 32 | RtosTimer thread2(Task2, osTimerPeriodic, NULL); |
| pHysiX | 0:8c28fac22d27 | 33 | RtosTimer thread3(Task3, osTimerPeriodic, (void *)0); |
| pHysiX | 0:8c28fac22d27 | 34 | //RtosTimer thread4(Task4, osTimerPeriodic, (void *)0); |
| pHysiX | 0:8c28fac22d27 | 35 | |
| pHysiX | 0:8c28fac22d27 | 36 | /* Start threads */ |
| pHysiX | 0:8c28fac22d27 | 37 | thread1.start(TASK1_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 38 | thread2.start(TASK2_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 39 | thread3.start(TASK3_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 40 | //thread4.start(TASK4_PERIOD); |
| pHysiX | 0:8c28fac22d27 | 41 | |
| pHysiX | 0:8c28fac22d27 | 42 | /* Execute state machine forever */ |
| pHysiX | 0:8c28fac22d27 | 43 | Thread::wait(osWaitForever); |
| pHysiX | 0:8c28fac22d27 | 44 | } else { |
| pHysiX | 0:8c28fac22d27 | 45 | imu.debugSerial.printf("Setup failed!\n"); |
| pHysiX | 0:8c28fac22d27 | 46 | return 0; |
| pHysiX | 0:8c28fac22d27 | 47 | } |
| pHysiX | 0:8c28fac22d27 | 48 | } |