Added checks to detect and work with faulty SEEPROM.

This commit is contained in:
skarg
2012-12-22 05:41:38 +00:00
parent 4c0599f104
commit d9877756bf
2 changed files with 25 additions and 6 deletions
+11 -4
View File
@@ -61,17 +61,24 @@ static bool seeprom_version_test(
uint16_t version = 0;
uint16_t id = 0;
bool status = false;
int rv;
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
seeprom_bytes_read(NV_SEEPROM_VERSION_0, (uint8_t *) & version, 2);
rv = seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
if (rv > 0) {
rv = seeprom_bytes_read(NV_SEEPROM_VERSION_0, (uint8_t *) & version, 2);
}
if ((id == SEEPROM_ID) && (version == SEEPROM_VERSION)) {
if ((rv > 0) && (id == SEEPROM_ID) && (version == SEEPROM_VERSION)) {
status = true;
} else {
} else if (rv > 0) {
version = SEEPROM_VERSION;
id = SEEPROM_ID;
seeprom_bytes_write(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
seeprom_bytes_write(NV_SEEPROM_VERSION_0, (uint8_t *) & version, 2);
} else {
while (1) {
/* SEEPROM is faulty! */
}
}
return status;