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

DefinitionIO.h

Committer:
flowh
Date:
2016-02-12
Revision:
0:0861bf46efe4
Child:
1:e1f3b4b8b99b

File content as of revision 0:0861bf46efe4:

#include "mbed.h"
#include "DataFile.h"

#include "SDFileSystem.h"
#include "COMPASS_DISCO_L476VG.h"


DigitalOut LedEnreg(LED1);
DigitalIn InterEnreg(PD_0,PullDown);

COMPASS_DISCO_L476VG  compass ;

  //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);

 
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"); 
}

void CheckEnreg()
{
   if (InterEnreg.read()==1)
    {
       //printf("InterEnreg\n\r"); 
       if (!EnregistrementEnCours)
       {
           EnregistrementEnCours=true;
           DataFile.New();
           printf("enregistrement started\n\r"); 
       } 
       else
       {
           DataFile.SaveMesures(&Mesures);
           //printf("Enregistrement\n\r"); 
       }
       LedEnreg=!LedEnreg;
       
    }
    else
    {
        //printf("Not InterEnreg\n\r"); 
        if (EnregistrementEnCours)
       {
           EnregistrementEnCours=false;
           DataFile.Close();
           printf("enregistrement stopped\n\r"); 
       } 
       LedEnreg=0;
    }
}