SAMV71 Xplained Ultra Software Package 1.0

diskio.c

00001 /*-----------------------------------------------------------------------*/
00002 /* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2014        */
00003 /*-----------------------------------------------------------------------*/
00004 /* If a working storage control module is available, it should be        */
00005 /* attached to the FatFs via a glue function rather than modifying it.   */
00006 /* This is an example of glue functions to attach various exsisting      */
00007 /* storage control modules to the FatFs module with a defined API.       */
00008 /*-----------------------------------------------------------------------*/
00009 
00010 #include "diskio.h"
00011 
00012 /* Definitions of physical drive number for each drive */
00013 #define ATA     0   /* Example: Map ATA drive to drive number 0 */
00014 #define MMC     1   /* Example: Map MMC/SD card to drive number 1 */
00015 #define USB     2   /* Example: Map USB drive to drive number 2 */
00016 
00017 
00018 /*-----------------------------------------------------------------------*/
00019 /* Get Drive Status                                                      */
00020 /*-----------------------------------------------------------------------*/
00021 
00022 DSTATUS disk_status (
00023     BYTE pdrv        /* Physical drive number to identify the drive */
00024 )
00025 {
00026     DSTATUS stat;
00027     int result;
00028 
00029     switch (pdrv) {
00030     case ATA :
00031         result = ATA_disk_status();
00032 
00033         // translate the result code here
00034 
00035         return stat;
00036 
00037     case MMC :
00038         result = MMC_disk_status();
00039 
00040         // translate the result code here
00041 
00042         return stat;
00043 
00044     case USB :
00045         result = USB_disk_status();
00046 
00047         // translate the result code here
00048 
00049         return stat;
00050     }
00051     return STA_NOINIT;
00052 }
00053 
00054 
00055 
00056 /*-----------------------------------------------------------------------*/
00057 /* Initialize a Drive                                                    */
00058 /*-----------------------------------------------------------------------*/
00059 
00060 DSTATUS disk_initialize (
00061     BYTE pdrv                /* Physical drive number to identify the drive */
00062 )
00063 {
00064     DSTATUS stat;
00065     int result;
00066 
00067     switch (pdrv) {
00068     case ATA :
00069         result = ATA_disk_initialize();
00070 
00071         // translate the result code here
00072 
00073         return stat;
00074 
00075     case MMC :
00076         result = MMC_disk_initialize();
00077 
00078         // translate the result code here
00079 
00080         return stat;
00081 
00082     case USB :
00083         result = USB_disk_initialize();
00084 
00085         // translate the result code here
00086 
00087         return stat;
00088     }
00089     return STA_NOINIT;
00090 }
00091 
00092 
00093 
00094 /*-----------------------------------------------------------------------*/
00095 /* Read Sector(s)                                                        */
00096 /*-----------------------------------------------------------------------*/
00097 
00098 DRESULT disk_read (
00099     BYTE pdrv,        /* Physical drive number to identify the drive */
00100     BYTE *buff,        /* Data buffer to store read data */
00101     DWORD sector,    /* Sector address in LBA */
00102     UINT count        /* Number of sectors to read */
00103 )
00104 {
00105     DRESULT res;
00106     int result;
00107 
00108     switch (pdrv) {
00109     case ATA :
00110         // translate the arguments here
00111 
00112         result = ATA_disk_read(buff, sector, count);
00113 
00114         // translate the result code here
00115 
00116         return res;
00117 
00118     case MMC :
00119         // translate the arguments here
00120 
00121         result = MMC_disk_read(buff, sector, count);
00122 
00123         // translate the result code here
00124 
00125         return res;
00126 
00127     case USB :
00128         // translate the arguments here
00129 
00130         result = USB_disk_read(buff, sector, count);
00131 
00132         // translate the result code here
00133 
00134         return res;
00135     }
00136 
00137     return RES_PARERR;
00138 }
00139 
00140 
00141 
00142 /*-----------------------------------------------------------------------*/
00143 /* Write Sector(s)                                                       */
00144 /*-----------------------------------------------------------------------*/
00145 
00146 #if _USE_WRITE
00147 DRESULT disk_write (
00148     BYTE pdrv,            /* Physical drive number to identify the drive */
00149     const BYTE *buff,    /* Data to be written */
00150     DWORD sector,        /* Sector address in LBA */
00151     UINT count            /* Number of sectors to write */
00152 )
00153 {
00154     DRESULT res;
00155     int result;
00156 
00157     switch (pdrv) {
00158     case ATA :
00159         // translate the arguments here
00160 
00161         result = ATA_disk_write(buff, sector, count);
00162 
00163         // translate the result code here
00164 
00165         return res;
00166 
00167     case MMC :
00168         // translate the arguments here
00169 
00170         result = MMC_disk_write(buff, sector, count);
00171 
00172         // translate the result code here
00173 
00174         return res;
00175 
00176     case USB :
00177         // translate the arguments here
00178 
00179         result = USB_disk_write(buff, sector, count);
00180 
00181         // translate the result code here
00182 
00183         return res;
00184     }
00185 
00186     return RES_PARERR;
00187 }
00188 #endif
00189 
00190 
00191 /*-----------------------------------------------------------------------*/
00192 /* Miscellaneous Functions                                               */
00193 /*-----------------------------------------------------------------------*/
00194 
00195 #if _USE_IOCTL
00196 DRESULT disk_ioctl (
00197     BYTE pdrv,        /* Physical drive number (0..) */
00198     BYTE cmd,        /* Control code */
00199     void *buff        /* Buffer to send/receive control data */
00200 )
00201 {
00202     DRESULT res;
00203     int result;
00204 
00205     switch (pdrv) {
00206     case ATA :
00207 
00208         // Process of the command for the ATA drive
00209 
00210         return res;
00211 
00212     case MMC :
00213 
00214         // Process of the command for the MMC/SD card
00215 
00216         return res;
00217 
00218     case USB :
00219 
00220         // Process of the command the USB drive
00221 
00222         return res;
00223     }
00224 
00225     return RES_PARERR;
00226 }
00227 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines