Prusa MINI Firmware overview
diskio.h File Reference
#include "integer.h"

Go to the source code of this file.

Macros

#define _USE_WRITE   1 /* 1: Enable disk_write function */
 
#define _USE_IOCTL   1 /* 1: Enable disk_ioctl function */
 
#define STA_NOINIT   0x01 /* Drive not initialized */
 
#define STA_NODISK   0x02 /* No medium in the drive */
 
#define STA_PROTECT   0x04 /* Write protected */
 
#define CTRL_SYNC   0 /* Complete pending write process (needed at _FS_READONLY == 0) */
 
#define GET_SECTOR_COUNT   1 /* Get media size (needed at _USE_MKFS == 1) */
 
#define GET_SECTOR_SIZE   2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
 
#define GET_BLOCK_SIZE   3 /* Get erase block size (needed at _USE_MKFS == 1) */
 
#define CTRL_TRIM   4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
 
#define CTRL_POWER   5 /* Get/Set power status */
 
#define CTRL_LOCK   6 /* Lock/Unlock media removal */
 
#define CTRL_EJECT   7 /* Eject media */
 
#define CTRL_FORMAT   8 /* Create physical format on the media */
 
#define MMC_GET_TYPE   10 /* Get card type */
 
#define MMC_GET_CSD   11 /* Get CSD */
 
#define MMC_GET_CID   12 /* Get CID */
 
#define MMC_GET_OCR   13 /* Get OCR */
 
#define MMC_GET_SDSTAT   14 /* Get SD status */
 
#define ATA_GET_REV   20 /* Get F/W revision */
 
#define ATA_GET_MODEL   21 /* Get model name */
 
#define ATA_GET_SN   22 /* Get serial number */
 

Typedefs

typedef BYTE DSTATUS
 

Enumerations

enum  DRESULT {
  RES_OK = 0, RES_ERROR, RES_WRPRT, RES_NOTRDY,
  RES_PARERR, RES_OK = 0, RES_ERROR, RES_WRPRT,
  RES_NOTRDY, RES_PARERR
}
 

Functions

DSTATUS disk_initialize (BYTE pdrv)
 Initializes a Drive. More...
 
DSTATUS disk_status (BYTE pdrv)
 Gets Disk Status. More...
 
DRESULT disk_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
 Reads Sector(s) More...
 
DRESULT disk_write (BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
 Writes Sector(s) More...
 
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void *buff)
 I/O control operation. More...
 
DWORD get_fattime (void)
 Gets Time from RTC. More...
 

Macro Definition Documentation

◆ _USE_WRITE

#define _USE_WRITE   1 /* 1: Enable disk_write function */

◆ _USE_IOCTL

#define _USE_IOCTL   1 /* 1: Enable disk_ioctl function */

◆ STA_NOINIT

#define STA_NOINIT   0x01 /* Drive not initialized */

◆ STA_NODISK

#define STA_NODISK   0x02 /* No medium in the drive */

◆ STA_PROTECT

#define STA_PROTECT   0x04 /* Write protected */

◆ CTRL_SYNC

#define CTRL_SYNC   0 /* Complete pending write process (needed at _FS_READONLY == 0) */

◆ GET_SECTOR_COUNT

#define GET_SECTOR_COUNT   1 /* Get media size (needed at _USE_MKFS == 1) */

◆ GET_SECTOR_SIZE

#define GET_SECTOR_SIZE   2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */

◆ GET_BLOCK_SIZE

#define GET_BLOCK_SIZE   3 /* Get erase block size (needed at _USE_MKFS == 1) */

◆ CTRL_TRIM

#define CTRL_TRIM   4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */

◆ CTRL_POWER

#define CTRL_POWER   5 /* Get/Set power status */

◆ CTRL_LOCK

#define CTRL_LOCK   6 /* Lock/Unlock media removal */

◆ CTRL_EJECT

#define CTRL_EJECT   7 /* Eject media */

◆ CTRL_FORMAT

#define CTRL_FORMAT   8 /* Create physical format on the media */

◆ MMC_GET_TYPE

#define MMC_GET_TYPE   10 /* Get card type */

◆ MMC_GET_CSD

#define MMC_GET_CSD   11 /* Get CSD */

◆ MMC_GET_CID

#define MMC_GET_CID   12 /* Get CID */

◆ MMC_GET_OCR

#define MMC_GET_OCR   13 /* Get OCR */

◆ MMC_GET_SDSTAT

#define MMC_GET_SDSTAT   14 /* Get SD status */

◆ ATA_GET_REV

#define ATA_GET_REV   20 /* Get F/W revision */

◆ ATA_GET_MODEL

#define ATA_GET_MODEL   21 /* Get model name */

◆ ATA_GET_SN

#define ATA_GET_SN   22 /* Get serial number */

Typedef Documentation

◆ DSTATUS

typedef BYTE DSTATUS

Enumeration Type Documentation

◆ DRESULT

enum DRESULT
Enumerator
RES_OK 
RES_ERROR 
RES_WRPRT 
RES_NOTRDY 
RES_PARERR 
RES_OK 
RES_ERROR 
RES_WRPRT 
RES_NOTRDY 
RES_PARERR 
22  {
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;

Function Documentation

◆ disk_initialize()

DSTATUS disk_initialize ( BYTE  pdrv)

Initializes a Drive.

Parameters
pdrvPhysical drive number (0..)
Return values
DSTATUSOperation status
94 {
95  DSTATUS stat = RES_OK;
96 
97  if(disk.is_initialized[pdrv] == 0)
98  {
99  disk.is_initialized[pdrv] = 1;
100  stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
101  }
102  return stat;
103 }

◆ disk_status()

DSTATUS disk_status ( BYTE  pdrv)

Gets Disk Status.

Parameters
pdrvPhysical drive number (0..)
Return values
DSTATUSOperation status
79 {
80  DSTATUS stat;
81 
82  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
83  return stat;
84 }

◆ disk_read()

DRESULT disk_read ( BYTE  pdrv,
BYTE buff,
DWORD  sector,
UINT  count 
)

Reads Sector(s)

Parameters
pdrvPhysical drive number (0..)
*buffData buffer to store read data
sectorSector address (LBA)
countNumber of sectors to read (1..128)
Return values
DRESULTOperation result
119 {
120  DRESULT res;
121 
122  res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
123  return res;
124 }

◆ disk_write()

DRESULT disk_write ( BYTE  pdrv,
const BYTE buff,
DWORD  sector,
UINT  count 
)

Writes Sector(s)

Parameters
pdrvPhysical drive number (0..)
*buffData to be written
sectorSector address (LBA)
countNumber of sectors to write (1..128)
Return values
DRESULTOperation result
141 {
142  DRESULT res;
143 
144  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
145  return res;
146 }

◆ disk_ioctl()

DRESULT disk_ioctl ( BYTE  pdrv,
BYTE  cmd,
void buff 
)

I/O control operation.

Parameters
pdrvPhysical drive number (0..)
cmdControl code
*buffBuffer to send/receive control data
Return values
DRESULTOperation result
162 {
163  DRESULT res;
164 
165  res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
166  return res;
167 }

◆ get_fattime()

DWORD get_fattime ( void  )

Gets Time from RTC.

Parameters
None
Return values
Timein DWORD
176 {
177  return 0;
178 }
RES_WRPRT
Definition: diskio.h:25
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::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_drvTypeDef::drv
const Diskio_drvTypeDef * drv[_VOLUMES]
Definition: ff_gen_drv.h:87
RES_PARERR
Definition: diskio.h:27
RES_OK
Definition: onboard_sd.h:23
DSTATUS
BYTE DSTATUS
Definition: onboard_sd.h:19
Diskio_drvTypeDef::disk_write
DRESULT(* disk_write)(BYTE, const BYTE *, DWORD, UINT)
Definition: ff_gen_drv.h:73
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
RES_OK
Definition: diskio.h:23
Diskio_drvTypeDef::disk_ioctl
DRESULT(* disk_ioctl)(BYTE, BYTE, void *)
Definition: ff_gen_drv.h:76