Pol Rodoreda Valeri
/
RTOS_rma
dnj
Fork of rtos_basic by
Revision 7:62b77d1d7f0d, committed 2016-11-11
- Comitter:
- polrodoreda
- Date:
- Fri Nov 11 18:46:32 2016 +0000
- Parent:
- 6:209f4db62daf
- Commit message:
- P5
Changed in this revision
diff -r 209f4db62daf -r 62b77d1d7f0d main.cpp --- a/main.cpp Tue Jun 04 16:01:32 2013 +0100 +++ b/main.cpp Fri Nov 11 18:46:32 2016 +0000 @@ -1,21 +1,59 @@ #include "mbed.h" #include "rtos.h" - -DigitalOut led1(LED1); -DigitalOut led2(LED2); + -void led2_thread(void const *args) { - while (true) { - led2 = !led2; - Thread::wait(1000); +DigitalOut led1S(p8); +DigitalOut led2S(p10); + +Timer tim1; +Timer tim2; +Timer tim; + +int vector[4][100]; +int index = 0; + + void t1_thread(void const *args) { + while(true) { + if(tim2.read_ms()==0){ + vector[0][index]=tim.read_ms(); + } + tim1.start(); + tim2.stop(); + if(tim1.read_ms()>100){ + tim1.stop(); + vector[1][index]=tim.read_ms(); + tim1.reset(); + } } } - -int main() { - Thread thread(led2_thread); - - while (true) { - led1 = !led1; - Thread::wait(500); + + void t2_thread(void const *args) { + while(true) { + if(tim1.read_ms()==0){ + vector[2][index]=tim.read_ms(); + } + tim2.start(); + tim1.stop(); + if(tim2.read_ms()>200){ + tim2.stop(); + vector[3][index]=tim.read_ms(); + tim2.reset(); + if(index<100){ + index++; + }else{ + for(int i=0; i<100;i++){ + printf("%d,%d,%d,%d\r\n", vector[0][i], vector[1][i], vector[2][i], vector[3][i]); + } + printf("\r\n"); + + } + } } } +int main() { + Thread thread1(t1_thread); + Thread thread2(t2_thread); + tim.start(); + while (true) { + } +}
diff -r 209f4db62daf -r 62b77d1d7f0d mbed-rtos.lib --- a/mbed-rtos.lib Tue Jun 04 16:01:32 2013 +0100 +++ b/mbed-rtos.lib Fri Nov 11 18:46:32 2016 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed-rtos/ \ No newline at end of file +https://mbed.org/users/mbed_official/code/mbed-rtos/#3da5f554d8bf
diff -r 209f4db62daf -r 62b77d1d7f0d mbed.bld --- a/mbed.bld Tue Jun 04 16:01:32 2013 +0100 +++ b/mbed.bld Fri Nov 11 18:46:32 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file