Francisco Salle / Mbed 2 deprecated cw-watchdog-09012018-copy_copy

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_09012018_copy by Calvin Kalintra

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sd.h Source File

sd.h

00001  #include "mbed.h"
00002  #include "SDBlockDevice.h"
00003  #include "FATFileSystem.h"
00004  #include "putty.h"
00005  #include "mbed_events.h"
00006  
00007 DigitalOut redLED(PB_11), yellowLED(PB_10), greenLED(PE_15);
00008 SDBlockDevice sd(D11, D12, D13, D10); 
00009 EventQueue eq;
00010 FILE* fp;
00011 bool ejected = false; 
00012 void takeSample()
00013 {
00014     int counterb = 0;
00015     while (counterb <= countera) 
00016     {
00017         if (ejected == true) 
00018         {
00019             return;    
00020         }   
00021         float temp_sd = data_tempa[counterb];
00022         float pressure_sd = data_pressa[counterb];
00023         float light_sd = data_lighta[counterb];
00024         float date_a_sd = date_aa[counterb] ; 
00025         float time_a_sd = time_aa [counterb];
00026         float date0_a_sd = date0_aa[counterb];
00027         float time0_a_sd = time0_aa[counterb];
00028         fprintf(fp, "%i%i, %i%i, temp:%f, pressure: %f, light lvl:%f\n\r", time0_a, time_a_sd, date0_a_sd, date_a_sd, temp_sd,pressure_sd,light_sd);
00029         redLED = 1;
00030         Thread::wait(100);
00031         redLED = 0;
00032     
00033         if ((sw1 == 1) && (sw2 == 1)) 
00034         {
00035             fclose(fp);
00036             sd.deinit();
00037             yellowLED = 1;
00038             ejected = true;
00039         }
00040     }
00041 }
00042  
00043 //void sd()
00044 //{
00045 //    if (sd.init() != 0) {
00046 //        printf("Init failed \n");
00047 //        errorCode(FATAL);
00048 //    }    
00049 //    FATFileSystem fs("sd", &sd);
00050 //    fp = fopen("/sd/test.txt","a");
00051 //    if (fp == NULL) {
00052 //        error("Could not open file for write\n");
00053 //        errorCode(FATAL);
00054 //    }
00055 //    takeSample();
00056 //   
00057 //
00058 //}