SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
diskio.h
Go to the documentation of this file.
1/*-----------------------------------------------------------------------/
2/ Low level disk interface modlue include file (C)ChaN, 2019 /
3/-----------------------------------------------------------------------*/
4
5#ifndef _DISKIO_DEFINED
6#define _DISKIO_DEFINED
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12/* Status of Disk Functions */
13typedef BYTE DSTATUS;
14
15/* Results of Disk Functions */
16typedef enum {
17 RES_OK = 0, /* 0: Successful */
18 RES_ERROR, /* 1: R/W Error */
19 RES_WRPRT, /* 2: Write Protected */
20 RES_NOTRDY, /* 3: Not Ready */
21 RES_PARERR /* 4: Invalid Parameter */
23
24/*---------------------------------------*/
25/* Prototypes for disk control functions */
26
29DRESULT disk_read(BYTE pdrv, BYTE *buff, LBA_t sector, UINT count);
30DRESULT disk_write(BYTE pdrv, const BYTE *buff, LBA_t sector, UINT count);
31DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff);
32
33/* Disk Status Bits (DSTATUS) */
34
35#define STA_NOINIT 0x01 /* Drive not initialized */
36#define STA_NODISK 0x02 /* No medium in the drive */
37#define STA_PROTECT 0x04 /* Write protected */
38
39/* Command code for disk_ioctrl fucntion */
40
41/* Generic command (Used by FatFs) */
42#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
43#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
44#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
45#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
46#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
47
48/* Generic command (Not used by FatFs) */
49#define CTRL_POWER 5 /* Get/Set power status */
50#define CTRL_LOCK 6 /* Lock/Unlock media removal */
51#define CTRL_EJECT 7 /* Eject media */
52#define CTRL_FORMAT 8 /* Create physical format on the media */
53
54/* MMC/SDC specific ioctl command */
55#define MMC_GET_TYPE 10 /* Get card type */
56#define MMC_GET_CSD 11 /* Get CSD */
57#define MMC_GET_CID 12 /* Get CID */
58#define MMC_GET_OCR 13 /* Get OCR */
59#define MMC_GET_SDSTAT 14 /* Get SD status */
60#define ISDIO_READ 55 /* Read data form SD iSDIO register */
61#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
62#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
63
64/* ATA/CF specific ioctl command */
65#define ATA_GET_REV 20 /* Get F/W revision */
66#define ATA_GET_MODEL 21 /* Get model name */
67#define ATA_GET_SN 22 /* Get serial number */
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif
DRESULT disk_read(BYTE pdrv, BYTE *buff, LBA_t sector, UINT count)
Definition diskio.c:77
DSTATUS disk_initialize(BYTE pdrv)
Definition diskio.c:63
DSTATUS disk_status(BYTE pdrv)
Definition diskio.c:50
DRESULT
Definition diskio.h:16
@ RES_OK
Definition diskio.h:17
@ RES_WRPRT
Definition diskio.h:19
@ RES_ERROR
Definition diskio.h:18
@ RES_NOTRDY
Definition diskio.h:20
@ RES_PARERR
Definition diskio.h:21
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
Definition diskio.c:160
DRESULT disk_write(BYTE pdrv, const BYTE *buff, LBA_t sector, UINT count)
Definition diskio.c:139
BYTE DSTATUS
Definition diskio.h:13
unsigned int UINT
Definition ff.h:56
unsigned char BYTE
Definition ff.h:57
QWORD LBA_t
Definition ff.h:71