使用SD卡和Flash做2个磁盘,将SD或flash做为卷0,程序都可以正常访问目录,文件,另外可以对卷1进行格式化,但是却访问不了卷1的目录;有没有知道什么问题的?
- void ShowSDFiles(u8 index)
- {
- FILINFO finfo;
- DIR dirs;
- char path[100] = {""};
- printf("\nSD file system starting! \n");
- disk_initialize(index);
- printf("f_mount %d\n", f_mount(index, &fs));
- printf("f_mkfs %d\n", f_mkfs(index, 0, 512)); // SD 卡时为4096
- printf("----------------------------------------------------\n");
- printf("f_opendir(&dirs, "/") = %d;\n", f_opendir(&dirs, "/"));
- if(f_opendir(&dirs, path) == FR_OK)
- {
- while(f_readdir(&dirs, &finfo) == FR_OK)
- {
- if(!finfo.fname[0]) break;
- if (finfo.fattrib & AM_ARC)
- {
- printf(" file name is: %s ", finfo.fname);
- printf("file size is: %d \n", finfo.fsize);
- if(File_type_Check((u8 *)finfo.fname, "txt"))
- {
- printf("file contex is:");
- res = f_open(&fsrc, finfo.fname, FA_OPEN_EXISTING | FA_READ);
- while(1)
- {
- memset(buffer, 0, sizeof(buffer));
- if(f_gets(buffer, 512, &fsrc))
- {
- printf("%s", buffer);
- }
- else break;
- }
- f_close(&fsrc);
- }
- }
- else
- {
- printf("Path name is: %s\n", finfo.fname);
- continue; //break;
- }
- }
- res = f_open(&fsrc, "armjishu.txt", FA_CREATE_ALWAYS | FA_WRITE);
- res = f_write(&fsrc, &armjishu, sizeof(text), &bw);
- f_close(&fsrc);
- else
- {
- printf(" err: f_opendir\n");
- }
- printf("----------------------------------------------------\n");
- f_mount(index, NULL);
- }
|