My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

persistent_store_impl.cpp 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. #ifdef __MK20DX256__
  20. #include "../../inc/MarlinConfig.h"
  21. #if ENABLED(EEPROM_SETTINGS)
  22. #include "../shared/persistent_store_api.h"
  23. bool PersistentStore::access_start() { return true; }
  24. bool PersistentStore::access_finish() { return true; }
  25. bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
  26. while (size--) {
  27. uint8_t * const p = (uint8_t * const)pos;
  28. uint8_t v = *value;
  29. // EEPROM has only ~100,000 write cycles,
  30. // so only write bytes that have changed!
  31. if (v != eeprom_read_byte(p)) {
  32. eeprom_write_byte(p, v);
  33. if (eeprom_read_byte(p) != v) {
  34. SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
  35. return true;
  36. }
  37. }
  38. crc16(crc, &v, 1);
  39. pos++;
  40. value++;
  41. };
  42. return false;
  43. }
  44. bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
  45. do {
  46. uint8_t c = eeprom_read_byte((uint8_t*)pos);
  47. if (writing) *value = c;
  48. crc16(crc, &c, 1);
  49. pos++;
  50. value++;
  51. } while (--size);
  52. return false;
  53. }
  54. #endif // EEPROM_SETTINGS
  55. #endif // __MK20DX256__