CH376做主機與CH340通信,數(shù)據(jù)不對

我用CH376做主機與CH340進行USB通信,發(fā)現(xiàn)當(dāng)發(fā)送十六進制數(shù)據(jù):AA AA AA AA AA AA AA AA AA AA十個數(shù)據(jù)時,CH340串口輸出00 00 E0 00 00 00 00 00 00九個數(shù)據(jù),每次都是這樣,請幫忙看一下,怎么收到數(shù)據(jù)不對呢,謝謝了。部分源代碼如下


main()

{

RtnBool = USB_Dev_Connect_Poll();


CH376WriteHostBlock(UsbPcBuffer,10);


USBC_ISSUE_TKN_X();

}

bIs USB_Dev_Connect_Poll(void)

{

int Index;

myRtn RtnState;

u8 RtnData;


//0 系統(tǒng)歸零,不產(chǎn)生SOF包

USBC_Bus_UnInit();

// 1 插入

RtnData = CH376TestConnect();

if(RtnData != USB_INT_CONNECT)?

{

return bFalse;

}


USBC_Delay_1200us(20);


// 2 總線初始化

USBC_Bus_UnInit();

RtnState = USBC_Bus_Init();

if (RtnState ?== RTN_ERR)?

{

return bFalse;

}


RtnState = USBC_GET_DEV_DESCR();


return bTrue;

}


myRtn USBC_ISSUE_TKN_X(void)

{

bIs RtnBool;

CH376SendCmdWaitInt(CMD_AUTO_SETUP);

RtnBool = CH376GetIntStatus();//返回0x14?


USBC_Send_Cmd(CMD_ISSUE_TKN_X);

USBC_Send_Data(0x80);?

USBC_Send_Data(0x21);

RtnBool = Wait376Interrupt();//返回0x14?

}


myRtn USBC_GET_DEV_DESCR(void)

{

bIs RtnBool,Len;


USBC_Send_Cmd(CMD_GET_DESCR);

USBC_Send_Data(0x01);

RtnBool = Wait376Interrupt();//返回0x14?


Len = CH376ReadBlock(&USB_DeviceDescriptor);//正常返回18個設(shè)備描述符?


USBC_Send_Cmd(CMD_GET_DESCR);

USBC_Send_Data(0x02);

RtnBool = Wait376Interrupt();//返回0x14?


Len = CH376ReadBlock(&USB_ConfigDescriptor);//正常返回39配置描述符

}


myRtn USBC_SET_DEV_RATE(void)

{

bIs RtnBool;


USBC_Send_Cmd(CMD_SET_USB_SPEED);

USBC_Send_Data(0x00); ?

}


voidCH376WriteHostBlock( PUINT8 buf, UINT8 len )

{

xWriteCH376Cmd( CMD_WR_HOST_DATA );

xWriteCH376Data( len );

if ( len )

{

do

{

xWriteCH376Data( *buf );

buf ++;

} while ( -- len );

}

xEndCH376Cmd( );

}



熱門產(chǎn)品 : USB3.0 HUB控制器:CH634

你的程序結(jié)構(gòu)有點混亂,在獲取完設(shè)備配置描述符后穿插一個往緩沖區(qū)寫數(shù)據(jù),接著又發(fā)自動配置命令,然后又啟動端點2傳輸。此時,之前你往緩沖區(qū)寫的數(shù)據(jù)早就被自動配置命令給沖掉了。另外,往340發(fā)串口數(shù)據(jù)之前你還沒有發(fā)類命令(配置串口數(shù)據(jù)位、波特率等)。


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频