Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate fatfs/diskio.c @ 49:ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
LFN doesn't work reliably so it's disabled for now.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 03 Apr 2013 23:34:20 +1030 |
parents | |
children |
rev | line source |
---|---|
49
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
3 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 /* If a working storage control module is available, it should be */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 /* attached to the FatFs via a glue function rather than modifying it. */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 /* This is an example of glue functions to attach various exsisting */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 /* storage control module to the FatFs module with a defined API. */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 #include "diskio.h" /* FatFs lower layer API */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
11 #include "usbdisk.h" /* Example: USB drive control */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 #include "atadrive.h" /* Example: ATA drive control */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 #include "sdcard.h" /* Example: MMC/SDC contorl */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
14 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 /* Definitions of physical drive number for each media */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 #define ATA 0 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
17 #define MMC 1 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 #define USB 2 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
22 /* Inidialize a Drive */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
23 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
24 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
25 DSTATUS disk_initialize ( |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 BYTE pdrv /* Physical drive nmuber (0..) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 ) |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 DSTATUS stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 int result; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
31 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 switch (pdrv) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 case ATA : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 result = ATA_disk_initialize(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 case MMC : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 result = MMC_disk_initialize(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 case USB : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 result = USB_disk_initialize(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
49 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
52 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 return STA_NOINIT; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
57 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 /* Get Disk Status */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
61 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 DSTATUS disk_status ( |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
64 BYTE pdrv /* Physical drive nmuber (0..) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
65 ) |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
66 { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
67 DSTATUS stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
68 int result; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
69 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
70 switch (pdrv) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
71 case ATA : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
72 result = ATA_disk_status(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
73 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
74 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
75 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
76 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
77 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
78 case MMC : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
79 result = MMC_disk_status(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
80 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
81 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
82 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
83 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
84 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
85 case USB : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
86 result = USB_disk_status(); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
87 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
88 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
89 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
90 return stat; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
91 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
92 return STA_NOINIT; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
93 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
94 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
95 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
96 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
97 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
98 /* Read Sector(s) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
99 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
100 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
101 DRESULT disk_read ( |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
102 BYTE pdrv, /* Physical drive nmuber (0..) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
103 BYTE *buff, /* Data buffer to store read data */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
104 DWORD sector, /* Sector address (LBA) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
105 BYTE count /* Number of sectors to read (1..128) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
106 ) |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
107 { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
108 DRESULT res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
109 int result; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
110 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
111 switch (pdrv) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
112 case ATA : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
114 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
115 result = ATA_disk_read(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
116 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
117 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
118 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
119 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
120 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
121 case MMC : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
122 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
123 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
124 result = MMC_disk_read(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
125 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
126 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
127 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
128 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
129 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
130 case USB : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
131 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
132 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
133 result = USB_disk_read(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
134 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
135 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
136 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
137 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
138 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
139 return RES_PARERR; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
140 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
141 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
142 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
143 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
144 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
145 /* Write Sector(s) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
146 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
147 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
148 #if _USE_WRITE |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
149 DRESULT disk_write ( |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
150 BYTE pdrv, /* Physical drive nmuber (0..) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
151 const BYTE *buff, /* Data to be written */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
152 DWORD sector, /* Sector address (LBA) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
153 BYTE count /* Number of sectors to write (1..128) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
154 ) |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
155 { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
156 DRESULT res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
157 int result; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
158 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
159 switch (pdrv) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
160 case ATA : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
161 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
162 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
163 result = ATA_disk_write(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
164 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
165 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
166 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
167 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
168 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
169 case MMC : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
170 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
171 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
172 result = MMC_disk_write(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
173 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
174 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
175 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
176 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
177 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
178 case USB : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
179 // translate the arguments here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
180 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
181 result = USB_disk_write(buff, sector, count); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
182 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
183 // translate the reslut code here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
184 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
185 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
186 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
187 return RES_PARERR; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
188 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
189 #endif |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
190 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
191 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
192 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
193 /* Miscellaneous Functions */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
194 /*-----------------------------------------------------------------------*/ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
195 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
196 #if _USE_IOCTL |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
197 DRESULT disk_ioctl ( |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
198 BYTE pdrv, /* Physical drive nmuber (0..) */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
199 BYTE cmd, /* Control code */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
200 void *buff /* Buffer to send/receive control data */ |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
201 ) |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
202 { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
203 DRESULT res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
204 int result; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
205 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
206 switch (pdrv) { |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
207 case ATA : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
208 // pre-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
209 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
210 result = ATA_disk_ioctl(cmd, buff); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
211 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
212 // post-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
213 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
214 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
215 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
216 case MMC : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
217 // pre-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
218 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
219 result = MMC_disk_ioctl(cmd, buff); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
220 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
221 // post-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
222 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
223 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
224 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
225 case USB : |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
226 // pre-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
227 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
228 result = USB_disk_ioctl(cmd, buff); |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
229 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
230 // post-process here |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
231 |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
232 return res; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
233 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
234 return RES_PARERR; |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
235 } |
ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
236 #endif |