My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

persistent_store_impl.cpp 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
  2. #include "../../inc/MarlinConfig.h"
  3. #if ENABLED(EEPROM_SETTINGS)
  4. #include "../shared/persistent_store_api.h"
  5. namespace HAL {
  6. namespace PersistentStore {
  7. bool access_start() { return true; }
  8. bool access_finish() { return true; }
  9. bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
  10. while (size--) {
  11. uint8_t * const p = (uint8_t * const)pos;
  12. uint8_t v = *value;
  13. // EEPROM has only ~100,000 write cycles,
  14. // so only write bytes that have changed!
  15. if (v != eeprom_read_byte(p)) {
  16. eeprom_write_byte(p, v);
  17. if (eeprom_read_byte(p) != v) {
  18. SERIAL_ECHO_MSG(MSG_ERR_EEPROM_WRITE);
  19. return true;
  20. }
  21. }
  22. crc16(crc, &v, 1);
  23. pos++;
  24. value++;
  25. };
  26. return false;
  27. }
  28. bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
  29. do {
  30. uint8_t c = eeprom_read_byte((uint8_t*)pos);
  31. if (writing) *value = c;
  32. crc16(crc, &c, 1);
  33. pos++;
  34. value++;
  35. } while (--size);
  36. return false;
  37. }
  38. } // PersistentStore
  39. } // HAL
  40. #endif // EEPROM_SETTINGS
  41. #endif // __MK64FX512__ || __MK66FX1M0__