Depending on how critical the saved data is, you might want to consider something like the following:
Code:
#define MAX_INDEX 24
#define MAX_STRUCTURES_IN_EE 23
struct ee_data_element
{
Uint8 index,
Uint16 data,
Uint8 checksum,
};
What you would do when you want to read the EE is read from address 0
Calculate checksum of index and data and compare it to the checksum stored in the EE to verify that the data is OK (you are afterall concerned about losing data due to power loss, if you lose power during a write your data may be corrupt)
If data is OK, read the next address
Verify checksum
If data is OK, compare the index of the current read to the index of the previous read. If the index of the current read is not the index of the previous read plus 1, then the previous read is the latest data
When you want to write, perform the above action to find the last valid written data. Increment the index of that data structure by 1, calculate the checksum, and write it to the EEPROM
You need your max EE address to be less than the max index number allowed
You need to account for making your EE address and your structure index to roll-over
This is just a rough idea, may need some fleshing out