2018年度計器mbed用プログラム
Dependencies: BufferedSoftSerial2 INA226_ver1 mbed-rtos mbed SDFileSystem-RTOS
Fork of keiki2017 by
Diff: main.cpp
- Branch:
- Thread-gyogetsuMPU
- Revision:
- 58:b4f3ed763cb4
- Parent:
- 56:6823d2324704
- Child:
- 59:7cb8eaf553ef
--- a/main.cpp Sat May 27 07:44:05 2017 +0000 +++ b/main.cpp Fri Jun 09 11:35:33 2017 +0000 @@ -134,6 +134,7 @@ void init() { + pc.printf("(BUILD:[" __DATE__ "/" __TIME__ "])\n\r"); //--------------------------------------(resetInterrupt init) resetPin.rise(resetInterrupt); resetPin.mode(PullDown); @@ -142,7 +143,7 @@ android.baud(9600); //writeTimer.start(); FusokukeiInit(); - SdInit(); +// SdInit(); // MpuInit(); //writeDatasTicker.attach(&WriteDatas,1); // cadenceUpdateTicker.attach(&updateCadence, 0.2); @@ -257,18 +258,26 @@ fclose(fp); } -void SDprintf(){ - fp = fopen("/sd/mydir/data.csv", "a"); - if(fp == NULL) { - error("Could not open file for write\n"); +void SDprintf(const void* arg){ + SdInit(); + while(1){ + if(write_datas_index == SD_WRITE_NUM-1){ + fp = fopen("/sd/mydir/data.csv", "a"); + if(fp == NULL) { + printf("Could not open file for write\n"); + } + for(int i = 0; i < SD_WRITE_NUM; i++){ + for(int j = 0; j < WRITE_DATAS_NUM; j++){ + fprintf(fp,"%f,", writeDatas[i][j]); + } + } + fprintf(fp,"\n"); + fclose(fp); + + write_datas_index=0; + } + Thread::wait(1); } - for(int i = 0; i < SD_WRITE_NUM; i++){ - for(int j = 0; j < WRITE_DATAS_NUM; j++){ - fprintf(fp,"%f,", writeDatas[i][j]); - } - } - fprintf(fp,"\n"); - fclose(fp); } void WriteDatas() @@ -292,7 +301,7 @@ // //pc.printf("\n\r"); // twe.printf("\n\r"); if(write_datas_index == SD_WRITE_NUM-1) { - SDprintf(); +// SDprintf(); write_datas_index=0; } else { write_datas_index++; @@ -383,7 +392,8 @@ int main() { // Thread cadence_thread(&updateCadence); -// Thread mpu_thread(&mpuProcessing); + Thread mpu_thread(&mpuProcessing); + Thread SD_thread(&SDprintf); // Thread soudaSerial_thread(&DataReceiveFromSouda); init(); while(1) {