|
@ -19,14 +19,13 @@ |
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
#ifdef __STM32F1__ |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* PersistentStore for Arduino-style EEPROM interface |
|
|
* PersistentStore for Arduino-style EEPROM interface |
|
|
* with simple implementations supplied by Marlin. |
|
|
* with simple implementations supplied by Marlin. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
#ifdef __STM32F1__ |
|
|
|
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h" |
|
|
#include "../../inc/MarlinConfig.h" |
|
|
|
|
|
|
|
|
#if ENABLED(IIC_BL24CXX_EEPROM) |
|
|
#if ENABLED(IIC_BL24CXX_EEPROM) |
|
@ -48,13 +47,11 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } |
|
|
bool PersistentStore::access_finish() { return true; } |
|
|
bool PersistentStore::access_finish() { return true; } |
|
|
|
|
|
|
|
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
|
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { |
|
|
size_t written = 0; |
|
|
uint16_t written = 0; |
|
|
while (size--) { |
|
|
while (size--) { |
|
|
uint8_t v = *value; |
|
|
uint8_t v = *value; |
|
|
uint8_t * const p = (uint8_t * const)pos; |
|
|
uint8_t * const p = (uint8_t * const)pos; |
|
|
// EEPROM has only ~100,000 write cycles,
|
|
|
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
|
|
|
// so only write bytes that have changed!
|
|
|
|
|
|
if (v != eeprom_read_byte(p)) { |
|
|
|
|
|
eeprom_write_byte(p, v); |
|
|
eeprom_write_byte(p, v); |
|
|
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
|
|
|
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
|
|
|
if (eeprom_read_byte(p) != v) { |
|
|
if (eeprom_read_byte(p) != v) { |
|
|