將FATFS移植STM32RBT6遇到的掛載不成功和返回值問題(2)
FRESULT res;
u32 nCapacity;
char buffer[512];
int main(void)
{
u32 total,free;
BspInit();
res= SD_Init();
if(res==0)
{
DebugOut(0, "sd卡初始化成功!");
}
res= f_mount(&fs,(TCHAR*)1,1); /* Mount a logical drive */;
//f_mkfs(0,1,4096);
res=exf_getfree("0:",&nCapacity,&free);//得到SD卡的總?cè)萘亢褪S嗳萘?br /> DebugOut(0,"總?cè)萘浚?dKB,剩余容量:%dKB",nCapacity,free);
res=f_open(&file, "0:/test.txt", FA_OPEN_EXISTING|FA_READ);
res=f_read (
&file, /* Pointer to the file object */
buffer,/* Pointer to data buffer */
512,/* Number of bytes to read */
&br/* Pointer to number of bytes read */
) ;
DebugOut(0,"buffer:%s",buffer);
res= f_mount(NULL,(TCHAR*)1,1);
while(1);
}
評(píng)論