F407使用f_open报错FR_NOT_ENABLED
使用F407读写16G的U盘,可以读取到U盘信息,可以挂载U盘,但是f_open出错。有没有大神给指点一下。程序如下:
DSTATUS dr;
FATFS fs;
FIL fil;
FRESULT fr;
if(Appli_state == APPLICATION_READY)
{
if(usb_ready == 0)
{
usb_ready = 1;
temp = USBH_MSC_IsReady(&hUsbHostFS);
printf("\r\nUSBH_MSC_IsReady %x", temp);
dr = disk_initialize(0);
printf("\r\ndisk_initialize %x", dr);
fr = f_mount(&fs, "0:", 1);
printf("\r\nf_mount %x", fr);
fr = f_open(&fil, "0:123.txt", FA_OPEN_ALWAYS | FA_WRITE);
//fr = f_open(&fil, "123.txt", FA_READ);
printf("\r\nopen file %x", fr);
}
}
程序输出:
USB Device Attached
ENUM_IDLE find usb;PID: 5567h
VID: 781h
Address (#1) assigned.
Manufacturer : SanDisk
Product : Cruzer Blade
Serial Number : 4C530001160510106081
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : 8h
SubClass : 6h
Protocol : 50h
MSC class started.
Number of supported LUN: 1
LUN #0:
Inquiry Vendor: SanDisk
Inquiry Product : Cruzer Blade
Inquiry Version : 1.00
MSC Device ready
MSC Device capacity : 2797338112 Bytes
Block number : 30629375
Block Size : 512
USBH_MSC_IsReady 1
disk_initialize 0
f_mount 0
open file 12
从打印信息来看,U盘已经识别,并挂载成功。 如果U盘已经存在123.txt, 则打印的信息为
f_mount 0
open file 2
这说明,程序已识别了U盘,并可以读取U盘数据。 如果U盘存在123.txt文件,则打印信息变为
USBH_MSC_IsReady 1
disk_initialize 0
f_mount 0
open file 2 如果U盘存在123.txt,打印信息发生改变。
USBH_MSC_IsReady 1
disk_initialize 0
f_mount 0
open file 2
页:
[1]