jiosd

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 
00004  
00005 DigitalOut led1S(p8); 
00006 DigitalOut led2S(p10);
00007 
00008 Timer tim1;
00009 Timer tim2;
00010 Timer tim3;
00011 
00012 int vectorT1[2][100];
00013 int vectorT2[2][100];
00014 int inde = 0;
00015 const int max = 1000;
00016 int T=100;
00017 int Tfor=76;
00018 
00019  void t1_thread(void const *args) {
00020     while(true) {
00021         tim3.reset();
00022         
00023         vectorT1[0][inde]=tim1.read_ms();
00024         vectorT2[1][inde]=tim2.read_ms();
00025         for(int i=0; i< max; i++ ){
00026             for(int j=0; j< max; j++ ){
00027                 int a=1;
00028             }
00029         }
00030         Thread::wait(10*tim3.read_ms());
00031     }
00032 }
00033 
00034 /*void t2_thread(void const *args) {
00035     while(true) {
00036         
00037     }
00038 }*/
00039 int main() {
00040     tim1.start();
00041     tim2.start();
00042     tim3.start();
00043     
00044     Thread thread1(t1_thread);
00045     //Thread thread2(t2_thread);
00046     //osThreadSetPriority(osThreadGetId(),osPriorityBelowNormal);
00047     while (true) {
00048         tim3.reset();
00049         
00050         vectorT2[0][inde]=tim2.read_ms();
00051         vectorT1[1][inde]=tim1.read_ms();
00052         for(int i=0; i< max; i++ ){
00053             for(int j=0; j< max; j++ ){
00054                 int a=1;
00055             }
00056         }
00057         for(int i=0; i< max; i++ ){
00058             for(int j=0; j< max; j++ ){
00059                 int a=1;
00060             }
00061         }
00062         Thread::wait(1.5*tim3.read_ms());
00063         
00064         if(inde < 100){
00065             inde++;
00066         }else{
00067             printf("INIT PRINT\r\n");
00068             for(int i=0; i < inde; i++ ){
00069                 printf("%d:\t%d,%d,%d,%d\r\n",i, vectorT1[0][i], vectorT1[1][i], vectorT2[0][i], vectorT2[1][i]);
00070             }
00071             printf("END PRINT\r\n");
00072             inde=0;
00073             tim1.reset();
00074             tim2.reset();
00075         }
00076     }
00077 }