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.

Sd2Card_FlashDrive.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * \file
  25. * \brief Sd2Card class for V2 SD/SDHC cards
  26. */
  27. #include "../SdFatConfig.h"
  28. #include "../SdInfo.h"
  29. /**
  30. * define SOFTWARE_SPI to use bit-bang SPI
  31. */
  32. #if MEGA_SOFT_SPI || USE_SOFTWARE_SPI
  33. #define SOFTWARE_SPI
  34. #endif
  35. // SPI pin definitions - do not edit here - change in SdFatConfig.h
  36. #if DISABLED(SOFTWARE_SPI)
  37. // hardware pin defs
  38. #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS.
  39. #else // SOFTWARE_SPI
  40. #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD
  41. #endif // SOFTWARE_SPI
  42. class Sd2Card {
  43. private:
  44. uint32_t pos;
  45. static void usbStateDebug();
  46. public:
  47. static bool usbStartup();
  48. bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN);
  49. static void idle();
  50. inline bool readStart(const uint32_t block) { pos = block; return ready(); }
  51. inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); }
  52. inline bool readStop() const { return true; }
  53. inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); }
  54. inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); }
  55. inline bool writeStop() const { return true; }
  56. bool readBlock(uint32_t block, uint8_t* dst);
  57. bool writeBlock(uint32_t blockNumber, const uint8_t* src);
  58. uint32_t cardSize();
  59. static bool isInserted();
  60. static bool ready();
  61. };