spi 挂载 fatfs 系统 读写速度 大概测试了一下,速度那真是慢啦,看来使用 spi的器件来挂载 fatfs 感觉使用价值不大啊
读写 8192*4个Byte ,接近 7s,
void QSPI_FlashFatfsDemo(void)
{
uint32_t RWDataSize = 8192 * 4;
uint8_t * qspi_tx_buff = (uint8_t *)mymalloc(SRAMEX, RWDataSize );
uint8_t * qspi_rx_buff = (uint8_t *)mymalloc(SRAMEX, RWDataSize );
uint8_t res;
FATFS qspi_fs;//逻辑磁盘工作区.
FIL file; //文件1
UINT bw; //读写变量
uint32_t cc;
uint8_t i = 0;
u8 work[_MAX_SS]; /* Work area (larger is better for processing time) */
uint32_t TimeBegin, TimeEnd;
if(( !qspi_tx_buff) || ( !qspi_rx_buff ))
printf("QSPI mymalloc Error ... ...
");
for(cc=0;cc < ( RWDataSize );cc++)
{
qspi_tx_buff[cc] = i * 1;
qspi_rx_buff[cc] = 0 ;
i ++;
}
res = f_mount( &qspi_fs,"3:",1); //挂载 QSPI FLASH.分配盘符号为 3:
if(FR_OK != res)
{
printf("f_mount NAND 失败 ... ... 0x%x
", res);
if(0x0D == res)
{
if(QSPI_EraseChip()) // 使用 fatfs 格式化函数前,先 擦除 QSPI flash 整个芯片,时间比较久,大概 2分钟左右
{
printf("QSPI Flash Format Error ... ...
");
}
res = f_mkfs("3:", 1, 4096, work, sizeof(work) ); //格式化FLASH,2,盘符;1,不需要引导区,8个扇区为1个簇
if(res == 0)
{
res = f_setlabel((const TCHAR *)"3
SPIDISK"); //设置Flash磁盘的名字为:QSPIDISK
if(FR_OK == res)
{
printf("QSPI Flash 磁盘设置成功 ... ...
");
}
printf("QSPI Flash Format Finish ... ...
"); //格式化完成
}
else
printf("QSPI Flash Format Error ... ...
"); //格式化失败
}
}
else
printf("f_mount QSPI 成功 ... ...
");
TimeBegin = HAL_GetTick();
// res = f_opendir(&DirInf, "3:"); /* 2: 表示盘符 ,在读写文件前必须先打开目录 */
res = f_open(&file, "3:/QSPI.txt", FA_CREATE_ALWAYS | FA_WRITE );
res = f_write(&file, &qspi_tx_buff[0], RWDataSize, &bw);
res = f_close(&file);
TimeEnd = HAL_GetTick();
printf("QSPI Flash Write 8192 * 4 End ... ... %dms
" , TimeEnd - TimeBegin); // 写入 8192*4 字节测试耗时147ms
TimeBegin = HAL_GetTick();
// res = f_opendir(&DirInf, "3:"); /* 2: 表示盘符 文件关闭后需要重新打开 根目录,否则读取失败 */
res = f_open(&file, "3:/QSPI.txt", FA_READ);
res = f_read (&file, &qspi_rx_buff[0], RWDataSize, &bw );
res = f_mount( NULL, "3:", 1);
TimeEnd = HAL_GetTick();
printf("QSPI Flash Read 8192 * 4 End ... ... %dms
" , TimeEnd - TimeBegin); // 读取 8192*4 字节测试耗时6ms
if( Buffercmp_8(&qspi_tx_buff[0], &qspi_rx_buff[0], RWDataSize ) == 0)
printf("QSPI Flash Fatfs Read Write 8192 * 4 Test OK .. DD
");
else
printf("QSPI Flash Fatfs Read Write 8192 * 4 Test Error .. EE
");
myfree(SRAMEX, qspi_tx_buff);
myfree(SRAMEX, qspi_rx_buff);
}
哦,看来你很厉害呀,估计在不久的将来应该是国家级别的领导人物,不过,就算你是国家级领导人物,估计也没有什么人愿意跟随你的,你就自己慢慢的嘚瑟吧
一周热门 更多>