Arduino FatFS
Loading...
Searching...
No Matches
IO.h
1
8#pragma once
9#include "../ff/ffdef.h"
10
11
12namespace fatfs {
13
14// forward declaration of FatFs
15class FatFs; // forward declaration
16
17
19enum DSTATUS {
20 STA_CLEAR=0X00,
21 STA_NOINIT=0x01,
22 STA_NODISK=0x02,
23 STA_PROTECT=0x04
24};
25
27enum DRESULT {
28 RES_OK = 0,
29 RES_ERROR,
30 RES_WRPRT,
31 RES_NOTRDY,
32 RES_PARERR
33};
34
35enum ioctl_cmd_t {
36 /* Generic command (Used by FatFs) */
37 CTRL_SYNC =
38 0, /* Complete pending write process (needed at FF_FS_READONLY == 0) */
39 GET_SECTOR_COUNT = 1, /* Get media size (needed at FF_USE_MKFS == 1) */
40 GET_SECTOR_SIZE = 2, /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
41 GET_BLOCK_SIZE = 3, /* Get erase block size (needed at FF_USE_MKFS == 1) \
42 */
43 CTRL_TRIM = 4, /* Inform device that the data on the block of sectors is no
44 longer used \ (needed at FF_USE_TRIM == 1) */
45
46 /* Generic command (Not used by FatFs) */
47 CTRL_POWER = 5, /* Get/Set power status */
48 CTRL_LOCK = 6, /* Lock/Unlock media removal */
49 CTRL_EJECT = 7, /* Eject media */
50 CTRL_FORMAT = 8, /* Create physical format on the media */
51
52 /* MMC/SDC specific ioctl command */
53 MMC_GET_TYPE = 10, /* Get card type */
54 MMC_GET_CSD = 11, /* Get CSD */
55 MMC_GET_CID = 12, /* Get CID */
56 MMC_GET_OCR = 13, /* Get OCR */
57 MMC_GET_SDSTAT = 14, /* Get SD status */
58 ISDIO_READ = 55, /* Read data form SD iSDIO register */
59 ISDIO_WRITE = 56, /* Write data to SD iSDIO register */
60 ISDIO_MRITE = 57, /* Masked write data to SD iSDIO register */
61
62 /* ATA/CF specific ioctl command */
63 ATA_GET_REV = 20, /* Get F/W revision */
64 ATA_GET_MODEL = 21, /* Get model name */
65 ATA_GET_SN = 22 /* Get serial number */
66};
67
74class IO {
75 public:
77 virtual FRESULT mount(FatFs& fs);
79 virtual FRESULT un_mount(FatFs& fs);
80
81 virtual DSTATUS disk_initialize(BYTE pdrv) = 0;
82 virtual DSTATUS disk_status(BYTE pdrv) = 0;
83 virtual DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector,
84 UINT count) = 0;
85 virtual DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector,
86 UINT count) = 0;
87 virtual DRESULT disk_ioctl(BYTE pdrv, ioctl_cmd_t cmd, void* buff) = 0;
88
89 FATFS fatfs;
90};
91
92} // namespace fatfs
93
94// Include FatFs header now to resolve the forward declaration
95#include "../ff/ff.h"
96
97namespace fatfs {
98
99// Inline implementations (moved from IO.cpp)
100inline FRESULT IO::mount(FatFs& fs) { return fs.f_mount(&fatfs, "", 0); }
101inline FRESULT IO::un_mount(FatFs& fs) { return fs.f_unmount(""); }
102
103} // namespace fatfs
API for FatFS See http://elm-chan.org/fsw/ff/00index_e.html.
Definition ff.h:34
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
Definition ff-inc.h:3527
FatFS interface definition.
Definition IO.h:74
virtual FRESULT un_mount(FatFs &fs)
unmount the file system - implementation at end of header to avoid recursive include
Definition IO.h:101
virtual FRESULT mount(FatFs &fs)
mount the file system - implementation at end of header to avoid recursive include
Definition IO.h:100
Definition ffdef.h:98