]> cloudbase.mooo.com Git - z180-stamp.git/blame - include/diskio.h
Adaptions for fatfs R0.15
[z180-stamp.git] / include / diskio.h
CommitLineData
7aaec0f9
L
1/*-----------------------------------------------------------------------/
2/ Low level disk interface modlue include file (C)ChaN, 2019 /
7f552300
L
3/-----------------------------------------------------------------------*/
4
7aaec0f9
L
5#ifndef _DISKIO_DEFINED
6#define _DISKIO_DEFINED
7f552300 7
7aaec0f9
L
8#ifdef __cplusplus
9extern "C" {
10#endif
7f552300 11
7aaec0f9 12#include "ff.h"
7f552300
L
13
14
15/* Status of Disk Functions */
16typedef BYTE DSTATUS;
17
18/* Results of Disk Functions */
19typedef enum {
20 RES_OK = 0, /* 0: Successful */
21 RES_ERROR, /* 1: R/W Error */
22 RES_WRPRT, /* 2: Write Protected */
23 RES_NOTRDY, /* 3: Not Ready */
24 RES_PARERR /* 4: Invalid Parameter */
25} DRESULT;
26
27
28/*---------------------------------------*/
29/* Prototypes for disk control functions */
30
7aaec0f9
L
31DSTATUS disk_initialize (BYTE pdrv);
32DSTATUS disk_status (BYTE pdrv);
33DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
34DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
35DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
7f552300
L
36void disk_timerproc (void);
37
38
39
40/* Disk Status Bits (DSTATUS) */
41
42#define STA_NOINIT 0x01 /* Drive not initialized */
43#define STA_NODISK 0x02 /* No medium in the drive */
44#define STA_PROTECT 0x04 /* Write protected */
a870134a 45#define STA_FAST 0x08 /* Fast SPI clock */
11b53d3f 46#define STAT_MASK (STA_NOINIT | STA_NODISK | STA_PROTECT)
7f552300
L
47
48
7aaec0f9 49/* Command code for disk_ioctrl function */
7f552300
L
50
51/* Generic command (Used by FatFs) */
7aaec0f9
L
52#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
53#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
54#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
55#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
56#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
7f552300
L
57
58/* Generic command (Not used by FatFs) */
59#define CTRL_FORMAT 5 /* Create physical format on the media */
60#define CTRL_POWER_IDLE 6 /* Put the device idle state */
61#define CTRL_POWER_OFF 7 /* Put the device off state */
62#define CTRL_LOCK 8 /* Lock media removal */
63#define CTRL_UNLOCK 9 /* Unlock media removal */
64#define CTRL_EJECT 10 /* Eject media */
65
66/* MMC/SDC specific command (Not used by FatFs) */
67#define MMC_GET_TYPE 50 /* Get card type */
68#define MMC_GET_CSD 51 /* Get CSD */
69#define MMC_GET_CID 52 /* Get CID */
70#define MMC_GET_OCR 53 /* Get OCR */
71#define MMC_GET_SDSTAT 54 /* Get SD status */
72
73/* ATA/CF specific command (Not used by FatFs) */
74#define ATA_GET_REV 60 /* Get F/W revision */
75#define ATA_GET_MODEL 61 /* Get model name */
76#define ATA_GET_SN 62 /* Get serial number */
77
78/* MMC card type flags (MMC_GET_TYPE) */
79#define CT_MMC 0x01 /* MMC ver 3 */
80#define CT_SD1 0x02 /* SD ver 1 */
81#define CT_SD2 0x04 /* SD ver 2 */
82#define CT_SDC (CT_SD1|CT_SD2) /* SD */
83#define CT_BLOCK 0x08 /* Block addressing */
84
85#endif /* _DISKIO_H */