请教各位大神,使用并口方式,调用例程函数CH378DiskQuery读取磁盘剩余空间时出错,
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个字节命令码 */
temp[0]=xReadCH378Data( );
temp[1]=xReadCH378Data( );/* 读取2个字节数据长度 */
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 );
}
将返回结果打印出来,
当磁盘为SD卡时,结果为00 a8 3a fa a7 3a 03 03 03 03 03
当磁盘为U盘时, 结果为00 04 ca 60 d4 ed 03 03 03 03 03
另外,在使用SectorSize = 1 << CH378ReadVar8( VAR8_DISK_SEC_LEN )读取磁盘扇区大小时,
U盘为512,SD卡为1024,但我用WinHex软件在电脑上读取SD卡扇区大小为512,格式化为512后结果还是不变。由于手上没有SD卡,使用的是TF+SD卡套,这个会不会有影响?