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.
RTOS-Setup/src/tasks.cpp@51:04c6af4319e1, 2014-05-19 (annotated)
- Committer:
- pHysiX
- Date:
- Mon May 19 15:30:05 2014 +0000
- Revision:
- 51:04c6af4319e1
- Parent:
- 50:8a0accb23007
Code rearranged into threads. Timer reserved for time critical routines only. Implemented working semaphore and mutex
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pHysiX | 22:ef8aa9728013 | 1 | /* File: tasks.h |
pHysiX | 22:ef8aa9728013 | 2 | * Author: Trung Tin Ian HUA |
pHysiX | 22:ef8aa9728013 | 3 | * Date: May 2014 |
pHysiX | 22:ef8aa9728013 | 4 | * Purpose: Code to intialise and start all threads. |
pHysiX | 22:ef8aa9728013 | 5 | */ |
pHysiX | 1:43f8ac7ca6d7 | 6 | #include "tasks.h" |
pHysiX | 1:43f8ac7ca6d7 | 7 | #include "setup.h" |
pHysiX | 1:43f8ac7ca6d7 | 8 | |
pHysiX | 51:04c6af4319e1 | 9 | Mutex mutex_i2c; |
pHysiX | 51:04c6af4319e1 | 10 | |
pHysiX | 3:605fbcb54e75 | 11 | void createThreads(void) |
pHysiX | 1:43f8ac7ca6d7 | 12 | { |
pHysiX | 51:04c6af4319e1 | 13 | /* Create timer callbacks */ |
pHysiX | 51:04c6af4319e1 | 14 | RtosTimer thread2Slave_ISR(Task2_Slave_ISR, osTimerPeriodic, NULL); |
pHysiX | 51:04c6af4319e1 | 15 | thread2Slave_ISR.start(TASK2_SLAVE_PERIOD); |
pHysiX | 50:8a0accb23007 | 16 | |
pHysiX | 50:8a0accb23007 | 17 | RtosTimer thread2Master_ISR(Task2_Master_ISR, osTimerPeriodic, NULL); |
pHysiX | 50:8a0accb23007 | 18 | thread2Master_ISR.start(TASK2_MASTER_PERIOD); |
pHysiX | 50:8a0accb23007 | 19 | |
pHysiX | 51:04c6af4319e1 | 20 | RtosTimer thread3(Task3, osTimerPeriodic, NULL); |
pHysiX | 51:04c6af4319e1 | 21 | thread3.start(TASK3_PERIOD); |
pHysiX | 51:04c6af4319e1 | 22 | |
pHysiX | 51:04c6af4319e1 | 23 | //RtosTimer thread4(Task4, osTimerPeriodic, NULL); |
pHysiX | 51:04c6af4319e1 | 24 | //thread4.start(TASK4_PERIOD); |
pHysiX | 50:8a0accb23007 | 25 | |
pHysiX | 51:04c6af4319e1 | 26 | /* Create threads */ |
pHysiX | 51:04c6af4319e1 | 27 | Thread thread1(Task1, NULL, osPriorityIdle); |
pHysiX | 51:04c6af4319e1 | 28 | Thread thread2Slave(Task2_Slave, NULL, osPriorityRealtime); |
pHysiX | 51:04c6af4319e1 | 29 | Thread thread2Master(Task2_Master, NULL, osPriorityHigh); |
pHysiX | 51:04c6af4319e1 | 30 | Thread thread4(Task4, NULL, osPriorityRealtime); |
pHysiX | 21:b642c18eccd1 | 31 | |
pHysiX | 3:605fbcb54e75 | 32 | /* Execute state machine forever */ |
pHysiX | 3:605fbcb54e75 | 33 | Thread::wait(osWaitForever); |
pHysiX | 1:43f8ac7ca6d7 | 34 | } |