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 eeprom mbed-rtos mbed FreescaleIAP
Fork of CDMS_CODE by
E2PROM.h@345:cdde554477cd, 2017-01-22 (annotated)
- Committer:
- chaithanyarss
- Date:
- Sun Jan 22 03:12:16 2017 +0000
- Revision:
- 345:cdde554477cd
- Parent:
- 344:1675dbde0bae
EERPOM completely added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| chaithanyarss | 343:cd7b1734f7a0 | 1 | #ifndef EEPROM_H |
| chaithanyarss | 343:cd7b1734f7a0 | 2 | #define EEPROM_H |
| chaithanyarss | 343:cd7b1734f7a0 | 3 | |
| chaithanyarss | 343:cd7b1734f7a0 | 4 | #define ee_scl PIN86 |
| chaithanyarss | 343:cd7b1734f7a0 | 5 | #define ee_sda PIN87 |
| chaithanyarss | 343:cd7b1734f7a0 | 6 | #define check 10 |
| chaithanyarss | 343:cd7b1734f7a0 | 7 | |
| chaithanyarss | 343:cd7b1734f7a0 | 8 | EEPROM e2prom(ee_sda, ee_scl, 0, EEPROM::T24C512); |
| chaithanyarss | 345:cdde554477cd | 9 | int32_t INITIAL_EEPROM[32] = {1,1,1,1,1,0,0,0,0,35001,0xff,300,85,20,20,3,80000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
| chaithanyarss | 343:cd7b1734f7a0 | 10 | |
| chaithanyarss | 343:cd7b1734f7a0 | 11 | void WRITE_TO_EEPROM(uint32_t address, int32_t data_block) |
| chaithanyarss | 343:cd7b1734f7a0 | 12 | { |
| chaithanyarss | 345:cdde554477cd | 13 | e2prom.write(address*4+10,data_block); |
| chaithanyarss | 343:cd7b1734f7a0 | 14 | } |
| chaithanyarss | 343:cd7b1734f7a0 | 15 | |
| chaithanyarss | 345:cdde554477cd | 16 | uint32_t READ_FROM_EERPOM(uint32_t address) |
| chaithanyarss | 343:cd7b1734f7a0 | 17 | { |
| chaithanyarss | 343:cd7b1734f7a0 | 18 | int32_t data; |
| chaithanyarss | 345:cdde554477cd | 19 | e2prom.read(address*4+10, data); |
| chaithanyarss | 345:cdde554477cd | 20 | return (uint32_t)data; |
| chaithanyarss | 343:cd7b1734f7a0 | 21 | } |
| chaithanyarss | 343:cd7b1734f7a0 | 22 | |
| chaithanyarss | 343:cd7b1734f7a0 | 23 | void INIT_EEPROM() |
| chaithanyarss | 343:cd7b1734f7a0 | 24 | { |
| chaithanyarss | 343:cd7b1734f7a0 | 25 | int32_t test_buffer; |
| chaithanyarss | 343:cd7b1734f7a0 | 26 | e2prom.ready(); |
| chaithanyarss | 345:cdde554477cd | 27 | e2prom.read(2,test_buffer); |
| chaithanyarss | 343:cd7b1734f7a0 | 28 | if(test_buffer == 0) |
| chaithanyarss | 343:cd7b1734f7a0 | 29 | { |
| chaithanyarss | 343:cd7b1734f7a0 | 30 | for(int i=0;i<32;i++) |
| chaithanyarss | 343:cd7b1734f7a0 | 31 | WRITE_TO_EEPROM( i, INITIAL_EEPROM[i]); |
| chaithanyarss | 343:cd7b1734f7a0 | 32 | |
| chaithanyarss | 345:cdde554477cd | 33 | e2prom.write(2,1); |
| chaithanyarss | 345:cdde554477cd | 34 | gPC.printf("starting flash"); |
| chaithanyarss | 343:cd7b1734f7a0 | 35 | } |
| chaithanyarss | 343:cd7b1734f7a0 | 36 | |
| chaithanyarss | 345:cdde554477cd | 37 | gPC.printf("Reading intial parametrs from flash\n"); |
| chaithanyarss | 343:cd7b1734f7a0 | 38 | EPS_V_A_EN_STATUS = READ_FROM_EERPOM(0); |
| chaithanyarss | 343:cd7b1734f7a0 | 39 | BAE_STATUS = READ_FROM_EERPOM(1); |
| chaithanyarss | 343:cd7b1734f7a0 | 40 | SD_STATUS = READ_FROM_EERPOM(2); |
| chaithanyarss | 343:cd7b1734f7a0 | 41 | PL_STATUS = READ_FROM_EERPOM(3); |
| chaithanyarss | 343:cd7b1734f7a0 | 42 | PL_EPS_LATCH_SW_EN = READ_FROM_EERPOM(4); |
| chaithanyarss | 343:cd7b1734f7a0 | 43 | RTC_INIT_STATUS = READ_FROM_EERPOM(5); |
| chaithanyarss | 343:cd7b1734f7a0 | 44 | CDMS_RTC_DISABLE = READ_FROM_EERPOM(6); |
| chaithanyarss | 343:cd7b1734f7a0 | 45 | CDMS_RESET_COUNTER = READ_FROM_EERPOM(7); |
| chaithanyarss | 343:cd7b1734f7a0 | 46 | TIME_LATEST_CDSMS_RESET = READ_FROM_EERPOM(8); |
| chaithanyarss | 343:cd7b1734f7a0 | 47 | COM_TC_BYTES_LIMIT = READ_FROM_EERPOM(9); |
| chaithanyarss | 343:cd7b1734f7a0 | 48 | COM_RX_CURRENT_MAX = READ_FROM_EERPOM(10); |
| chaithanyarss | 343:cd7b1734f7a0 | 49 | COM_RX_DISABLE_TIMEOUT = READ_FROM_EERPOM(11); |
| chaithanyarss | 343:cd7b1734f7a0 | 50 | COM_PA_TMP_HIGH = READ_FROM_EERPOM(12); |
| chaithanyarss | 343:cd7b1734f7a0 | 51 | COM_PA_RECOVERY_TIMEOUT = READ_FROM_EERPOM(13); |
| chaithanyarss | 343:cd7b1734f7a0 | 52 | COM_SESSION_TIMEOUT = READ_FROM_EERPOM(14); |
| chaithanyarss | 343:cd7b1734f7a0 | 53 | COM_RSSI_MIN = READ_FROM_EERPOM(15); |
| chaithanyarss | 343:cd7b1734f7a0 | 54 | SD_LIB_BLK_CURRENT = READ_FROM_EERPOM(16); |
| chaithanyarss | 343:cd7b1734f7a0 | 55 | } |
| chaithanyarss | 343:cd7b1734f7a0 | 56 | |
| chaithanyarss | 345:cdde554477cd | 57 | void THRES_WRITE_TO EEPROM(uint16_t mid, int8_t*data) |
| chaithanyarss | 345:cdde554477cd | 58 | { |
| chaithanyarss | 345:cdde554477cd | 59 | if(mid <11 & mid >1) |
| chaithanyarss | 345:cdde554477cd | 60 | { |
| chaithanyarss | 345:cdde554477cd | 61 | e2prom.write((mid-1)*128,data,128); |
| chaithanyarss | 345:cdde554477cd | 62 | } |
| chaithanyarss | 345:cdde554477cd | 63 | } |
| chaithanyarss | 343:cd7b1734f7a0 | 64 | #endif |
