mbed_robotcar / Mbed OS mbed_signal
Committer:
tomotsugu
Date:
Thu Jul 09 07:10:52 2020 +0000
Revision:
0:c8547914b033
signal_LED8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomotsugu 0:c8547914b033 1 #include "mbed.h"
tomotsugu 0:c8547914b033 2 #include "rtos.h"
tomotsugu 0:c8547914b033 3
tomotsugu 0:c8547914b033 4 DigitalOut led1(p17);
tomotsugu 0:c8547914b033 5 DigitalOut led2(p18);
tomotsugu 0:c8547914b033 6 DigitalOut led3(p19);
tomotsugu 0:c8547914b033 7 DigitalOut led4(p20);
tomotsugu 0:c8547914b033 8 DigitalOut led5(p27);
tomotsugu 0:c8547914b033 9 DigitalOut led6(p28);
tomotsugu 0:c8547914b033 10 DigitalOut led7(p29);
tomotsugu 0:c8547914b033 11 DigitalOut led8(p30);
tomotsugu 0:c8547914b033 12
tomotsugu 0:c8547914b033 13 void led1_thread(void const *arg){
tomotsugu 0:c8547914b033 14 while(1){
tomotsugu 0:c8547914b033 15 Thread::signal_wait(0x1);
tomotsugu 0:c8547914b033 16 led1 = !led1;
tomotsugu 0:c8547914b033 17 }
tomotsugu 0:c8547914b033 18 }
tomotsugu 0:c8547914b033 19
tomotsugu 0:c8547914b033 20 void led2_thread(void const *arg){
tomotsugu 0:c8547914b033 21 while(1){
tomotsugu 0:c8547914b033 22 Thread::signal_wait(0x1);
tomotsugu 0:c8547914b033 23 led2 = !led2;
tomotsugu 0:c8547914b033 24 }
tomotsugu 0:c8547914b033 25 }
tomotsugu 0:c8547914b033 26
tomotsugu 0:c8547914b033 27 void led3_thread(void const *arg){
tomotsugu 0:c8547914b033 28 while(1){
tomotsugu 0:c8547914b033 29 Thread::signal_wait(0x1);
tomotsugu 0:c8547914b033 30 led3 = !led3;
tomotsugu 0:c8547914b033 31 }
tomotsugu 0:c8547914b033 32 }
tomotsugu 0:c8547914b033 33
tomotsugu 0:c8547914b033 34 void led4_thread(void const *arg){
tomotsugu 0:c8547914b033 35 while(1){
tomotsugu 0:c8547914b033 36 Thread::signal_wait(0x1);
tomotsugu 0:c8547914b033 37 led4 = !led4;
tomotsugu 0:c8547914b033 38 }
tomotsugu 0:c8547914b033 39 }
tomotsugu 0:c8547914b033 40
tomotsugu 0:c8547914b033 41 void led5_thread(void const *arg){
tomotsugu 0:c8547914b033 42 while(1){
tomotsugu 0:c8547914b033 43 Thread::signal_wait(0x2);
tomotsugu 0:c8547914b033 44 led5 = !led5;
tomotsugu 0:c8547914b033 45 }
tomotsugu 0:c8547914b033 46 }
tomotsugu 0:c8547914b033 47
tomotsugu 0:c8547914b033 48 void led6_thread(void const *arg){
tomotsugu 0:c8547914b033 49 while(1){
tomotsugu 0:c8547914b033 50 Thread::signal_wait(0x2);
tomotsugu 0:c8547914b033 51 led6 = !led6;
tomotsugu 0:c8547914b033 52 }
tomotsugu 0:c8547914b033 53 }
tomotsugu 0:c8547914b033 54
tomotsugu 0:c8547914b033 55 void led7_thread(void const *arg){
tomotsugu 0:c8547914b033 56 while(1){
tomotsugu 0:c8547914b033 57 Thread::signal_wait(0x2);
tomotsugu 0:c8547914b033 58 led7 = !led7;
tomotsugu 0:c8547914b033 59 }
tomotsugu 0:c8547914b033 60 }
tomotsugu 0:c8547914b033 61
tomotsugu 0:c8547914b033 62 void led8_thread(void const *arg){
tomotsugu 0:c8547914b033 63 while(1){
tomotsugu 0:c8547914b033 64 Thread::signal_wait(0x2);
tomotsugu 0:c8547914b033 65 led8 = !led8;
tomotsugu 0:c8547914b033 66 }
tomotsugu 0:c8547914b033 67 }
tomotsugu 0:c8547914b033 68
tomotsugu 0:c8547914b033 69 int main(){
tomotsugu 0:c8547914b033 70 Thread thread1(led1_thread);
tomotsugu 0:c8547914b033 71 Thread thread2(led2_thread);
tomotsugu 0:c8547914b033 72 Thread thread3(led3_thread);
tomotsugu 0:c8547914b033 73 Thread thread4(led4_thread);
tomotsugu 0:c8547914b033 74 Thread thread5(led5_thread);
tomotsugu 0:c8547914b033 75 Thread thread6(led6_thread);
tomotsugu 0:c8547914b033 76 Thread thread7(led7_thread);
tomotsugu 0:c8547914b033 77 Thread thread8(led8_thread);
tomotsugu 0:c8547914b033 78
tomotsugu 0:c8547914b033 79 while(1){
tomotsugu 0:c8547914b033 80 thread1.signal_set(0x1);
tomotsugu 0:c8547914b033 81 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 82 thread2.signal_set(0x1);
tomotsugu 0:c8547914b033 83 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 84 thread3.signal_set(0x1);
tomotsugu 0:c8547914b033 85 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 86 thread4.signal_set(0x1);
tomotsugu 0:c8547914b033 87 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 88 thread5.signal_set(0x2);
tomotsugu 0:c8547914b033 89 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 90 thread6.signal_set(0x2);
tomotsugu 0:c8547914b033 91 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 92 thread7.signal_set(0x2);
tomotsugu 0:c8547914b033 93 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 94 thread8.signal_set(0x2);
tomotsugu 0:c8547914b033 95 ThisThread::sleep_for(10);
tomotsugu 0:c8547914b033 96 }
tomotsugu 0:c8547914b033 97 }