本帖最后由 心静则平 于 2019-3-27 11:54 编辑
我在407开发板上修改个文件系统读写程序:实例如下
u8 USH_User_App(void)
{
FIL fil;
char buf[100];
UINT bww;
u32 total,free;
u8 res = 0;
Show_Str(30,140,200,16,"设备连接成功!.",16,0);
res = exf_getfree("2:",&total,&free);
if(res==0)
{
POINT_COLOR=BLUE;//设置字体为蓝 {MOD}
LCD_ShowString(30,160,200,16,16,"FATFS OK!");
LCD_ShowString(30,180,200,16,16,"U Disk Total Size: MB");
LCD_ShowString(30,200,200,16,16,"U Disk Free Size: MB");
LCD_ShowNum(174,180,total>>10,5,16); //显示U盘总容量 MB
LCD_ShowNum(174,200,free>>10,5,16);
}
//mf_scan_files("2:");
res = f_open(&fil,"2:/message.txt",FA_CREATE_ALWAYS|FA_WRITE);
f_write(&fil,"alientek test",50,&bww);
f_close(&fil);
res = f_open (&fil,"2:/message.txt",FA_READ);
f_read(&fil,buf,100,&bww);
f_close(&fil);
while(HCD_IsDeviceConnected(&USB_OTG_Core))//设备连接成功
{
LED1=!LED1;
delay_ms(200);
}
POINT_COLOR=RED;//设置字体为红 {MOD}
Show_Str(30,140,200,16,"设备连接中...",16,0);
LCD_Fill(30,160,239,220,WHITE);
return res;
}
但是结果读出来的buf里面是空的,请问这是问什么?
一周热门 更多>