Skip to content

Commit

Permalink
Added STM32F411 NV write validation & Wire restart
Browse files Browse the repository at this point in the history
  • Loading branch information
hjd1964 committed May 3, 2021
1 parent be48e33 commit 1cb054e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/HAL/STM32F4/STM32F411.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ HardwareSerial HWSerial2(PA3, PA2); // RX2, TX2
#define NV_ENDURANCE HIGH
#define E2END 8191
#define I2C_EEPROM_ADDRESS 0x50
#define NV_VALIDATE
#include "../drivers/NV_I2C_EEPROM_24XX_C.h"
#elif defined(NV_MB85RC256V)
#include "../drivers/NV_I2C_FRAM_MB85RC256V.h"
Expand Down
14 changes: 14 additions & 0 deletions src/HAL/drivers/NV_I2C_EEPROM_24XX_C.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ class nvs {
if (dirtyW) {
j=cache[i]; // get data from cache
ee_write(i,j); // store in EEPROM
#ifdef NV_VALIDATE
uint8_t k;
ee_read(i,&k);
if (j!=k) {
//Serial.print("Write addr "); Serial.print(i); Serial.print(" value "); Serial.print(j); Serial.println(" FAILED");
//Serial.println("Restarting Wire");
HAL_Wire.end();
HAL_Wire.begin();
HAL_Wire.setClock(HAL_WIRE_CLOCK);
ee_write(i,j);
//ee_read(i,&k);
//if (j!=k) Serial.println("Second attempt FAILED"); else Serial.println("Second attempt SUCCESS");
}
#endif
bitWrite(cacheWriteState[i/8],i%8,0); // clean
} else {
// read data as required
Expand Down

0 comments on commit 1cb054e

Please sign in to comment.