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: SDFileSystem mbed-rtos mbed
Fork of CDMS_BAE by
Revision 4:374c51671a69, committed 2014-12-22
- Comitter:
- pradeepvk2208
- Date:
- Mon Dec 22 14:33:30 2014 +0000
- Parent:
- 3:6cde88f8c50f
- Child:
- 5:3979ca24777a
- Commit message:
- final rtcsd
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Mon Dec 22 14:33:30 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
--- a/rtsc.cpp Mon Dec 22 10:10:38 2014 +0000
+++ b/rtsc.cpp Mon Dec 22 14:33:30 2014 +0000
@@ -2,6 +2,8 @@
SPI spi(PTD6, PTD7, PTD5);
DigitalOut cs(PTD2);
+SDFileSystem sd(PTD6, PTD7, PTD5, D10,"sd");
+
void spiwrite(int a)
{
cs=1;
@@ -34,7 +36,7 @@
char mi[3]=getstr(minutes);
char s[3]=getstr(seconds);*/
char time[15];
- sprintf(time,"%2d%2d%2d%2d%2d%2d%2d",year1,month1,date1,day1,hours1,minutes1,seconds1);
+ sprintf(time,"%02d%02d%02d%02d%02d%02d%02d",year1,month1,date1,day1,hours1,minutes1,seconds1);
return(time);
}
@@ -69,5 +71,39 @@
wait(1);
printf("Seconds register = %2X : %2X : %2X : %2X : %2X : %2X : %2X \n\r",year,month,date,day, hours,minutes,seconds);
printf("b4 returning tmpstmp is : %s\n",getname(year,month,date,day,hours,minutes,seconds));
+ printf("Hello World!\n");
+ SensorData Sensor;
+
+ printf("Writing dummy values\n");
+ strcpy( Sensor.Voltage, "49");
+ strcpy( Sensor.Current, "83");
+ strcpy( Sensor.Temperature, "53");
+ strcpy( Sensor.PanelTemperature, "43");
+ Sensor.Vcell_soc='9';
+ Sensor.alerts= '4';
+ Sensor.crate='7';
+ Sensor.BatteryTemperature='6';
+ Sensor.faultpoll='4';
+ Sensor.faultir='g';
+ Sensor.power_mode='k';
+ strcpy( Sensor.AngularSpeed, "49");
+ strcpy(Sensor.Bnewvalue,"76");
+ SensorData* Sensor1= &Sensor;
+ printf("Done writing dummy values\n");
+ mkdir("/sd/hk", 0777);
+ char date2[100]="/sd/hk/";
+ strcat(date2,getname(year,month,date,day,hours,minutes,seconds));
+ strcat(date2,".txt");
+ FILE *fp ;
+ fp= fopen(date2, "w");
+ if(fp == NULL) {
+ error("Could not open file for write\n");
}
- }
\ No newline at end of file
+ else
+ {
+ fwrite(Sensor1, sizeof(*Sensor1), 1, fp);
+ fclose(fp);
+ printf("Mission Accomplished\n");
+ printf("Goodbye World!\n");
+ }
+ }}
\ No newline at end of file
--- a/rtsc.h Mon Dec 22 10:10:38 2014 +0000
+++ b/rtsc.h Mon Dec 22 14:33:30 2014 +0000
@@ -1,7 +1,33 @@
#include "mbed.h"
+#include "SDFileSystem.h"
+#include "string.h"
+typedef struct SensorData {
+ char Voltage[8];
+ char Current[4];
+ char Temperature[1];
+ char PanelTemperature[2];//read by the 4 thermistors on solar panels
+ char Vcell_soc;//MSBs correspond to Vcell, LSBs to Soc
+ char alerts;//UNQUANTISED
+ //(alerts[0]=1)-> reset indicator=>dont care
+ //(alerts[1]=1)-> Vcell>ValrtMax(5.1V)->will always be high->dont care
+ //(alerts[2]=1)-> Vcell<ValrtMin(5.1V)->indicates deep discharge
+ //(alerts[3]=1)-> Vcell<Vreset(2.5V)
+ //(alerts[5]=1)-> Soc CROSSES the threshold value
+ //(alerts[6]=1)-> alert on (alerts[3]) enabled when Vcell<Vreset(here we set it to be 2.5V)
+ char crate;
+ char BatteryTemperature; //to be populated
+ char faultpoll; //polled faults
+ char faultir; //interrupted faults
+ char power_mode; //power modes
+ char AngularSpeed[2];
+ char Bnewvalue[2];
+
+ //float magnetometer,gyro=>to be addes
+} SensorData;
void spiwrite(int);
int spiread(int);
int hexint(int);
char* getname(int,int,int,int,int,int,int);
-char* getts(void);
\ No newline at end of file
+char* getts(void);
+void storedata(char*,SensorData*);
\ No newline at end of file
