Log measurements on SD card added on DISCO-L476VG board acceleration, omega, compass & 5 Analog values

Dependencies:   BSP_DISCO_L476VG COMPASS_DISCO_L476VG ConfigFile GYRO_DISCO_L476VG SDFileSystem mbed

Revision:
1:e1f3b4b8b99b
Parent:
0:0861bf46efe4
Child:
2:f53340e49cc0
--- a/DefinitionIO.h	Fri Feb 12 20:54:38 2016 +0000
+++ b/DefinitionIO.h	Sat Feb 13 14:29:40 2016 +0000
@@ -3,66 +3,101 @@
 
 #include "SDFileSystem.h"
 #include "COMPASS_DISCO_L476VG.h"
+#include "GYRO_DISCO_L476VG.h"
+#define NbDAC   5
 
+#define SavePeriod  0.1     // 1/frequency of log : default 0.1 (tested OK at 0.01 (100Hz))
 
 DigitalOut LedEnreg(LED1);
 DigitalIn InterEnreg(PD_0,PullDown);
+Ticker TickUpdate;
+COMPASS_DISCO_L476VG  compass ; //declaration must be before SDFile system declaration
+GYRO_DISCO_L476VG gyro;
 
-COMPASS_DISCO_L476VG  compass ;
+
+
+AnalogIn AIn0(PA_0);
+AnalogIn AIn1(PA_1);
+AnalogIn AIn2(PA_2);
+AnalogIn AIn3(PA_3);
+AnalogIn AIn4(PA_5);
+
+AnalogIn * TabpAIn[NbDAC]= {&AIn0,&AIn1,&AIn2,&AIn3,&AIn4};
+//AnalogIn * AIn [5];
 
   //Create an SDFileSystem object
- SDFileSystem sd(PE_15, PE_14, PE_13, PE_12, "sd");
- tDataFile DataFile;
- bool EnregistrementEnCours;
- 
- //COMPASS_DISCO_L476VG  compass ;//=new COMPASS_DISCO_L476VG();
- 
- tMesure Mesures(&compass);
+SDFileSystem sd(PE_15, PE_14, PE_13, PE_12, "sd");
+
 
+tDataFile DataFile; //used to manage data savings
+bool EnregistrementEnCours;
  
-void Init()
-{
-  printf("avant Compass created\n");
-  //pcompass =new COMPASS_DISCO_L476VG();
-  printf("Compass created\n");
- // delete pcompass;
-   EnregistrementEnCours=false;
-   LedEnreg=0;
-   printf("Compass started\n"); 
-   
-   //Mount the filesystem
-   sd.mount();   
-   printf("mounted\n\r"); 
-}
+tMesure Mesures(&compass,&gyro,TabpAIn);
+
 
+
+//------------------------
+// manage log switch
 void CheckEnreg()
 {
    if (InterEnreg.read()==1)
     {
-       //printf("InterEnreg\n\r"); 
        if (!EnregistrementEnCours)
        {
            EnregistrementEnCours=true;
            DataFile.New();
-           printf("enregistrement started\n\r"); 
+           printf("log started\n\r"); 
        } 
        else
        {
            DataFile.SaveMesures(&Mesures);
-           //printf("Enregistrement\n\r"); 
        }
        LedEnreg=!LedEnreg;
        
     }
     else
-    {
-        //printf("Not InterEnreg\n\r"); 
-        if (EnregistrementEnCours)
+    { 
+       if (EnregistrementEnCours)
        {
            EnregistrementEnCours=false;
            DataFile.Close();
-           printf("enregistrement stopped\n\r"); 
+           printf("Log stopped\n\r"); 
        } 
        LedEnreg=0;
     }
+}
+
+/***********************
+Main function in loop
+************************/
+void Update()
+{
+   CheckEnreg();  
+   Mesures.Update();
+}
+
+//------------------------
+// initialization of logger
+ 
+void Init()
+{
+   TickUpdate.attach(&Update, SavePeriod);  //starting the infinit loop
+   printf("\n\r");
+   printf("Moth logger V2.0\n\r");
+   printf("----------------\n\r\n\r");
+   
+   EnregistrementEnCours=false;
+   LedEnreg=0;
+   
+   printf("sensors started\n\r"); 
+   
+   //Mount the filesystem
+   sd.mount();   
+   printf("File system mounted\n\r"); 
+   
+  /* AIn[0]=&AIn0;
+   AIn[1]=&AIn1;
+   AIn[2]=&AIn2;
+   AIn[3]=&AIn3;
+   AIn[4]=&AIn4;*/
 }
\ No newline at end of file