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,8 +48,6 @@ bool PersistentStore::access_start()  { eeprom_init(); return true; }
48 48
 bool PersistentStore::access_finish() { return true; }
49 49
 
50 50
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
51
-  size_t written = 0;
52
-
53 51
   while (size--) {
54 52
     uint8_t v = *value;
55 53
     uint8_t * const p = (uint8_t * const)pos;
@@ -57,10 +55,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
57 55
     // so only write bytes that have changed!
58 56
     if (v != eeprom_read_byte(p)) {
59 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 59
       if (eeprom_read_byte(p) != v) {
65 60
         SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
66 61
         return true;

Loading…
Cancel
Save