//读文件测试
printf("read file test......\n\r");
res = f_open(&fsrc, "0:/test.txt", FA_OPEN_EXISTING | FA_READ);
if(res != FR_OK){
printf("open file error : %d\n\r",res);
}else{
res = f_read(&fsrc, buffer, sizeof(textFileBuffer), &br); /* Read a chunk of src file */
if(res==FR_OK){
printf("read data num : %d\n\r",br);
printf("%s\n\r",buffer);
}else{
printf("read file error : %d\n\r",res);
}
/*close file */
f_close(&fsrc);
} |