/* Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01) MSVC 1.52 Compile mode: large Project: SD_QA.c ..\..\lib\8000a.lib ..\lib\sd_vnnn.lib Hardware: uPAC-5000 [Jan 05, 2012] by Liam */ #include #include "..\..\Lib\8000e.h" #include "..\..\Lib\8073.h" #include "..\..\Lib\microSD.h" void main(void) { int fd,iRet; int slot; InitLib(); for(slot=0;slot < NumberOfSlot; slot++){ if(ModuleName[slot]==73){ Slot_8073=slot; Print("Find i-8073 plug at slot %d\r\n",slot); goto Start; } } Print("Can not find i-8073 \r\n"); return; Start: if(pc_init()) Print("Init microSD ok\n\r"); else { Print("Init microSD failed\n\r"); iRet=pc_get_errno(); switch(iRet) { case PCERR_BAD_FORMAT: //1 Print("Error 01: format is not FAT(FAT16)\n\r"); break; case PCERR_NO_CARD: //2 Print("Error 02: no microSD card\n\r"); break; default: Print("Error %02d: check the error code list in microSD.h\n\r"); } Delay(10); //wait 10 ms to let the message can be printed compeletely. exit(0); } fd=pc_open("test.txt",(word)(PO_WRONLY|PO_CREATE|PO_APPEND),(word)(PS_IWRITE|PS_IREAD)); if(fd>=0) { pc_write(fd,"1234567890",10); //write 10 bytes pc_close(fd); Print("write 10 bytes to test.txt, done.\n\r"); } else { iRet=pc_get_errno(); Print("Error %02d: check the error code list in microSD.h\n\r",iRet); } }