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: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Revision 343:cd7b1734f7a0, committed 2017-01-04
- Comitter:
- chaithanyarss
- Date:
- Wed Jan 04 10:55:22 2017 +0000
- Parent:
- 338:d63eb331a67d
- Child:
- 344:1675dbde0bae
- Commit message:
- Testing EEPROM
Changed in this revision
--- a/CDMS_HK.h Mon Jan 02 14:21:44 2017 +0000
+++ b/CDMS_HK.h Wed Jan 04 10:55:22 2017 +0000
@@ -457,13 +457,15 @@
SD_FAULTCOUNT++;
SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT;
if(SD_FAULTCOUNT == 3) {
- FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(2,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
gPC.printf("Declaring SD card permanantly Disabled");
}
} else {
+ if(SD_STATUS != DEVICE_POWERED)
+ WRITE_TO_EEPROM(2,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
SD_STATUS = DEVICE_POWERED;
- if(SD_STATUS != DEVICE_POWERED)
- FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
SD_FAULTCOUNT = 0;
}
}
@@ -484,13 +486,15 @@
BAE_FAULTCOUNT++;
BAE_STATUS = (BAE_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
if(BAE_FAULTCOUNT == 3) {
- FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(1,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
gPC.printf("Declaring BAE permanantly Disabled");
}
} else {
+ if(BAE_STATUS != DEVICE_POWERED)
+ WRITE_TO_EEPROM(1,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
BAE_STATUS = DEVICE_POWERED;
- if(SD_STATUS != DEVICE_POWERED);
- FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
BAE_FAULTCOUNT = 0;
}
}
@@ -521,7 +525,8 @@
PL_FAULTCOUNT++;
PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
if(PL_FAULTCOUNT == 3) {
- FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(3,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
gPC.printf("Declaring PL_BEE permanantly Disabled");
}
} else {
@@ -535,9 +540,10 @@
PYLD_DFF_CLK = 0;
wait_us(1);
}
+ if(PL_STATUS != DEVICE_ENABLED)
+ WRITE_TO_EEPROM(3,(int32_t)DEVICE_ENABLED);
+ //FCTN_CDMS_WR_FLASH(3,DEVICE_ENABLED);
PL_STATUS = DEVICE_ENABLED;
- if(PL_STATUS != DEVICE_ENABLED)
- FCTN_CDMS_WR_FLASH(3,DEVICE_ENABLED);
PL_FAULTCOUNT = 0;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/E2PROM.h Wed Jan 04 10:55:22 2017 +0000
@@ -0,0 +1,56 @@
+#ifndef EEPROM_H
+#define EEPROM_H
+
+#define ee_scl PIN86
+#define ee_sda PIN87
+#define check 10
+
+EEPROM e2prom(ee_sda, ee_scl, 0, EEPROM::T24C512);
+int32_t INITIAL_EEPROM[32] = {1,1,1,1,1,0,0,0,0,35000,0xff,300,85,20,20,3,80000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+
+void WRITE_TO_EEPROM(uint32_t address, int32_t data_block)
+{
+ e2prom.write(address+10,data_block);
+}
+
+int32_t READ_FROM_EERPOM(uint32_t address)
+{
+ int32_t data;
+ e2prom.read(address+10, data);
+ return data;
+}
+
+void INIT_EEPROM()
+{
+ int32_t test_buffer;
+ e2prom.ready();
+ e2prom.read(9,test_buffer);
+ if(test_buffer == 0)
+ {
+ for(int i=0;i<32;i++)
+ WRITE_TO_EEPROM( i, INITIAL_EEPROM[i]);
+
+ e2prom.write(9,1);
+ }
+
+ EPS_V_A_EN_STATUS = READ_FROM_EERPOM(0);
+ BAE_STATUS = READ_FROM_EERPOM(1);
+ SD_STATUS = READ_FROM_EERPOM(2);
+ PL_STATUS = READ_FROM_EERPOM(3);
+ PL_EPS_LATCH_SW_EN = READ_FROM_EERPOM(4);
+ RTC_INIT_STATUS = READ_FROM_EERPOM(5);
+ CDMS_RTC_DISABLE = READ_FROM_EERPOM(6);
+ CDMS_RESET_COUNTER = READ_FROM_EERPOM(7);
+ TIME_LATEST_CDSMS_RESET = READ_FROM_EERPOM(8);
+ COM_TC_BYTES_LIMIT = READ_FROM_EERPOM(9);
+ COM_RX_CURRENT_MAX = READ_FROM_EERPOM(10);
+ COM_RX_DISABLE_TIMEOUT = READ_FROM_EERPOM(11);
+ COM_PA_TMP_HIGH = READ_FROM_EERPOM(12);
+ COM_PA_RECOVERY_TIMEOUT = READ_FROM_EERPOM(13);
+ COM_SESSION_TIMEOUT = READ_FROM_EERPOM(14);
+ COM_RSSI_MIN = READ_FROM_EERPOM(15);
+ SD_LIB_BLK_CURRENT = READ_FROM_EERPOM(16);
+}
+
+
+#endif
\ No newline at end of file
--- a/FMS_all.h Mon Jan 02 14:21:44 2017 +0000
+++ b/FMS_all.h Wed Jan 04 10:55:22 2017 +0000
@@ -83,7 +83,8 @@
{
SD_SW_EN_DS = 1;
SD_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
+ WRITE_TO_EEPROM(2,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
gPC.printf("sw on sd\n");
}
@@ -91,7 +92,8 @@
{
SD_SW_EN_DS = 0;
SD_STATUS = DEVICE_DISABLED;
- FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(2,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
gPC.printf("sw off sd\n");
}
@@ -122,7 +124,8 @@
{
BAE_SW_EN_DS = 1;
BAE_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
+ WRITE_TO_EEPROM(1,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
gPC.printf("sw on bae\n");
}
@@ -130,7 +133,8 @@
{
BAE_SW_EN_DS = 0;
BAE_STATUS = DEVICE_DISABLED;
- FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(1,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
gPC.printf("sw off bae\n");
}
@@ -144,7 +148,8 @@
PYLD_DFF_CLK = 0;
wait_us(1);
PL_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
+ WRITE_TO_EEPROM(3,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
}
void SW_OFF_PL_BEE()
@@ -157,7 +162,8 @@
PYLD_DFF_CLK = 0;
wait_us(1);
PL_STATUS = DEVICE_DISABLED;
- FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
+ WRITE_TO_EEPROM(3,(int32_t)DEVICE_DISABLED);
+ //FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
}
void SW_ON_PL_EPS()
@@ -170,7 +176,8 @@
PYLD_EPS_DFF_PWR_CLK = 0;
wait_us(1);
PL_EPS_LATCH_SW_EN = 1;
- FCTN_CDMS_WR_FLASH(4,1);
+ WRITE_TO_EEPROM(4,(int32_t)1);
+ //FCTN_CDMS_WR_FLASH(4,1);
}
void SW_OFF_PL_EPS()
@@ -183,21 +190,24 @@
PYLD_EPS_DFF_PWR_CLK = 0;
wait_us(1);
PL_EPS_LATCH_SW_EN = 0;
- FCTN_CDMS_WR_FLASH(4,0);
+ WRITE_TO_EEPROM(4,(int32_t)0);
+ //FCTN_CDMS_WR_FLASH(4,0);
}
void SW_ON_V_A_EN()
{
V_A_EN = 1;
EPS_V_A_EN_STATUS = 1;
- FCTN_CDMS_WR_FLASH(0,1);
+ WRITE_TO_EEPROM(0,(int32_t)1);
+ //FCTN_CDMS_WR_FLASH(0,1);
}
void SW_OFF_V_A_EN()
{
V_A_EN = 0;
EPS_V_A_EN_STATUS = 0;
- FCTN_CDMS_WR_FLASH(0,0);
+ WRITE_TO_EEPROM(0,(int32_t)0);
+ //FCTN_CDMS_WR_FLASH(0,0);
}
void RST_SD()
@@ -206,7 +216,8 @@
wait_ms(10);
SD_SW_EN_DS = 1;
SD_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
+ WRITE_TO_EEPROM(2,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
gPC.printf("rst sd\n");
}
@@ -217,7 +228,8 @@
BAE_SW_EN_DS = 1;
wait_ms(100);
BAE_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
+ WRITE_TO_EEPROM(1,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
gPC.printf("rst bae\n");
}
@@ -227,7 +239,8 @@
wait_ms(10);
PYLD_DFF = 1;
PL_STATUS = DEVICE_POWERED;
- FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
+ WRITE_TO_EEPROM(3,(int32_t)DEVICE_POWERED);
+ //FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
}
void RST_BAE()
--- a/Flash.h Mon Jan 02 14:21:44 2017 +0000
+++ b/Flash.h Wed Jan 04 10:55:22 2017 +0000
@@ -51,7 +51,6 @@
COM_SESSION_TIMEOUT = read[14];
COM_RSSI_MIN = read[15];
SD_LIB_BLK_CURRENT = read[16];
- CDMS_RESET_COUNTER = read[17];
}
/*Writing to the Flash*/
--- a/cdms_rtc.h Mon Jan 02 14:21:44 2017 +0000
+++ b/cdms_rtc.h Wed Jan 04 10:55:22 2017 +0000
@@ -80,7 +80,8 @@
gCS_RTC=1;
gPC.puts("\n\r rtc initalised \n");
RTC_INIT_STATUS = 1;
- FCTN_CDMS_WR_FLASH(5,1);
+ WRITE_TO_EEPROM(5,(int32_t)1);
+ //FCTN_CDMS_WR_FLASH(5,1);
SPI_mutex.unlock();
}
--- a/cdms_sd.h Mon Jan 02 14:21:44 2017 +0000
+++ b/cdms_sd.h Wed Jan 04 10:55:22 2017 +0000
@@ -105,7 +105,8 @@
SD_MNG_SECT += SD_LIB_WRITES/(int)0xFFFF;
if(SD_MNG_SECT != SD_LIB_BLK_CURRENT) {
SD_LIB_BLK_CURRENT = SD_MNG_SECT;
- FCTN_CDMS_WR_FLASH(16,SD_LIB_BLK_CURRENT);
+ WRITE_TO_EEPROM(16, (int32_t)SD_LIB_BLK_CURRENT);
+ //FCTN_CDMS_WR_FLASH(16,SD_LIB_BLK_CURRENT);
}
SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF;
disk_write(buffer,SD_MNG_SECT);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.lib Wed Jan 04 10:55:22 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/bborredon/code/eeprom/#925096a4c7f0
--- a/main.cpp Mon Jan 02 14:21:44 2017 +0000
+++ b/main.cpp Wed Jan 04 10:55:22 2017 +0000
@@ -14,6 +14,8 @@
#include "DefinitionsAndGlobals.h"
#include "crc.h"
#include "i2c.h"
+#include "eeprom.h"
+#include "E2PROM.h"
#include "COM_SND_TM_functions.h"
#include "Flash.h"
#include "cdms_rtc.h"
@@ -84,9 +86,11 @@
FCTN_CDMS_SD_INIT();/* sd card initialization*/
CDMS_RESET_COUNTER++;
- FCTN_CDMS_WR_FLASH(17,CDMS_RESET_COUNTER);
+ WRITE_TO_EEPROM(17,(int32_t)CDMS_RESET_COUNTER);
+ //FCTN_CDMS_WR_FLASH(17,CDMS_RESET_COUNTER);
TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
- FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET);
+ WRITE_TO_EEPROM(8,(int32_t)TIME_LATEST_CDSMS_RESET);
+ //FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET);
uint8_t test[512];
for(int i =0; i<512; i++)
