新手上路
- 积分
- 23
- 金钱
- 23
- 注册时间
- 2017-10-17
- 在线时间
- 3 小时
|
5金钱
各位大神,小弟用STM32F407移植FATFS时,f_mount返回值为0,SD卡初始也成功,但是在调用f_open却返回12(FR_NOT_ENABLED),请问怎么解决啊!贴出main 函数代码。。
int main(void)
{
// u8 res=0;
unsigned int i;
BYTE buffer[1024]; // file copy buffer // Work area (file system object) for logical drive
FIL fsrc; // file objects
FRESULT res=1; // FatFs function common result code
FATFS fatfs;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//
delay_init(168); //
uart_init(115200); //
LED_Init();
while(SD_Init()){
printf("Please Check!");
}
disk_initialize(0);
printf("Now, I'll read file 'test.txt'.\n");
res =f_mount(&fatfs,"0:/",1);
printf("%d\n",res);
res = f_open(&fsrc,"test.txt",FA_OPEN_ALWAYS|FA_READ|FA_WRITE);
printf("%d",res);
if (res)
{
printf("Can't open test.txt for read.\n");
f_mount(NULL,"0:/",1);
}else
{
for (;;) {
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
if (res || br == 0) break; // error or eof
for( i = 0; i < br; ++i )
putchar(buffer);
}
f_close(&fsrc);
}
}
|
|