rtos32

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 DigitalOut led1(LED1);
00004 DigitalOut led2(LED2);
00005 double status; 
00006 Timer t;
00007 int tim;
00008 bool b;
00009 
00010 void thread1(void const *args) {
00011     int aux = (t.read_us() - tim);  
00012     printf("The time taken was %d US_SECONDS (CON LA MISMA PRIORIDAD) \r\n", aux);
00013     t.reset();
00014     while (true) {
00015             
00016             led1 = !led1;
00017             for(double i=0; i<100000; i++) {
00018                    status = i;  
00019                 }
00020             led1 = !led1;
00021             Thread::wait(300);
00022         }
00023     }
00024 
00025 
00026 int main() {
00027     led1 = false;
00028     led2 = false;
00029     b = true;
00030     Thread my_thread1(thread1);
00031     t.reset();
00032     t.start();
00033     while (true) {
00034             tim = t.read_us();
00035         }
00036 }