1MB version
Dependencies: mbed EEPROM USBDevice
bbt_eeprom.h
00001 #include "mbed.h" 00002 #include "EEPROM.h" 00003 00004 #ifndef BBT_EEPROM_H 00005 #define BBT_EEPROM_H 00006 00007 #define BBT_EEPROM_SLOT_LENGTH 20 00008 #define BBT_EEPROM_SLOT_SIZE 2 00009 #define BBT_EEPROM_STATUS_ADDR 0 00010 #define BBT_EEPROM_TEMPSLOT_ADDR 1 00011 #define BBT_EEPROM_SLOT_BASE_ADDR 2 00012 00013 00014 class bbt_eeprom { 00015 public: 00016 bbt_eeprom(uint16_t offsetReservedBlockAddress); 00017 uint8_t getStatus_EEP(); 00018 void setStatus_EEP(uint8_t status); 00019 void clearAllSlot_EEP(); 00020 void setSlot_EEP(uint8_t slot, uint8_t broken, uint8_t used,uint16_t blockAddress); 00021 void getSlot_EEP(uint8_t slot, uint8_t * broken, uint8_t * used, uint16_t * blockAddress); 00022 00023 // Reserved Block Address <-> Slot translation 00024 uint16_t slotToReservedBlockAddress(uint8_t slot); 00025 uint8_t reservedBlockAddressToSlot(uint16_t reservedBlockAddress); 00026 00027 // get not broken not used slot 00028 uint8_t getFreeSlot_EEP(); 00029 00030 // build ram bbt table 00031 void updateTranslateTable(); 00032 00033 00034 // get translated block address 00035 uint16_t getTranslatedBlockAddress(uint16_t blockAddress); 00036 00037 void setTempSlot_EEP(uint8_t tempSlot); 00038 uint8_t getTempSlot_EEP(); 00039 void incrTempSlot_EEP(); 00040 00041 // build ram temp value 00042 void updateTempSlot(); 00043 00044 void setTempSlot(uint8_t tempSlot); 00045 uint8_t getTempSlot(); 00046 00047 bool isReservedBlockAddress(uint16_t blockAddress); 00048 00049 uint8_t get(uint16_t address); 00050 void put(uint16_t address,uint8_t data); 00051 00052 protected: 00053 EEPROM m_eeprom; 00054 uint16_t m_offsetReservedBlockAddress; 00055 uint16_t m_translateTableFrom[BBT_EEPROM_SLOT_LENGTH]; 00056 uint16_t m_translateTableTo[BBT_EEPROM_SLOT_LENGTH]; 00057 int m_translateTableMaxIndex; 00058 uint8_t m_tempSlot; 00059 }; 00060 00061 00062 #endif
Generated on Mon Jul 25 2022 04:43:05 by 1.7.2