我用CH376芯片查询U盘总容量和剩余容量读出来的数据不对,插入32GU盘实际为29.71G,剩余14.19G,但读出来的数据为总扇区0xB6C40009,剩余扇区0xC6684003,插入另外一个32GU盘实际为27.86G,剩余21.44G,读出来的数据为总扇区0x7BD14009,剩余扇区0x63622003,文件系统都是FAT32;请教各位大神,帮我看下是哪里的问题,下面是我查询容量的代码
void?QueryDiskSize(BYTE?mDiskNAme)
void QueryDiskSize(BYTE mDiskNAme)
{
BYTE mData0,mData1,mData2,mData3;
LONG mTimer;
mTimer=0;
CH376->mCH376CMD=DISK_QUERY;//<<8;
DelayUs(2);
while(INT_CH376==1){mTimer=mTimer+1;if(mTimer>5000000)return;}
mData0=CH376GetIntStatus();
if(mData0==USB_INT_SUCCESS)
{
CH376->mCH376CMD=RD_USB_DATA0;//<<8;
DelayUs(2);
//得出总容量
mData0=CH376->mCH376DAT;//>>8;
LCDStringData(100,150,"TCap=%H",mData0);
mData1=CH376->mCH376DAT;//>>8;
LCDStringData(200,150,"%H",mData1);
mData2=CH376->mCH376DAT;//>>8;
LCDStringData(250,150,"%H",mData2);
mData3=CH376->mCH376DAT;//>>8;
LCDStringData(300,150,"%H",mData3);
//mTemp2=mTemp2>>1;//得出总空间大小(以Kb为单位)
mSysRun.mDisk[mDiskNAme].mTotalCapacity=mData0|((WORD)mData1<<8)|((LONG)mData2<<16)|((LONG)mData3<< 24);//得出扇区数
//得出可用容量
mData0=CH376->mCH376DAT;//>>8;
LCDStringData(100,170,"FCap=%H",mData0);
mData1=CH376->mCH376DAT;//>>8;
LCDStringData(200,170,"%H",mData1);
mData2=CH376->mCH376DAT;//>>8;
LCDStringData(250,170,"%H",mData2);
mData3=CH376->mCH376DAT;//>>8;
LCDStringData(300,170,"%H",mData3);
//mTemp2=mTemp2>>1;//得出总空间大小(以Kb为单位)
mSysRun.mDisk[mDiskNAme].mFreeCapacity=mData0|((WORD)mData1<<8)|((LONG)mData2<<16)|((LONG)mData3<< 24);;
DelayUs(1);
mSysRun.mDisk[mDiskNAme].mFileSystem=CH376->mCH376DAT;
}
else
{
mSysRun.mDisk[mDiskNAme].mTotalCapacity=0;
mSysRun.mDisk[mDiskNAme].mFreeCapacity=0;
mSysRun.mDisk[mDiskNAme].mFileSystem=0;
}
SMatchingStringData("TotalCapacity=%H\r\n",mSysRun.mDisk[mDiskNAme].mTotalCapacity);
SMatchingStringData("mFreeCapacity=%H\r\n",mSysRun.mDisk[mDiskNAme].mFreeCapacity);
SMatchingStringData("mFileSystem=%H\r\n",mSysRun.mDisk[mDiskNAme].mFileSystem);
}
热门产品 :
CH634: 4端口USB3.0 HUB控制器芯片