SD Card Interface class. Log raw data bytes to memory addresses of your choice, or format the card and use the FAT file system to write files.
diskio.c
00001 /*-----------------------------------------------------------------------*/ 00002 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */ 00003 /*-----------------------------------------------------------------------*/ 00004 /* This is a stub disk I/O module that acts as front end of the existing */ 00005 /* disk I/O modules and attach it to FatFs module with common interface. */ 00006 /*-----------------------------------------------------------------------*/ 00007 00008 //Modified by Thomas Hamilton, Copyright 2010 00009 00010 #include "diskio.h" 00011 00012 DSTATUS disk_initialize(BYTE drv) 00013 { 00014 if (FATFileSystem::DriveArray[drv]) 00015 { 00016 return (DSTATUS)FATFileSystem::DriveArray[drv]->disk_initialize(); 00017 } 00018 else 00019 { 00020 return STA_NOINIT; 00021 } 00022 } 00023 00024 DSTATUS disk_status(BYTE drv) 00025 { 00026 if (FATFileSystem::DriveArray[drv]) 00027 { 00028 return (DSTATUS)FATFileSystem::DriveArray[drv]->disk_status(); 00029 } 00030 else 00031 { 00032 return STA_NOINIT; 00033 } 00034 } 00035 00036 DRESULT disk_read(BYTE drv, BYTE* buff, DWORD sector, BYTE count) 00037 { 00038 if (FATFileSystem::DriveArray[drv]) 00039 { 00040 return (DRESULT)FATFileSystem::DriveArray[drv]->disk_read((unsigned char*)buff, 00041 (unsigned long)sector, (unsigned char)count); 00042 } 00043 else 00044 { 00045 return RES_NOTRDY; 00046 } 00047 } 00048 00049 #if _READONLY == 0 00050 DRESULT disk_write(BYTE drv, const BYTE* buff, DWORD sector, BYTE count) 00051 { 00052 if (FATFileSystem::DriveArray[drv]) 00053 { 00054 return (DRESULT)FATFileSystem::DriveArray[drv]->disk_write((const unsigned char*)buff, 00055 (unsigned long)sector, (unsigned char)count); 00056 } 00057 else 00058 { 00059 return RES_NOTRDY; 00060 } 00061 } 00062 #endif 00063 00064 DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void* buff) 00065 { 00066 switch (ctrl) 00067 { 00068 case CTRL_SYNC: 00069 if (FATFileSystem::DriveArray[drv]) 00070 { 00071 return (DRESULT)FATFileSystem::DriveArray[drv]->disk_sync(); 00072 } 00073 else 00074 { 00075 return RES_NOTRDY; 00076 } 00077 00078 case GET_SECTOR_SIZE: 00079 if (FATFileSystem::DriveArray[drv]) 00080 { 00081 WORD Result = FATFileSystem::DriveArray[drv]->disk_sector_size(); 00082 if (Result > 0) 00083 { 00084 *((WORD*)buff) = Result; 00085 return RES_OK; 00086 } 00087 else 00088 { 00089 return RES_ERROR; 00090 } 00091 } 00092 else 00093 { 00094 return RES_NOTRDY; 00095 } 00096 00097 case GET_SECTOR_COUNT: 00098 if (FATFileSystem::DriveArray[drv]) 00099 { 00100 DWORD Result = FATFileSystem::DriveArray[drv]->disk_sector_count(); 00101 if (Result > 0) 00102 { 00103 *((DWORD*)buff) = Result; 00104 return RES_OK; 00105 } 00106 else 00107 { 00108 return RES_ERROR; 00109 } 00110 } 00111 else 00112 { 00113 return RES_NOTRDY; 00114 } 00115 00116 case GET_BLOCK_SIZE: 00117 if (FATFileSystem::DriveArray[drv]) 00118 { 00119 DWORD Result = FATFileSystem::DriveArray[drv]->disk_block_size(); 00120 if (Result > 0) 00121 { 00122 *((DWORD*)buff) = Result; 00123 return RES_OK; 00124 } 00125 else 00126 { 00127 return RES_ERROR; 00128 } 00129 } 00130 else 00131 { 00132 return RES_NOTRDY; 00133 } 00134 00135 default: 00136 return RES_PARERR; 00137 } 00138 }
Generated on Wed Jul 13 2022 05:31:45 by 1.7.2