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.

eeprom_qspi.cpp 1.8KB

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