ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
diskio.c
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module glue functions (C)ChaN, 2016 */
3 /*-----------------------------------------------------------------------*/
4 /* If a working storage control module is available, it should be */
5 /* attached to the FatFs via a glue function rather than modifying it. */
6 /* This is an example of glue functions to attach various exsisting */
7 /* storage control modules to the FatFs module with a defined API. */
8 /*-----------------------------------------------------------------------*/
9 
10 #define DRV_MMC 0
11 
12 /* mmc.c */
13 #include "user_config.h"
14 #include "fatfs.h"
15 //#include "mmc_hal.h"
16 
17 
18 #include "diskio.h" /* FatFs lower layer API */
19 #ifdef DRV_CFC
20 #include "cfc.h" /* Header file of existing CF control module */
21 #endif
22 #ifdef DRV_MMC
23 #include "mmc.h" /* Header file of existing SD control module */
24 #endif
25 
26 
27 /*-----------------------------------------------------------------------*/
28 /* Get Drive Status */
29 /*-----------------------------------------------------------------------*/
30 
32  BYTE pdrv /* Physical drive nmuber to identify the drive */
33 )
34 {
35  switch (pdrv) {
36 #ifdef DRV_CFC
37  case DRV_CFC :
38  return cf_disk_status();
39 #endif
40 #ifdef DRV_MMC
41  case DRV_MMC :
42  return mmc_disk_status();
43 #endif
44  }
45  return STA_NOINIT;
46 }
47 
48 
49 
50 /*-----------------------------------------------------------------------*/
51 /* Inidialize a Drive */
52 /*-----------------------------------------------------------------------*/
53 
55  BYTE pdrv /* Physical drive nmuber to identify the drive */
56 )
57 {
58  switch (pdrv) {
59 #ifdef DRV_CFC
60  case DRV_CFC :
61  return cf_disk_initialize();
62 #endif
63 #ifdef DRV_MMC
64  case DRV_MMC :
65  return mmc_disk_initialize();
66 #endif
67  }
68  return STA_NOINIT;
69 }
70 
71 
72 
73 /*-----------------------------------------------------------------------*/
74 /* Read Sector(s) */
75 /*-----------------------------------------------------------------------*/
76 
78  BYTE pdrv, /* Physical drive nmuber to identify the drive */
79  BYTE *buff, /* Data buffer to store read data */
80  DWORD sector, /* Sector address in LBA */
81  UINT count /* Number of sectors to read */
82 )
83 {
84  switch (pdrv) {
85 #ifdef DRV_CFC
86  case DRV_CFC :
87  return cf_disk_read(buff, sector, count);
88 #endif
89 #ifdef DRV_MMC
90  case DRV_MMC :
91  return mmc_disk_read(buff, sector, count);
92 #endif
93  }
94  return RES_PARERR;
95 }
96 
97 
98 
99 /*-----------------------------------------------------------------------*/
100 /* Write Sector(s) */
101 /*-----------------------------------------------------------------------*/
102 
103 #if _USE_WRITE
105  BYTE pdrv, /* Physical drive nmuber to identify the drive */
106  const BYTE *buff, /* Data to be written */
107  DWORD sector, /* Sector address in LBA */
108  UINT count /* Number of sectors to write */
109 )
110 {
111  switch (pdrv) {
112 #ifdef DRV_CFC
113  case DRV_CFC :
114  return cf_disk_write(buff, sector, count);
115 #endif
116 #ifdef DRV_MMC
117  case DRV_MMC :
118  return mmc_disk_write(buff, sector, count);
119 #endif
120  }
121  return RES_PARERR;
122 }
123 #endif
124 
125 
126 /*-----------------------------------------------------------------------*/
127 /* Miscellaneous Functions */
128 /*-----------------------------------------------------------------------*/
129 
130 #if _USE_IOCTL
132  BYTE pdrv, /* Physical drive nmuber (0..) */
133  BYTE cmd, /* Control code */
134  void *buff /* Buffer to send/receive control data */
135 )
136 {
137  switch (pdrv) {
138 #ifdef DRV_CFC
139  case DRV_CFC :
140  return cf_disk_ioctl(cmd, buff);
141 #endif
142 #ifdef DRV_MMC
143  case DRV_MMC :
144  return mmc_disk_ioctl(cmd, buff);
145 #endif
146  }
147  return RES_PARERR;
148 }
149 #endif
150 
151 
152 /*-----------------------------------------------------------------------*/
153 /* Timer driven procedure */
154 /*-----------------------------------------------------------------------*/
155 
156 
157 void disk_timerproc (void)
158 {
159 #ifdef DRV_CFC
160  cf_disk_timerproc();
161 #endif
162 #ifdef DRV_MMC
164 #endif
165 }
166 
167 
168 
MEMSPACE DSTATUS mmc_disk_initialize(void)
Public Functions.
Definition: mmc.c:340
#define STA_NOINIT
Definition: diskio.h:53
Master include file for project Includes all project includes and defines here.
MEMSPACE DSTATUS mmc_disk_status(void)
Get Disk Status.
Definition: mmc.c:420
MEMSPACE DRESULT mmc_disk_write(const BYTE *buff, DWORD sector, UINT count)
MEMSPACE DRESULT mmc_disk_read(BYTE *buff, DWORD sector, UINT count)
Read Sector(s)
Definition: mmc.c:433
void mmc_disk_timerproc(void)
Write Sector(s)
Definition: mmc.c:708
unsigned long DWORD
Definition: integer.h:31
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Definition: diskio.c:104
BYTE DSTATUS
Definition: diskio.h:20
DRESULT
Definition: diskio.h:23
unsigned char BYTE
Definition: integer.h:22
DSTATUS disk_status(BYTE pdrv)
Definition: diskio.c:31
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
Definition: diskio.c:131
#define DRV_MMC
Definition: diskio.c:10
DSTATUS disk_initialize(BYTE pdrv)
Definition: diskio.c:54
unsigned int UINT
Definition: integer.h:19
void disk_timerproc(void)
Definition: diskio.c:157
MEMSPACE DRESULT mmc_disk_ioctl(BYTE cmd, void *buff)
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Definition: diskio.c:77