RTOS Example

Dependencies:   mbed-rtos mbed

Committer:
saypulung
Date:
Mon Mar 30 17:20:15 2015 +0000
Revision:
0:837f2afb6c50
Example RTOS on MBED LPC1768

Who changed what in which revision?

UserRevisionLine numberNew contents of line
saypulung 0:837f2afb6c50 1 #include "mbed.h"
saypulung 0:837f2afb6c50 2 #include "rtos.h"
saypulung 0:837f2afb6c50 3 DigitalOut led1(LED1);
saypulung 0:837f2afb6c50 4 DigitalOut led2(LED2);
saypulung 0:837f2afb6c50 5 DigitalOut led3(LED3);
saypulung 0:837f2afb6c50 6 DigitalOut led4(LED4);
saypulung 0:837f2afb6c50 7
saypulung 0:837f2afb6c50 8 void pLED1(void const *args){
saypulung 0:837f2afb6c50 9 while(1)
saypulung 0:837f2afb6c50 10 {
saypulung 0:837f2afb6c50 11 led1 = 1;
saypulung 0:837f2afb6c50 12 Thread::wait(100);
saypulung 0:837f2afb6c50 13 led1 = 0;
saypulung 0:837f2afb6c50 14 Thread::wait(100);
saypulung 0:837f2afb6c50 15 }
saypulung 0:837f2afb6c50 16 }
saypulung 0:837f2afb6c50 17 void pLED2(void const *args){
saypulung 0:837f2afb6c50 18 while(1)
saypulung 0:837f2afb6c50 19 {
saypulung 0:837f2afb6c50 20 led2 = 1;
saypulung 0:837f2afb6c50 21 Thread::wait(50);
saypulung 0:837f2afb6c50 22 led2 = 0;
saypulung 0:837f2afb6c50 23 Thread::wait(50);
saypulung 0:837f2afb6c50 24
saypulung 0:837f2afb6c50 25 }
saypulung 0:837f2afb6c50 26 }
saypulung 0:837f2afb6c50 27 void pLED3(void const *args){
saypulung 0:837f2afb6c50 28 while(1)
saypulung 0:837f2afb6c50 29 {
saypulung 0:837f2afb6c50 30 led3 = 1;
saypulung 0:837f2afb6c50 31 Thread::wait(300);
saypulung 0:837f2afb6c50 32 led3 = 0;
saypulung 0:837f2afb6c50 33 Thread::wait(300);
saypulung 0:837f2afb6c50 34
saypulung 0:837f2afb6c50 35 }
saypulung 0:837f2afb6c50 36 }
saypulung 0:837f2afb6c50 37 int main(){
saypulung 0:837f2afb6c50 38 Thread thread1(pLED1);
saypulung 0:837f2afb6c50 39 Thread thread2(pLED2);
saypulung 0:837f2afb6c50 40 Thread thread3(pLED3);
saypulung 0:837f2afb6c50 41 while(1){
saypulung 0:837f2afb6c50 42 led4 = 1;
saypulung 0:837f2afb6c50 43 Thread::wait(200);
saypulung 0:837f2afb6c50 44 led4 = 0;
saypulung 0:837f2afb6c50 45 Thread::wait(200);
saypulung 0:837f2afb6c50 46 }
saypulung 0:837f2afb6c50 47 }