Ian Hua / Quadcopter-mbedRTOS

main.cpp

Committer:
pHysiX
Date:
2014-04-29
Revision:
0:8c28fac22d27
Child:
2:ab967d7b4346

File content as of revision 0:8c28fac22d27:

#include "mbed.h"
#include "rtos.h"
#include "setup.h"
#include "tasks.h"

int main(void)
{
    bool error = false;
    
    /* Setup devices */
    if (setup_led())
        error = false;
    else
        error = true;

    if (setup_bt()) {
        error = false;
        BT.printf("test\n");
        }
    else
        error = true;
        
    if (setup_mpu6050()) {
        error = false;
        BT.printf("Setup done!\n");
        }
    else error = true;

    if (!error) {
        /* Create threads */
        RtosTimer thread1(Task1, osTimerPeriodic, NULL);
        RtosTimer thread2(Task2, osTimerPeriodic, NULL);
        RtosTimer thread3(Task3, osTimerPeriodic, (void *)0);
        //RtosTimer thread4(Task4, osTimerPeriodic, (void *)0);

        /* Start threads */
        thread1.start(TASK1_PERIOD);
        thread2.start(TASK2_PERIOD);
        thread3.start(TASK3_PERIOD);
        //thread4.start(TASK4_PERIOD);

        /* Execute state machine forever */
        Thread::wait(osWaitForever);
    } else {
        imu.debugSerial.printf("Setup failed!\n");
        return 0;
    }
}