本帖最后由 cl17726 于 2017-5-9 18:18 编辑
首先TF卡肯定是没写保护的.使用FreeRTOS,DMA传送SDMMC的内容,分配的Stack也是绝对超大的10KB.
我先用以下函数验证了一下,确实是没问题的.正常读写比对没有任何问题.
[mw_shl_code=c,true]void SDMMC_Test(void const *argument)
{
BSP_SD_Init();
while(1)
{
Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF);
Fill_Buffer(aRxBuffer, BUFFER_WORDS_SIZE, 0x0000);
BSP_SD_WriteBlocks_DMA(aTxBuffer, BLOCK_START_ADDR, NUM_OF_BLOCKS);
while( xSemaphoreTake( SDCard.SDWriteStatus, portMAX_DELAY ) != pdTRUE );
while(BSP_SD_GetCardState() != SD_TRANSFER_OK)
{
}
BSP_SD_ReadBlocks_DMA(aRxBuffer, BLOCK_START_ADDR, NUM_OF_BLOCKS);
while( xSemaphoreTake( SDCard.SDReadStatus, portMAX_DELAY ) != pdTRUE );
while(BSP_SD_GetCardState() != SD_TRANSFER_OK)
{
}
if (Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0)
{
while(1);
}
vTaskDelay(1000);
}
}[/mw_shl_code]
但是使用我的FATFS验证时候,仅仅读取是没问题的,而且再大的文件,连续读写下去也没事,版本R0.12c.
[mw_shl_code=cpp,true]UINT bw;
BYTE data[64] = "no data!
";
uint32_t i = 0;
FATFS *SDCard_Fatfs;
FIL *fil;
FRESULT res;
void FATFS_Test(void const *argument)
{
SDCard_Fatfs = ( FATFS * ) pvPortMalloc( sizeof( FATFS ) );
fil = ( FIL * ) pvPortMalloc( sizeof( FIL ) );
res = f_mount(SDCard_Fatfs, "0:", 1);
res = f_open(fil, "0:test.txt", FA_READ);
for(;;)
{
vTaskDelay(1000);
//res = f_write(&fil, data, sizeof(data), &bw);
res = f_read(fil, data, 64, &bw);
//f_close(&fil);
}
}[/mw_shl_code]
但是一旦以WRITE模式打开,不管是否WRITE内容,都会失败.
虽然我认为屏蔽掉写保护代码不明智,但是还是测试了,没效果的.
读写函数移植到这样.
跟进写函数也是返回OK的.
包括可能获取到写保护的也写这样了.
/*-----------------------------------------------------------------------*/
/* Get Drive Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
switch (pdrv)
{
case DEV_MMC :
return 0x00;
}
return STA_NOINIT;
}
一周热门 更多>