Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning
Dependencies: BME280 BMP280 TextLCD
Working Repository
Diff: SD_CARD.cpp
- Revision:
- 48:244d6d81bb52
- Parent:
- 47:6d128e500875
- Child:
- 49:d51f96a46cc3
--- a/SD_CARD.cpp Mon Jan 08 21:53:40 2018 +0000 +++ b/SD_CARD.cpp Tue Jan 09 00:37:01 2018 +0000 @@ -1,17 +1,40 @@ #include "SD_CARD.hpp" +FILE* fp; +InterruptIn SD_CARD_DETECT(D0); + +bool SD_Write = 1; void SD_Init()//Initialised the SD CARD { } +void SD_Card_Eject() +{ + SD_Write = 0; + if(Log_Value==5){pc.printf("Closing File Ejecting SD Card\n");} + fclose(fp);//Close File + sd.deinit();//Close down + LCD.Display_Clear(); + LCD.DDRAM_Address(0x00); + LCD.Write_String("SD Card"); + LCD.DDRAM_Address(0x40); + LCD.Write_String("Unmounted"); + LCD.DDRAM_Address(0x00); + pc.printf("SD Card Unmounted\n"); +} void SD_Card_Write() { + if(SD_Write == 0) + { + if(Log_Value==5){pc.printf("SD Has Been Ejected Please do a Hardware Restart\n");} + return; + } if(Write_Pointer == mailsize - 1) { - if(Log_Value==1){pc.printf("In SD_Card Thread\n");} + if(Log_Value==5){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");} + if(Log_Value==5){pc.printf("File Opened\n");} for(int SD_Card_Data_Pointer = 0; SD_Card_Data_Pointer != mailsize; SD_Card_Data_Pointer++) { @@ -36,7 +59,7 @@ 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");} + if(Log_Value==5){pc.printf("Dumped data to SD Card\n");} //Close File fclose(fp); }