I've inherited an eeprom library for STM32 for an i2c device which is using the HAL_I2C_Mem_xxx library. What i've noticed is that for each saved parameter there are 2 copies of it. So in total 3 times the same value.
I was wondering if this is a safety mechanism to avoid wrong data to be written/read and if this is the state of the art when using an eeprom over i2c.
What's not completely clear is the following as well:
1. After each read call, all the 3 values are read and if the return state from the HAL_I2C_Mem_Read is different than HAL_OK, all the 3 values are overwritten in the memory with a default value --> shouldn't be better to retry a read call first?
2. If the read call returns 3 different values, all the 3 values are overwritten with a default value --> this could be the safest solution
3. If the last one in memory is equal to 1 of the 2 values and within boundaries, the last one in mem is copied to the one which is different so all 3 of them are equals. If outside boundaries the default is written in all of them.
4. If the first two are equal and the first in memory is within boundaries, the first one is written in the last one in memory.If outside boundaries the default is written in all of them.
Is all of this really needed nowadays?
Regards,