Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_L476VG COMPASS_DISCO_L476VG ConfigFile GYRO_DISCO_L476VG SDFileSystem mbed
DefinitionIO.h
00001 #include "mbed.h" 00002 #include "DataFile.h" 00003 00004 #include "SDFileSystem.h" 00005 #include "COMPASS_DISCO_L476VG.h" 00006 #include "GYRO_DISCO_L476VG.h" 00007 #define NbDAC 5 00008 00009 #define SavePeriod 0.1 // 1/frequency of log : default 0.1 (tested OK at 0.01 (100Hz)) 00010 00011 DigitalOut LedEnreg(LED1); 00012 DigitalIn InterEnreg(PD_0,PullDown); 00013 Ticker TickUpdate; 00014 COMPASS_DISCO_L476VG compass ; //declaration must be before SDFile system declaration 00015 GYRO_DISCO_L476VG gyro; 00016 00017 00018 00019 AnalogIn AIn0(PA_0); 00020 AnalogIn AIn1(PA_1); 00021 AnalogIn AIn2(PA_2); 00022 AnalogIn AIn3(PA_3); 00023 AnalogIn AIn4(PA_5); 00024 00025 AnalogIn * TabpAIn[NbDAC]= {&AIn0,&AIn1,&AIn2,&AIn3,&AIn4}; 00026 //AnalogIn * AIn [5]; 00027 00028 //Create an SDFileSystem object 00029 SDFileSystem sd(PE_15, PE_14, PE_13, PE_12, "sd"); 00030 00031 00032 tDataFile DataFile; //used to manage data savings 00033 bool EnregistrementEnCours; 00034 00035 tMesure Mesures(&compass,&gyro,TabpAIn); 00036 00037 00038 00039 //------------------------ 00040 // manage log switch 00041 void CheckEnreg() 00042 { 00043 if (InterEnreg.read()==1) 00044 { 00045 if (!EnregistrementEnCours) 00046 { 00047 EnregistrementEnCours=true; 00048 DataFile.New(); 00049 printf("log started\n\r"); 00050 } 00051 else 00052 { 00053 DataFile.SaveMesures(&Mesures); 00054 } 00055 LedEnreg=!LedEnreg; 00056 00057 } 00058 else 00059 { 00060 if (EnregistrementEnCours) 00061 { 00062 EnregistrementEnCours=false; 00063 DataFile.Close(); 00064 printf("Log stopped\n\r"); 00065 } 00066 LedEnreg=0; 00067 } 00068 } 00069 00070 /*********************** 00071 Main function in loop 00072 ************************/ 00073 void Update() 00074 { 00075 CheckEnreg(); 00076 Mesures.Update(); 00077 } 00078 00079 //------------------------ 00080 // initialization of logger 00081 00082 void Init() 00083 { 00084 TickUpdate.attach(&Update, SavePeriod); //starting the infinit loop 00085 printf("\n\r"); 00086 printf("DISCO logger V2.0\n\r"); 00087 printf("----------------\n\r\n\r"); 00088 00089 EnregistrementEnCours=false; 00090 LedEnreg=0; 00091 00092 printf("sensors started\n\r"); 00093 00094 //Mount the filesystem 00095 sd.mount(); 00096 printf("File system mounted\n\r"); 00097 printf("Toggle switch to start recording\n\r"); 00098 00099 /* AIn[0]=&AIn0; 00100 AIn[1]=&AIn1; 00101 AIn[2]=&AIn2; 00102 AIn[3]=&AIn3; 00103 AIn[4]=&AIn4;*/ 00104 }
Generated on Thu Jul 14 2022 08:24:02 by
1.7.2