哪位小哥哥知道,我在用原子哥的FATFS文件系统读取SD卡剩余容量时一直显示14679000KB,不管SD卡存放多少数据都是这样
程序什么都没有动啊!咋回事啊求助![mw_shl_code=c,true]void SDcardFullInitialize()
{
u32 total,free;
exfuns_init(); //为fatfs相关变量申请内存
mem_init(); //初始化内存池
while(SD_Initialize()) //检测SD卡
{
LCD_Write_String(0,0,(uchar *)"SDcard CHECK ...");
delay_ms(200);
}
exfuns_init(); //为fatfs相关变量申请内存
f_mount(fs[0],"0:",1); //挂载SD卡
LCD_WriteInitcmd(0x01); //清除LCD的显示内容
LCD_Write_String(0,0,(uchar *)"SDcard OK");
while(exf_getfree("0",&total,&free)) //得到SD卡的总容量和剩余容量
{
}
printf("SDcard 长度:%d KB
",total);
printf("SDcard 剩余:%d KB
",free);
LCD_Write_String(14,0,(uchar *)"MB");
Stringtotal = my_itoa(total>>10);
LCD_Write_String(0,1,(uchar *)"T:");
LCD_Write_String(2,1,(uchar *)Stringtotal);
Stringfree = my_itoa(free>>10);
LCD_Write_String(8,1,(uchar *)"F:");
LCD_Write_String(10,1,(uchar *)Stringfree);
delay_ms(1000); //延迟一会让用户看到SD卡使用情况
res = f_open(&infile,LaneINFOR_1,FA_CREATE_NEW); //如果存在“车道1.txt”文件则打开,否则创建新的文件
switch (res)
{
case FR_OK :
res = f_open(&infile,LaneINFOR_1, FA_WRITE);
if(res == FR_OK)
{
f_puts((char *)HEADLINE,&infile); // 写入字符串
f_puts((char *)HEADLINE_Lane,&infile); // 写入空格
f_lseek (&infile,infile.fsize); // 文本指针指向末尾
f_close(&infile); // 关闭文件
}else{
SYSTEM_Check = SDcardInitUnknown;
}
printf("%s 信息建立成功
",LaneINFOR_1);
SYSTEM_Check = SDcardInitsucceed; //系统检查SD卡成功
break;
case FR_EXIST:
printf("%s 信息已经建立
",LaneINFOR_1);
f_close(&infile); // 关闭文件
SYSTEM_Check = SDcardInitsucceed;
break;
default:
SYSTEM_Check = SDcardIniterror; //系统检查SD卡失败
break;
}
}[/mw_shl_code]
一周热门 更多>