jiosd

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

main.cpp

Committer:
polrodoreda
Date:
2016-11-11
Revision:
7:8fcd03be2590
Parent:
3:c92e21f305d8

File content as of revision 7:8fcd03be2590:

#include "mbed.h"
#include "rtos.h"

 
DigitalOut led1S(p8); 
DigitalOut led2S(p10);

Timer tim1;
Timer tim2;
Timer tim3;

int vectorT1[2][100];
int vectorT2[2][100];
int inde = 0;
const int max = 1000;
int T=100;
int Tfor=76;

 void t1_thread(void const *args) {
    while(true) {
        tim3.reset();
        
        vectorT1[0][inde]=tim1.read_ms();
        vectorT2[1][inde]=tim2.read_ms();
        for(int i=0; i< max; i++ ){
            for(int j=0; j< max; j++ ){
                int a=1;
            }
        }
        Thread::wait(10*tim3.read_ms());
    }
}

/*void t2_thread(void const *args) {
    while(true) {
        
    }
}*/
int main() {
    tim1.start();
    tim2.start();
    tim3.start();
    
    Thread thread1(t1_thread);
    //Thread thread2(t2_thread);
    //osThreadSetPriority(osThreadGetId(),osPriorityBelowNormal);
    while (true) {
        tim3.reset();
        
        vectorT2[0][inde]=tim2.read_ms();
        vectorT1[1][inde]=tim1.read_ms();
        for(int i=0; i< max; i++ ){
            for(int j=0; j< max; j++ ){
                int a=1;
            }
        }
        for(int i=0; i< max; i++ ){
            for(int j=0; j< max; j++ ){
                int a=1;
            }
        }
        Thread::wait(1.5*tim3.read_ms());
        
        if(inde < 100){
            inde++;
        }else{
            printf("INIT PRINT\r\n");
            for(int i=0; i < inde; i++ ){
                printf("%d:\t%d,%d,%d,%d\r\n",i, vectorT1[0][i], vectorT1[1][i], vectorT2[0][i], vectorT2[1][i]);
            }
            printf("END PRINT\r\n");
            inde=0;
            tim1.reset();
            tim2.reset();
        }
    }
}