My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

onboard_sd.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*-----------------------------------------------------------------------
  2. / * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  3. / * Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech]
  4. / * Low level disk interface module include file (C)ChaN, 2015
  5. /-----------------------------------------------------------------------*/
  6. #pragma once
  7. #define _DISKIO_WRITE 1 /* 1: Enable disk_write function */
  8. #define _DISKIO_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
  9. #define _DISKIO_ISDIO 0 /* 1: Enable iSDIO control fucntion */
  10. typedef unsigned char BYTE;
  11. typedef unsigned short WORD;
  12. typedef unsigned long DWORD;
  13. typedef unsigned int UINT;
  14. /* Status of Disk Functions */
  15. typedef BYTE DSTATUS;
  16. /* Results of Disk Functions */
  17. typedef enum {
  18. RES_OK = 0, /* 0: Successful */
  19. RES_ERROR, /* 1: R/W Error */
  20. RES_WRPRT, /* 2: Write Protected */
  21. RES_NOTRDY, /* 3: Not Ready */
  22. RES_PARERR /* 4: Invalid Parameter */
  23. } DRESULT;
  24. #if _DISKIO_ISDIO
  25. /* Command structure for iSDIO ioctl command */
  26. typedef struct {
  27. BYTE func; /* Function number: 0..7 */
  28. WORD ndata; /* Number of bytes to transfer: 1..512, or mask + data */
  29. DWORD addr; /* Register address: 0..0x1FFFF */
  30. void* data; /* Pointer to the data (to be written | read buffer) */
  31. } SDIO_CMD;
  32. #endif
  33. /*---------------------------------------*/
  34. /* Prototypes for disk control functions */
  35. DSTATUS disk_initialize(BYTE pdrv);
  36. DSTATUS disk_status(BYTE pdrv);
  37. DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
  38. #if _DISKIO_WRITE
  39. DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
  40. #endif
  41. #if _DISKIO_IOCTL
  42. DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff);
  43. #endif
  44. /* Disk Status Bits (DSTATUS) */
  45. #define STA_NOINIT 0x01 /* Drive not initialized */
  46. #define STA_NODISK 0x02 /* No medium in the drive */
  47. #define STA_PROTECT 0x04 /* Write protected */
  48. /* Command code for disk_ioctrl fucntion */
  49. /* Generic command (Used by FatFs) */
  50. #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
  51. #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
  52. #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
  53. #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
  54. #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
  55. /* Generic command (Not used by FatFs) */
  56. #define CTRL_FORMAT 5 /* Create physical format on the media */
  57. #define CTRL_POWER_IDLE 6 /* Put the device idle state */
  58. #define CTRL_POWER_OFF 7 /* Put the device off state */
  59. #define CTRL_LOCK 8 /* Lock media removal */
  60. #define CTRL_UNLOCK 9 /* Unlock media removal */
  61. #define CTRL_EJECT 10 /* Eject media */
  62. /* MMC/SDC specific ioctl command (Not used by FatFs) */
  63. #define MMC_GET_TYPE 50 /* Get card type */
  64. #define MMC_GET_CSD 51 /* Get CSD */
  65. #define MMC_GET_CID 52 /* Get CID */
  66. #define MMC_GET_OCR 53 /* Get OCR */
  67. #define MMC_GET_SDSTAT 54 /* Get SD status */
  68. #define ISDIO_READ 55 /* Read data form SD iSDIO register */
  69. #define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
  70. #define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
  71. /* ATA/CF specific ioctl command (Not used by FatFs) */
  72. #define ATA_GET_REV 60 /* Get F/W revision */
  73. #define ATA_GET_MODEL 61 /* Get model name */
  74. #define ATA_GET_SN 62 /* Get serial number */
  75. /* MMC card type flags (MMC_GET_TYPE) */
  76. #define CT_MMC 0x01 /* MMC ver 3 */
  77. #define CT_SD1 0x02 /* SD ver 1 */
  78. #define CT_SD2 0x04 /* SD ver 2 */
  79. #define CT_SDC (CT_SD1|CT_SD2) /* SD */
  80. #define CT_BLOCK 0x08 /* Block addressing */