本帖最后由 Solace1123 于 2019-4-27 20:10 编辑
用的是micro SD卡,不知道是挂载不上还是怎么样,程序跑到创建文本文件的那一句就卡死了,求助!!!换了两张卡还是不行SD卡用的是别人的SDIO库
这是diskio.c,
[mw_shl_code=c,true]/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
/*-----------------------------------------------------------------------*/
/* This is a stub disk I/O module that acts as front end of the existing */
/* disk I/O modules and attach it to FatFs module with common interface. */
/*-----------------------------------------------------------------------*/
#include "diskio.h"
#include "stm32f10x.h"
#include "sdio_sdcard.h"
#define BLOCK_SIZE 512 /* Block Size in Bytes */
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
DSTATUS disk_initialize (
BYTE drv /* Physical drive nmuber (0..) */
)
{
SD_Error Status;
/* Supports only single drive */
if (drv)
{
return STA_NOINIT;
}
/*-------------------------- SD Init ----------------------------- */
Status = SD_Init();
if (Status!=SD_OK )
{
return STA_NOINIT;
}
else
{
return RES_OK;
}
}
/*-----------------------------------------------------------------------*/
/* Return Disk Status */
DSTATUS disk_status (
BYTE drv /* Physical drive nmuber (0..) */
)
{
return RES_OK;
}
/*-----------------------------------------------------------------------*/
/* Read Sector(s) */
DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to read (1..255) */
)
{
if (count > 1)
{
SD_ReadMultiBlocks(buff, sector*BLOCK_SIZE, BLOCK_SIZE, count);
/* Check if the Transfer is finished */
SD_WaitReadOperation(); //Ñ-»·2éÑˉdma′«êäêÇ·ñ½áêø
/* Wait until end of DMA transfer */
while(SD_GetStatus() != SD_TRANSFER_OK);
}
else
{
SD_ReadBlock(buff, sector*BLOCK_SIZE, BLOCK_SIZE);
/* Check if the Transfer is finished */
SD_WaitReadOperation(); //Ñ-»·2éÑˉdma′«êäêÇ·ñ½áêø
/* Wait until end of DMA transfer */
while(SD_GetStatus() != SD_TRANSFER_OK);
}
return RES_OK;
}
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
#if _READONLY == 0
DRESULT disk_write (
BYTE drv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to write (1..255) */
)
{
if (count > 1)
{
SD_WriteMultiBlocks((uint8_t *)buff, sector*BLOCK_SIZE, BLOCK_SIZE, count);
/* Check if the Transfer is finished */
SD_WaitWriteOperation(); //μè′ydma′«êä½áêø
while(SD_GetStatus() != SD_TRANSFER_OK); //μè′ysdioμ½sd¿¨′«êä½áêø
}
else
{
SD_WriteBlock((uint8_t *)buff,sector*BLOCK_SIZE, BLOCK_SIZE);
/* Check if the Transfer is finished */
SD_WaitWriteOperation(); //μè′ydma′«êä½áêø
while(SD_GetStatus() != SD_TRANSFER_OK); //μè′ysdioμ½sd¿¨′«êä½áêø
}
return RES_OK;
}
#endif /* _READONLY */
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE ctrl, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
return RES_OK;
}
/*-----------------------------------------------------------------------*/
/* Get current time */
/*-----------------------------------------------------------------------*/
DWORD get_fattime(void)
{
return 0;
}
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>