管理员
  
- 积分
- 165377
- 金钱
- 165377
- 注册时间
- 2010-12-1
- 在线时间
- 2111 小时
|
发表于 2021-6-15 19:04:17
|
显示全部楼层
有的
你看错了源码吧。
- //写扇区
- //pdrv:磁盘编号0~9
- //*buff:发送数据首地址
- //sector:扇区地址
- //count:需要写入的扇区数
- DRESULT disk_write (
- BYTE pdrv, /* Physical drive nmuber to identify the drive */
- const BYTE *buff, /* Data to be written */
- DWORD sector, /* Sector address in LBA */
- UINT count /* Number of sectors to write */
- )
- {
- u8 res=0;
- if (!count)return RES_PARERR;//count不能等于0,否则返回参数错误
- switch(pdrv)
- {
- case SD_CARD: //SD卡
- res=SD_WriteDisk((u8*)buff,sector,count);
- while(res)//写出错
- {
- SD_Init(); //重新初始化SD卡
- res=SD_WriteDisk((u8*)buff,sector,count);
- //printf("sd wr error:%d\r\n",res);
- }
- break;
- case EX_FLASH: //外部flash
- for(;count>0;count--)
- {
- W25QXX_Write((u8*)buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
- sector++;
- buff+=FLASH_SECTOR_SIZE;
- }
- res=0;
- break;
- case EX_NAND: //外部NAND
- res=FTL_WriteSectors((u8*)buff,sector,512,count);//写入数据
- break;
- case USB_DISK: //U盘
- res=USBH_UDISK_Write((u8*)buff,sector,count);
- break;
- default:
- res=1;
- }
- //处理返回值,将SPI_SD_driver.c的返回值转成ff.c的返回值
- if(res == 0x00)return RES_OK;
- else return RES_ERROR;
- }
复制代码 |
|