@santoshwagle
If I undestand you correctly, you're looking for a way to store configuration information (language specified) in a way that it can be changed and the last value is accessible upon boot.
Personally, I would select a free block of Flash memory and use it to store a configuration information. I recommend using the second to last block in Sector 1 - the last block of each sector is reserved for sector swap data (if this feature is used - but it's still good to not use it just as a rule of thumb in case you want to implement sector swapping for in field updates).
The configuration information would defined in a structure and look something like:
struct NVconfigStruct {
uint32_t checkWord;
uint32_t language;
// You can add more data items to the configuration structure
};
to point to the configuration information, you'll use the pointer "configPtr" (with setup code):
uint32_t sectorSize;
FLASH_GetProperty(&s_flashDriver
, kFLASH_PropertyPflash0SectorSize
, §orSize);
struct NVconfigStruct* configPtr = (struct NVconfigStruct*)((sectorSize * 2) - (FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE * 2));
In ram, you'll need to set up an NVconfigStruct Buffer:
struct NVconfigStruct configBuffer = { 0xA5A55A5A
, 2 // "language" = English (2)
};
In your start up code, you'll check to see if configPtr->checkWord == 0xFFFFFFFF; if the value is all Foxes, then this is the first time executing the application and you'll write configBuffer at configPtr to get an initial configuration:
if (0xFFFFFFFF == configPtr->checkWord) {
flashWrite(configPtr
, configBuffer
, FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE);
}
After this if statement executes, you'll know that the configuration is set and you can use configPtr->language as the user specified language value.
When you want to change the language, set the appropriate value to configBuffer.langauge and then write configBuffer into the sector of Flash at configPtr.
This approach is fairly easy to understand and does not rely on compiler idieosyncracies or esoteric type definitions and uses standard Flash writing methods which you already have working.