Ian Hua / Quadcopter-mbedRTOS

RTOS-Setup/src/tasks.cpp

Committer:
pHysiX
Date:
2014-05-19
Revision:
50:8a0accb23007
Parent:
48:9dbdc4144f00
Child:
51:04c6af4319e1

File content as of revision 50:8a0accb23007:

/* File:    tasks.h
 * Author:  Trung Tin Ian HUA
 * Date:    May 2014
 * Purpose: Code to intialise and start all threads.
 */
#include "tasks.h"
#include "setup.h"

void createThreads(void)
{
    /* Create threads */
    Thread thread1(Task1, NULL, osPriorityIdle);
    Thread thread2Master(Task2_Master, NULL, osPriorityHigh);
    Thread thread2Slave(Task2_Slave, NULL, osPriorityRealtime);
    //Thread thread4(Task4, NULL, osPriorityRealtime);
    
    /* Create timer callbacks */
    RtosTimer thread2Master_ISR(Task2_Master_ISR, osTimerPeriodic, NULL);
    thread2Master_ISR.start(TASK2_MASTER_PERIOD);
    
    RtosTimer thread2Slave_ISR(Task2_Slave_ISR, osTimerPeriodic, NULL);
    thread2Slave_ISR.start(TASK2_SLAVE_PERIOD);
    
    RtosTimer thread3_ISR(Task3, osTimerPeriodic, NULL);
    thread3_ISR.start(TASK3_PERIOD);
    
    RtosTimer thread4(Task4, osTimerPeriodic, NULL);
    thread4.start(TASK4_PERIOD);

    /* Execute state machine forever */
    Thread::wait(osWaitForever);
}