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.0KB

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