SD File System

Committer:
lucydamon
Date:
Thu Dec 01 23:57:53 2022 +0000
Revision:
0:4c17779d2cc6
1st commit- code but not working needs some debugs;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lucydamon 0:4c17779d2cc6 1 /*-----------------------------------------------------------------------/
lucydamon 0:4c17779d2cc6 2 / Low level disk interface modlue include file (C)ChaN, 2014 /
lucydamon 0:4c17779d2cc6 3 /-----------------------------------------------------------------------*/
lucydamon 0:4c17779d2cc6 4
lucydamon 0:4c17779d2cc6 5 #ifndef _DISKIO_DEFINED
lucydamon 0:4c17779d2cc6 6 #define _DISKIO_DEFINED
lucydamon 0:4c17779d2cc6 7
lucydamon 0:4c17779d2cc6 8 #ifdef __cplusplus
lucydamon 0:4c17779d2cc6 9 extern "C" {
lucydamon 0:4c17779d2cc6 10 #endif
lucydamon 0:4c17779d2cc6 11
lucydamon 0:4c17779d2cc6 12 #define _USE_WRITE 1 /* 1: Enable disk_write function */
lucydamon 0:4c17779d2cc6 13 #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
lucydamon 0:4c17779d2cc6 14
lucydamon 0:4c17779d2cc6 15 #include "integer.h"
lucydamon 0:4c17779d2cc6 16
lucydamon 0:4c17779d2cc6 17
lucydamon 0:4c17779d2cc6 18 /* Status of Disk Functions */
lucydamon 0:4c17779d2cc6 19 typedef BYTE DSTATUS;
lucydamon 0:4c17779d2cc6 20
lucydamon 0:4c17779d2cc6 21 /* Results of Disk Functions */
lucydamon 0:4c17779d2cc6 22 typedef enum {
lucydamon 0:4c17779d2cc6 23 RES_OK = 0, /* 0: Successful */
lucydamon 0:4c17779d2cc6 24 RES_ERROR, /* 1: R/W Error */
lucydamon 0:4c17779d2cc6 25 RES_WRPRT, /* 2: Write Protected */
lucydamon 0:4c17779d2cc6 26 RES_NOTRDY, /* 3: Not Ready */
lucydamon 0:4c17779d2cc6 27 RES_PARERR /* 4: Invalid Parameter */
lucydamon 0:4c17779d2cc6 28 } DRESULT;
lucydamon 0:4c17779d2cc6 29
lucydamon 0:4c17779d2cc6 30
lucydamon 0:4c17779d2cc6 31 /*---------------------------------------*/
lucydamon 0:4c17779d2cc6 32 /* Prototypes for disk control functions */
lucydamon 0:4c17779d2cc6 33
lucydamon 0:4c17779d2cc6 34
lucydamon 0:4c17779d2cc6 35 DSTATUS disk_initialize (BYTE pdrv);
lucydamon 0:4c17779d2cc6 36 DSTATUS disk_status (BYTE pdrv);
lucydamon 0:4c17779d2cc6 37 DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
lucydamon 0:4c17779d2cc6 38 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
lucydamon 0:4c17779d2cc6 39 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
lucydamon 0:4c17779d2cc6 40
lucydamon 0:4c17779d2cc6 41
lucydamon 0:4c17779d2cc6 42 /* Disk Status Bits (DSTATUS) */
lucydamon 0:4c17779d2cc6 43
lucydamon 0:4c17779d2cc6 44 #define STA_NOINIT 0x01 /* Drive not initialized */
lucydamon 0:4c17779d2cc6 45 #define STA_NODISK 0x02 /* No medium in the drive */
lucydamon 0:4c17779d2cc6 46 #define STA_PROTECT 0x04 /* Write protected */
lucydamon 0:4c17779d2cc6 47
lucydamon 0:4c17779d2cc6 48
lucydamon 0:4c17779d2cc6 49 /* Command code for disk_ioctrl fucntion */
lucydamon 0:4c17779d2cc6 50
lucydamon 0:4c17779d2cc6 51 /* Generic command (Used by FatFs) */
lucydamon 0:4c17779d2cc6 52 #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
lucydamon 0:4c17779d2cc6 53 #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
lucydamon 0:4c17779d2cc6 54 #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
lucydamon 0:4c17779d2cc6 55 #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
lucydamon 0:4c17779d2cc6 56 #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
lucydamon 0:4c17779d2cc6 57
lucydamon 0:4c17779d2cc6 58 /* Generic command (Not used by FatFs) */
lucydamon 0:4c17779d2cc6 59 #define CTRL_POWER 5 /* Get/Set power status */
lucydamon 0:4c17779d2cc6 60 #define CTRL_LOCK 6 /* Lock/Unlock media removal */
lucydamon 0:4c17779d2cc6 61 #define CTRL_EJECT 7 /* Eject media */
lucydamon 0:4c17779d2cc6 62 #define CTRL_FORMAT 8 /* Create physical format on the media */
lucydamon 0:4c17779d2cc6 63
lucydamon 0:4c17779d2cc6 64 /* MMC/SDC specific ioctl command */
lucydamon 0:4c17779d2cc6 65 #define MMC_GET_TYPE 10 /* Get card type */
lucydamon 0:4c17779d2cc6 66 #define MMC_GET_CSD 11 /* Get CSD */
lucydamon 0:4c17779d2cc6 67 #define MMC_GET_CID 12 /* Get CID */
lucydamon 0:4c17779d2cc6 68 #define MMC_GET_OCR 13 /* Get OCR */
lucydamon 0:4c17779d2cc6 69 #define MMC_GET_SDSTAT 14 /* Get SD status */
lucydamon 0:4c17779d2cc6 70
lucydamon 0:4c17779d2cc6 71 /* ATA/CF specific ioctl command */
lucydamon 0:4c17779d2cc6 72 #define ATA_GET_REV 20 /* Get F/W revision */
lucydamon 0:4c17779d2cc6 73 #define ATA_GET_MODEL 21 /* Get model name */
lucydamon 0:4c17779d2cc6 74 #define ATA_GET_SN 22 /* Get serial number */
lucydamon 0:4c17779d2cc6 75
lucydamon 0:4c17779d2cc6 76 #ifdef __cplusplus
lucydamon 0:4c17779d2cc6 77 }
lucydamon 0:4c17779d2cc6 78 #endif
lucydamon 0:4c17779d2cc6 79
lucydamon 0:4c17779d2cc6 80 #endif