用ch372直接向PC機上傳數(shù)據(jù)
void mCh375Interrupt( ) interrupt 2 using 1 { unsigned char InterruptStatus; CH375_WR_CMD_PORT( CMD_GET_STATUS ); /* 獲取中斷狀態(tài)并取消中斷請求 */ InterruptStatus = CH375_RD_DAT_PORT( ); /* 獲取中斷狀態(tài) */ if(InterruptStatus==USB_INT_EP2_IN) { CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); } }
main( ) { unsigned char len; len=63; Delay50ms( ); /* 延時等待CH375初始化完成,如果單片機由CH375提供復(fù)位信號則不必延時 */ CH375_Init( ); /* 初始化CH375 */ EA = 1; /* 允許中斷 */ CH375_WR_CMD_PORT( CMD_WR_USB_DATA7 ); /* 向USB端點2的發(fā)送緩沖區(qū)寫入數(shù)據(jù)塊 */ CH375_WR_DAT_PORT( len ); /* 首先寫入后續(xù)數(shù)據(jù)長度,回傳剛接收到的數(shù)據(jù)長度 */ for ( i = 0; i < len; i ++ ) CH375_WR_DAT_PORT( i ); }
這么寫不對么? 應(yīng)該怎么寫