My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Sd2Card_FlashDrive.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 USB Flash Drive
  26. */
  27. #include "../SdFatConfig.h"
  28. #include "../SdInfo.h"
  29. #include "../disk_io_driver.h"
  30. #if DISABLED(USE_OTG_USB_HOST)
  31. /**
  32. * Define SOFTWARE_SPI to use bit-bang SPI
  33. */
  34. #if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI)
  35. #define SOFTWARE_SPI
  36. #endif
  37. // SPI pin definitions - do not edit here - change in SdFatConfig.h
  38. #if ENABLED(SOFTWARE_SPI)
  39. #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN."
  40. #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD
  41. #else
  42. // hardware pin defs
  43. #define SD_CHIP_SELECT_PIN SD_SS_PIN // The default chip select pin for the SD card is SS.
  44. #endif
  45. #endif
  46. class DiskIODriver_USBFlash : public DiskIODriver {
  47. private:
  48. uint32_t pos;
  49. static void usbStateDebug();
  50. public:
  51. static bool usbStartup();
  52. static bool isInserted();
  53. bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN)) override;
  54. inline bool readCSD(csd_t*) override { return true; }
  55. inline bool readStart(const uint32_t block) override { pos = block; return isReady(); }
  56. inline bool readData(uint8_t *dst) override { return readBlock(pos++, dst); }
  57. inline bool readStop() override { return true; }
  58. inline bool writeStart(const uint32_t block, const uint32_t) override { pos = block; return isReady(); }
  59. inline bool writeData(const uint8_t *src) override { return writeBlock(pos++, src); }
  60. inline bool writeStop() override { return true; }
  61. bool readBlock(uint32_t block, uint8_t *dst) override;
  62. bool writeBlock(uint32_t blockNumber, const uint8_t *src) override;
  63. uint32_t cardSize() override;
  64. bool isReady() override;
  65. void idle() override;
  66. };