本帖最后由 cry1109 于 2019-11-23 16:42 编辑
小白求助。
目前可以正确读写U盘text文件,可是无法读取bin文件,想通过U盘IAP。
- res = f_open(&MyFile, "app.bin", FA_READ);
- if(res != FR_OK)
- {
- /* 'hello.txt' file Open for write Error */
- USBH_UsrLog("f_open with write access error: %d", res);
- printf("文件打开错误\r\n");
- Error_Handler();
- }
- res = f_read(&MyFile, RAM_Buf, sizeof(RAM_Buf), (void *)&bytesread);
- printf("文件大小%d\r\n",bytesread);
-
- res = f_open(&MyFile, "test.txt", FA_READ);
- if(res != FR_OK)
- {
- /* 'hello.txt' file Open for read Error */
- USBH_UsrLog("f_open with read access error: %d", res);
- Error_Handler();
- }
- /* Read data from the text file */
- res = f_read(&MyFile, rtext, sizeof(rtext), (void *)&bytesread);
- printf("%s\r\n",rtext);
- printf("文件大小%d\r\n",bytesread);
通过cubeMX配置fatfs如下:
|