我在調(diào)用例程中的查詢U盤剩余容量時
/* 檢查U盤或者SD卡的剩余空間 */
printf( "DiskQuery: " );
status = CH378DiskQuery( (PUINT32)buf ); ??/* 查詢磁盤剩余空間信息,扇區(qū)數(shù) */
printf( "Free Cap: = %ld MB\n", *(PUINT32)buf / ( 1000000 / DEF_SECTOR_SIZE ) ); ?/* 未用扇區(qū)數(shù)乘以扇區(qū)大小后,除以1M換算為兆字節(jié)單位 */
其中CH378DiskQuery函數(shù)的內(nèi)容和你們提供的應(yīng)該是一致的
UINT8 CH378DiskQuery( PUINT32 DiskFre ) ?
{
UINT8 ?s;
//UINT8 ?c0, c1, c2, c3;
s = CH378SendCmdWaitInt( CMD0H_DISK_QUERY );
if( s == ERR_SUCCESS )?
{ ?
xWriteCH378Cmd( CMD00_RD_HOST_REQ_DATA );?/* 寫入1個字節(jié)命令碼 */
xReadCH378Data( );
xReadCH378Data( );???? ? /* 讀取2個字節(jié)數(shù)據(jù)長度 */
xReadCH378Data( ); ??/* CH378_CMD_DATA.DiskQuery.mTotalSector */
xReadCH378Data( );
xReadCH378Data( );
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;
xReadCH378Data( ); ??/* CH378_CMD_DATA.DiskQuery.mDiskFat */
xEndCH378Cmd( );
}
else?
{
*DiskFre = 0;
}
return( s );
}
其中我在往U盤中寫入信息時*DiskFre的值總是不變是不是xReadCH378Data( );有問題呢?我的函數(shù)內(nèi)容是
UINT8 xReadCH378Data( void )
{
return( Spi376Exchange( 0xFF ) );
}