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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <https://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 EITHER(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 ENABLED(SOFTWARE_SPI)
  37. #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN."
  38. #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD
  39. #else
  40. // hardware pin defs
  41. #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS.
  42. #endif
  43. class Sd2Card {
  44. private:
  45. uint32_t pos;
  46. static void usbStateDebug();
  47. public:
  48. static bool usbStartup();
  49. bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN);
  50. static void idle();
  51. inline bool readStart(const uint32_t block) { pos = block; return ready(); }
  52. inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); }
  53. inline bool readStop() const { return true; }
  54. inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); }
  55. inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); }
  56. inline bool writeStop() const { return true; }
  57. bool readBlock(uint32_t block, uint8_t* dst);
  58. bool writeBlock(uint32_t blockNumber, const uint8_t* src);
  59. uint32_t cardSize();
  60. static bool isInserted();
  61. static bool ready();
  62. };