Browse Source

Tweak to EEPROM safe delay

Scott Lahteine 4 years ago
parent
commit
2e010909ac
1 changed files with 1 additions and 6 deletions
  1. 1
    6
      Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp

+ 1
- 6
Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp View File

48
 bool PersistentStore::access_finish() { return true; }
48
 bool PersistentStore::access_finish() { return true; }
49
 
49
 
50
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
50
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
51
-  size_t written = 0;
52
-
53
   while (size--) {
51
   while (size--) {
54
     uint8_t v = *value;
52
     uint8_t v = *value;
55
     uint8_t * const p = (uint8_t * const)pos;
53
     uint8_t * const p = (uint8_t * const)pos;
57
     // so only write bytes that have changed!
55
     // so only write bytes that have changed!
58
     if (v != eeprom_read_byte(p)) {
56
     if (v != eeprom_read_byte(p)) {
59
       eeprom_write_byte(p, v);
57
       eeprom_write_byte(p, v);
60
-      if (++written % 128 == 0)
61
-        safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
62
-      else
63
-        delay(2);
58
+      if (size & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
64
       if (eeprom_read_byte(p) != v) {
59
       if (eeprom_read_byte(p) != v) {
65
         SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
60
         SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
66
         return true;
61
         return true;

Loading…
Cancel
Save