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