working version
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
EEPROM.h
- Committer:
- samp1234
- Date:
- 2017-02-21
- Revision:
- 353:e1803e801e20
- Parent:
- 352:022c513aee03
File content as of revision 353:e1803e801e20:
#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,35001,0xff,300,85,20,20,3,8000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint32_t flasharray_thres[32]; void WRITE_TO_EEPROM(uint32_t address, int32_t data_block) { e2prom.write(address*4+10,data_block); } void THRES_WRITE_TO_EEPROM(uint16_t mid, uint32_t* thres_data) { int8_t data[128]; memcpy(data,&thres_data,128); if(mid <11 & mid >1) { e2prom.write((uint32_t)(mid-1)*128,data,128); } } uint32_t READ_FROM_EERPOM(uint32_t address) { int32_t data; e2prom.read(address*4+10, data); return (uint32_t)data; } void INIT_EEPROM() { // int32_t test_buffer; // e2prom.ready(); // e2prom.read(2,test_buffer); /* if(test_buffer == 0) { for(int i=0;i<32;i++) WRITE_TO_EEPROM( i, INITIAL_EEPROM[i]); e2prom.write(2,1); gPC.printf("starting flash"); } */ gPC.printf("Reading intial parametrs from flash\n"); EPS_V_A_EN_STATUS = READ_FROM_EERPOM(0); // ok BAE_STATUS = READ_FROM_EERPOM(1); //ok SD_STATUS = READ_FROM_EERPOM(2); //ok PL_STATUS = READ_FROM_EERPOM(3); //ok PL_EPS_LATCH_SW_EN = READ_FROM_EERPOM(4); //ok RTC_INIT_STATUS = READ_FROM_EERPOM(5); CDMS_RTC_DISABLE = READ_FROM_EERPOM(6); EN_RTC = CDMS_RTC_DISABLE&0x01; CDMS_RESET_COUNTER = READ_FROM_EERPOM(7); //ok // 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); // added by samp if (CDMS_RTC_DISABLE ==0) { gCS_RTC=0; spi.write(0x8C); //register address with write flag spi.write(0x40);//enabling halt bit in the seconds register gCS_RTC=1; } } #endif