我在调用例程中的查询U盘剩余容量时
/* 检查U盘或者SD卡的剩余空间 */
printf( "DiskQuery: " );
status = CH378DiskQuery( (PUINT32)buf ); /* 查询磁盘剩余空间信息,扇区数 */
printf( "Free Cap: = %ld MB\n", *(PUINT32)buf / ( 1000000 / DEF_SECTOR_SIZE ) ); /* 未用扇区数乘以扇区大小后,除以1M换算为兆字节单位 */
其中CH378DiskQuery函数的内容和你们提供的应该是一致的
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个字节命令码 */
xReadCH378Data( );
xReadCH378Data( ); /* 读取2个字节数据长度 */
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( );有问题呢?我的函数内容是
UINT8 xReadCH378Data( void )
{
return( Spi376Exchange( 0xFF ) );
}