Fatfs移植的问题

[复制链接]
1089|8
 楼主| anger0925 发表于 2020-6-11 11:54 | 显示全部楼层 |阅读模式
我在GD32F4上实现SD卡的FATFS移植。单独对sd读写正常。移植fatfs后,res=f_mkdir(pcVariable);   执行这句时就出现写CMD16时,返回SD_CMD_RESP_TIMEOUT超时。可能是什么原因呢?读写函数为:
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
  DRESULT res = RES_OK;
   
  if (count > 1)
  {
     /* Read multiple block */
    if(sd_multiblocks_read((uint32_t *)buff,
                          (uint32_t) (sector * BLOCK_SIZE),
                          BLOCK_SIZE,
                          count) != SD_OK)
      return RES_ERROR;
    /* Check if the Transfer is finished */
   
  }
  else
  {
    /* Read block */
    if(sd_block_read((uint32_t *)buff,
                    (uint32_t) (sector * BLOCK_SIZE),
                    BLOCK_SIZE) != SD_OK)
      return RES_ERROR;
    /* Check if the Transfer is finished */
     while(sd_transfer_state_get() != SD_NO_TRANSFER);       
  }
  
  return res;
}

DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
{
  DRESULT res = RES_OK;
  
  if (count > 1)
  {
     /* Write multiple block */
    if(sd_multiblocks_write((uint32_t *)buff,
                           (uint32_t) (sector * BLOCK_SIZE),
                           BLOCK_SIZE,
                           count) != SD_OK)
      return RES_ERROR;
    /* Check if the Transfer is finished */
  
  }
  else
  {
    /* Write block */
    if(sd_block_write((uint32_t *)buff,
                     (uint32_t) (sector * BLOCK_SIZE),
                     BLOCK_SIZE) != SD_OK)
      return RES_ERROR;
    /* Check if the Transfer is finished */
   while(sd_transfer_state_get() != SD_NO_TRANSFER);       
   
  }
  
  return res;
}

谢谢大家
coshi 发表于 2020-7-6 15:38 | 显示全部楼层
没看太明白呀
aoyi 发表于 2020-7-6 15:39 | 显示全部楼层
不懂 帮楼主顶一下
drer 发表于 2020-7-6 15:41 | 显示全部楼层
楼主问题解决了吗
gwsan 发表于 2020-7-6 15:42 | 显示全部楼层
我的移植也不成功
qhjjjs 发表于 2020-9-12 22:31 | 显示全部楼层
我也遇到这个问题,请教一下现在这个问题解决了吗?
zhengshuai888 发表于 2020-9-16 07:41 来自手机 | 显示全部楼层
应该fatfs接口问题
明天真的好 发表于 2020-9-17 19:19 | 显示全部楼层
单独对sd读写正常。移植fatfs后,res=f_mkdir(pcVariable);   执行这句时就出现写CMD16时,返回SD_CMD_RESP_TIMEOUT超时。
里面有晴雨 发表于 2020-9-18 09:07 | 显示全部楼层
fat移植都是通用的吧,没有什么难的地方。我想在哪里跑都是差不多的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

8

主题

54

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部