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.
Fork of ELEC351 by
Diff: SD_CARD.cpp
- Revision:
- 47:6d128e500875
- Child:
- 48:244d6d81bb52
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SD_CARD.cpp Mon Jan 08 21:53:40 2018 +0000
@@ -0,0 +1,43 @@
+#include "SD_CARD.hpp"
+void SD_Init()//Initialised the SD CARD
+{
+
+}
+void SD_Card_Write()
+{
+ if(Write_Pointer == mailsize - 1)
+ {
+ if(Log_Value==1){pc.printf("In SD_Card Thread\n");}
+
+ //Open to WRITE
+ FILE* fp = fopen("/sd/test.csv","a");
+ if(Log_Value==1){pc.printf("File Opened\n");}
+
+ for(int SD_Card_Data_Pointer = 0; SD_Card_Data_Pointer != mailsize; SD_Card_Data_Pointer++)
+ {
+ time_t Time = Data_Buffer[SD_Card_Data_Pointer].get_time();
+ tm* Time_Pointer = localtime(&Time);
+ int temp_day = Time_Pointer->tm_mday;
+ int temp_month = (Time_Pointer->tm_mon+1);//Set to current month
+ int temp_year = (Time_Pointer->tm_year+1900);//Set to current year
+
+ int temp_hours = Time_Pointer->tm_hour;
+ int temp_minute = Time_Pointer->tm_min;
+ int temp_seconds = Time_Pointer->tm_sec;
+
+ float temp_temperature = Data_Buffer[SD_Card_Data_Pointer].get_temperature();
+ float temp_pressure = Data_Buffer[SD_Card_Data_Pointer].get_pressure();
+ float temp_light = Data_Buffer[SD_Card_Data_Pointer].get_light();
+
+ fprintf(fp, "Date: %02d/%02d/%d,",temp_day,temp_month,temp_year);//Date
+ fprintf(fp, "Time: %02d:%02d:%02d,",temp_hours,temp_minute, temp_seconds);//Time
+ fprintf(fp, "Temperature: %1.1f,",temp_temperature);//Temperature
+ fprintf(fp, "Pressure: %1.1f,",temp_pressure);//Pressure
+ fprintf(fp, "Light: %5.3f,",temp_light);//Light
+ fprintf(fp, "End of Data \n");//End of data
+ }
+ if(Log_Value==1){pc.printf("Dumped data to SD Card\n");}
+ //Close File
+ fclose(fp);
+ }
+}
