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