請(qǐng)教各位大神,使用并口方式,調(diào)用例程函數(shù)CH378DiskQuery讀取磁盤剩余空間時(shí)出錯(cuò),
UINT8 CH378DiskQuery( PUINT32 DiskFre ) ?
{
UINT8 ?s;
UINT8 ?c0, c1, c2, c3;
UINT8 temp[11];
s = CH378SendCmdWaitInt( CMD0H_DISK_QUERY );
if( s == ERR_SUCCESS )?
{ ?
xWriteCH378Cmd( CMD00_RD_HOST_REQ_DATA );?/* 寫入1個(gè)字節(jié)命令碼 */
temp[0]=xReadCH378Data( );
temp[1]=xReadCH378Data( );/* 讀取2個(gè)字節(jié)數(shù)據(jù)長度 */
temp[2]=xReadCH378Data( );?/* CH378_CMD_DATA.DiskQuery.mTotalSector */
temp[3]=xReadCH378Data( );
temp[4]=xReadCH378Data( );
temp[5]=xReadCH378Data( );
c0 = xReadCH378Data( );/* CH378_CMD_DATA.DiskQuery.mFreeSector */
c1 = xReadCH378Data( );
c2 = xReadCH378Data( );
c3 = xReadCH378Data( );
*DiskFre = c0 | (UINT16)c1 << 8 | (UINT32)c2 << 16 | (UINT32)c3 << 24;
temp[6]=xReadCH378Data( );/* CH378_CMD_DATA.DiskQuery.mDiskFat */
uart_putchar(temp[0]);
uart_putchar(temp[1]);
uart_putchar(temp[2]);
uart_putchar(temp[3]);
uart_putchar(temp[4]);
uart_putchar(temp[5]);
uart_putchar(c0);
uart_putchar(c1);
uart_putchar(c2);
uart_putchar(c3);
uart_putchar(temp[6]);
uart_putchar('\n');
}
else?
{
*DiskFre = 0;
}
return( s );
}
將返回結(jié)果打印出來,
當(dāng)磁盤為SD卡時(shí),結(jié)果為00 a8 3a fa a7 3a 03 03 03 03 03
當(dāng)磁盤為U盤時(shí), 結(jié)果為00 04 ca 60 d4 ed 03 03 03 03 03
另外,在使用SectorSize = 1 << ?CH378ReadVar8( VAR8_DISK_SEC_LEN )讀取磁盤扇區(qū)大小時(shí),
U盤為512,SD卡為1024,但我用WinHex軟件在電腦上讀取SD卡扇區(qū)大小為512,格式化為512后結(jié)果還是不變。由于手上沒有SD卡,使用的是TF+SD卡套,這個(gè)會(huì)不會(huì)有影響?