int main()
{
UINT8 s,c;
UINT16 i,TotalCount;
UINT8 buf[512];
Interrupt_init( 1<<INT_ID_SDC ); /* 系统总中断开启 */
SysClkInit(); /* 初始化系统时钟 */
mInitSTDIO_UR3(); /* 调试信息初始化 printf调用 */
SDIO0Init();
CH567LibInit( );//初始化U盘程序库以支持U盘文件 GJ
printf("Wait Connect...\n");
while( 1 )
{
s = SD0CheckConnect( &TF_SDParam );
if(s == OP_SUCCESS) break;
else mDelaymS(100);
}
mDelaymS(1000);
printf("TF Card connect...\n");
s = SDCardConfig( &TF_SDParam );
if(s != OP_SUCCESS)
{
printf("Init Failed...");
}
else
{
printf("Init Success...\n");
printf("BlockSize:%d B \n", TF_SDParam.SDSecSize);
printf("Cap:%ld MB \n", TF_SDParam.SDSecNum/2048);
printf("Test read and write...\n");
/* 读取原文件 */
printf( "Open\n" );
strcpy( mCmdParam.Open.mPathName, "/TOURD000.BIN" );
s = CH567FileOpen( ); // 打开文件
printf( "status = %02X \n",(UINT16)s);
printf("\n");
if ( s == ERR_MISS_DIR || s == ERR_MISS_FILE )// 没有找到文件
{
printf( "no found TOURD000.BIN!\n" );
}
else
{
printf( "found TOURD000.BIN!\n" );
mCmdParam.ByteRead.mByteCount = 16; // 请求读出几十字节数据
mCmdParam.ByteRead.mByteBuffer= &buf[0];
s = CH567ByteRead( ); // 以字节为单位读取数据块,单次读写的长度不能超过MAX_BYTE_IO,第二次调用时接着刚才的向后读
for(c=0;c<16;c++)
{
printf("%02X ",(UINT16)buf[c]);
}
printf("\n");
}
i = CH567FileClose( );
mStopIfError( i );
}
while(1);
return 0;
}
|