#include "..\..\Lib\8000A.h" #include unsigned char read_buffer[512],write_buffer[512]; unsigned long totalBlock=0,totalMemorySize=0; /* // first step the use microSD card, we have to use this function to get the total block counts and total memory size int microSD_Start(unsigned long *BlockNo,unsigned long *MemorySize); BlockNo [out]the total block counts, there are 256 bytes for each block MemorySize [out]total memory size return value: 0: OK int microSD_WriteBlock(void *data,unsigned long blockIndex,unsigned blockCount); data [in] buffer data write to microSD card blockIndex [in] the block index data will be written blockCount [in] total block count will be written int microSD_ReadBlock(void *data,unsigned long blockIndex,unsigned blockCount); data [out] buffer data read to microSD card blockIndex [in] the block index data will be read blockCount [in] total block count will be read int microSD_CheckCardReady(void); //[2008/11/14] add. return value: 0: not ready 64: ready */ int main() { int i,j,ret; InitLib(); InstallCom(1,115200L,8,0,1); ret = microSD_Start(&totalBlock,&totalMemorySize); printCom(1,"IsReady = %d block number=%lu, memory size= %lu\r\n",microSD_CheckCardReady(),totalBlock,totalMemorySize); memset( write_buffer, '*', 256 ); microSD_WriteBlock(write_buffer, 0 , 1); microSD_ReadBlock(read_buffer, 0 , 1); for(i=0;i<256;i++) { if(i % 8 ==7) printCom1("[%03d]=[%c]\n",i,read_buffer[i]); else printCom1("[%03d]=[%c] ",i,read_buffer[i]); } while(1) { printCom(1,"IsReady = %2d\r",microSD_CheckCardReady()); if(ReadCom(1)=='q') break; } RestoreCom(1); return 0; }