EEPROM Library Overview  1.0
Modules | Functions | Variables
EEPROM Emulation Type A
Collaboration diagram for EEPROM Emulation Type A:

Modules

 EEPROM_TYPE_A_USER_CONFIGURABLE_PARAMETERS
 
 EEPROM_TYPE_A_LIB_PARAMETERS
 
 EEPROM_TYPE_A_STATUS
 

Functions

uint32_t EEPROM_TypeA_writeData (uint32_t *data)
 Store provided data to the virtual EEPROM. More...
 
uint32_t EEPROM_TypeA_init (uint32_t *data)
 Initialize the specified area in flash. More...
 
void EEPROM_TypeA_readData (uint32_t *data)
 Read the data from active record to the buffer in RAM. More...
 
bool EEPROM_TypeA_repairFormat (uint32_t *data)
 Repair the format. More...
 
void EEPROM_TypeA_searchCheck (void)
 Search the active record and check the format. More...
 
bool EEPROM_TypeA_eraseLastSector (void)
 Erase the previous sector of the active sector. More...
 
bool EEPROM_TypeA_eraseNonActiveSectors (void)
 Erases sectors other than the active sector. More...
 
bool EEPROM_TypeA_eraseAllSectors (void)
 Erase all sectors used by EEPROM emulation. More...
 

Variables

uint32_t gActiveRecordAddress
 Store the address of the current active record.
 
uint32_t gNextRecordAddress
 Store the address of the next active record.
 
uint16_t gActiveRecordNum
 Store the number of active records.
 
uint16_t gActiveSectorNum
 Store the number of active sectors.
 
bool gEEPROMTypeASearchFlag
 Indicate when the active record exists.
 
bool gEEPROMTypeAEraseFlag
 Indicate when the sector is full nad needs to be erased.
 
bool gEEPROMTypeAFormatErrorFlag
 Indicate when a format error is found.
 

Detailed Description

Overview

MSPM0 support EEPROM emulation through its internal Flash. Compared to using an external serial EEPROM, EEPROM emulation using the internal Flash saves pin usage and cost. The EEPROM emulation Type A solution is suitable if the user application needs to store large "blocks" of data.


Function Documentation

§ EEPROM_TypeA_writeData()

uint32_t EEPROM_TypeA_writeData ( uint32_t *  data)

Store provided data to the virtual EEPROM.

The function will store the data to the flash to be a new record. It will also add a header to the record to mark its state. When the flash sector is full, it will set the gEEPROMTypeAEraseFlag.

Parameters
[in]dataPointer to the buffer in RAM
Returns
Whether or not the program succeeded
Return values
EEPROM_EMULATION_WRITE_OKProgram was successful
EEPROM_EMULATION_FORMAT_ERRORNext address was not erased
Precondition
The user must ensure that the length of the buffer in RAM is equal to the length of the data portion of the record.
Postcondition
When the sector is full, the function only set the gEEPROMTypeAEraseFlag. The user should erase the sector before all sectors are full. Refer to EEPROM_TypeA_eraseLastSector.

§ EEPROM_TypeA_init()

uint32_t EEPROM_TypeA_init ( uint32_t *  data)

Initialize the specified area in flash.

The function will first search the active record and check the format at the specified area. If active record exists, it will copy the data of active record to the buffer in RAM. If format is not correct, it will repair the format.

Parameters
[in]dataPointer to the buffer in RAM
Returns
Whether or not the program succeeded
Return values
EEPROM_EMULATION_INIT_OKProgram was successful
EEPROM_EMULATION_INIT_ERRORNext address was not erased
Precondition
The user must ensure that the length of the buffer in RAM is equal to the length of the data portion of the record.
Postcondition
After EEPROM_TypeA_init, there will be a format-correct area in flash, a buffer in RAM copied the active record, and some global variables that have been written.

4 global variables about active record: gActiveRecordAddress gNextRecordAddress gActiveRecordNum gActiveSectorNum 3 global variables about format: gEEPROMTypeASearchFlag gEEPROMTypeAEraseFlag gEEPROMTypeAFormatErrorFlag

§ EEPROM_TypeA_readData()

void EEPROM_TypeA_readData ( uint32_t *  data)

Read the data from active record to the buffer in RAM.

Parameters
[in]dataPointer to the buffer in RAM
Precondition
The user must ensure that the length of the buffer in RAM is equal to the length of the data portion of the record.

§ EEPROM_TypeA_repairFormat()

bool EEPROM_TypeA_repairFormat ( uint32_t *  data)

Repair the format.

The function will first erase sectors other than the active sector. Then it will copy the data from the buffer in RAM to the beginning of next sector, which is to be new active record. 4 global variables about active record are updated too. Finally, the function erase the last sector

Parameters
[in]dataPointer to the buffer in RAM
Returns
Whether or not the program succeeded
Return values
falseProgram didn't succeed
trueProgram was successful
Precondition
The user must firstly prepare the data in RAM before call the function. The user must ensure that the length of the buffer in RAM is equal to the length of the data portion of the record.
Postcondition
After EEPROM_TypeA_repairFormat, all sectors are erased and the active record is at the beginning of next sector

NOTE: The user must firstly prepare the data in RAM before call the function. It is recommended to read active record into RAM first, then call the function to repair the format and write active record back.

§ EEPROM_TypeA_searchCheck()

void EEPROM_TypeA_searchCheck ( void  )

Search the active record and check the format.

The function will traverse records� header. If the active record exists, gEEPROMTypeASearchFlag will be set, and 4 global variables about active record are updated. If the format is wrong, gEEPROMTypeAFormatErrorFlag is set

Postcondition
If the active record exists, gEEPROMTypeASearchFlag will be set, and 4 global variables about active record are updated. If the format is wrong, gEEPROMTypeAFormatErrorFlag is set

§ EEPROM_TypeA_eraseLastSector()

bool EEPROM_TypeA_eraseLastSector ( void  )

Erase the previous sector of the active sector.

Returns
Whether or not the program succeeded
Return values
falseProgram didn't succeed
trueProgram was successful

According to gActiveSectorNum, the function can find the sector with active record. Then it will erase the previous sector

§ EEPROM_TypeA_eraseNonActiveSectors()

bool EEPROM_TypeA_eraseNonActiveSectors ( void  )

Erases sectors other than the active sector.

Returns
Whether or not the program succeeded
Return values
falseProgram didn't succeed
trueProgram was successful

According to gActiveSectorNum, the function can find the sector with active record. Then it will erase sectors other than the active sector

§ EEPROM_TypeA_eraseAllSectors()

bool EEPROM_TypeA_eraseAllSectors ( void  )

Erase all sectors used by EEPROM emulation.

Returns
Whether or not the program succeeded
Return values
falseProgram didn't succeed
trueProgram was successful
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale