use the thread the control 3 leds

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

Committer:
shiyilei
Date:
Mon Oct 27 04:35:25 2014 +0000
Revision:
7:c3d06470b694
Parent:
3:c92e21f305d8
use the thread the control 3 leds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 7:c3d06470b694 1 /*********************************************
shiyilei 7:c3d06470b694 2 *file name : the first thread app
shiyilei 7:c3d06470b694 3 *Creator :JacobShi
shiyilei 7:c3d06470b694 4 *Time:2014/10/27
shiyilei 7:c3d06470b694 5 * Description :use the thread the control 3 leds
shiyilei 7:c3d06470b694 6 ******************************************/
emilmont 1:491820ee784d 7 #include "mbed.h"
emilmont 1:491820ee784d 8 #include "rtos.h"
emilmont 1:491820ee784d 9 DigitalOut led1(LED1);
emilmont 1:491820ee784d 10 DigitalOut led2(LED2);
shiyilei 7:c3d06470b694 11 DigitalOut led3(LED3);
shiyilei 7:c3d06470b694 12 void led1_task(void const* args)
shiyilei 7:c3d06470b694 13 {
shiyilei 7:c3d06470b694 14 while(1)
shiyilei 7:c3d06470b694 15 {
shiyilei 7:c3d06470b694 16 led1=!led1;
shiyilei 7:c3d06470b694 17 Thread::wait(500);
shiyilei 7:c3d06470b694 18
emilmont 1:491820ee784d 19 }
emilmont 1:491820ee784d 20 }
shiyilei 7:c3d06470b694 21
shiyilei 7:c3d06470b694 22 void led2_task(void const* args)
shiyilei 7:c3d06470b694 23 {
shiyilei 7:c3d06470b694 24 while(1)
shiyilei 7:c3d06470b694 25 {
shiyilei 7:c3d06470b694 26 led2=!led2;
shiyilei 7:c3d06470b694 27 Thread::wait(1000);
shiyilei 7:c3d06470b694 28 }
shiyilei 7:c3d06470b694 29
emilmont 1:491820ee784d 30 }
shiyilei 7:c3d06470b694 31
shiyilei 7:c3d06470b694 32 void led3_task(void const*args)
shiyilei 7:c3d06470b694 33 {
shiyilei 7:c3d06470b694 34 while(1)
shiyilei 7:c3d06470b694 35 {
shiyilei 7:c3d06470b694 36 led3=!led3;
shiyilei 7:c3d06470b694 37 Thread::wait(250);
shiyilei 7:c3d06470b694 38 }
shiyilei 7:c3d06470b694 39
shiyilei 7:c3d06470b694 40 }
shiyilei 7:c3d06470b694 41
shiyilei 7:c3d06470b694 42
shiyilei 7:c3d06470b694 43 int main(void)
shiyilei 7:c3d06470b694 44 {
shiyilei 7:c3d06470b694 45
shiyilei 7:c3d06470b694 46 Thread led1_thread1(led1_task);
shiyilei 7:c3d06470b694 47 Thread led2_thread2(led2_task);
shiyilei 7:c3d06470b694 48 Thread led3_thread3(led3_task);
shiyilei 7:c3d06470b694 49
shiyilei 7:c3d06470b694 50 while(1)
shiyilei 7:c3d06470b694 51 {
shiyilei 7:c3d06470b694 52
shiyilei 7:c3d06470b694 53
shiyilei 7:c3d06470b694 54 }
shiyilei 7:c3d06470b694 55 }