請(qǐng)問(wèn)初始化CH375為主機(jī)模式時(shí),CH375一直無(wú)數(shù)據(jù)返回給單片機(jī)是什么原因?無(wú)論寫(xiě)入什么命令,都無(wú)數(shù)據(jù)返回。
void CH375_WR_CMD_PORT( unsigned char cmd ) {?
u8 aCmd;
if(USART_GetFlagStatus(USART2, USART_FLAG_TXE)!=RESET)
{
aCmd = 0x100 | cmd;
USART_SendData(USART2, aCmd);
delay_us(200);
}
}
void CH375_WR_DAT_PORT( unsigned int dat ) { ?
unsigned int aData;
if(USART_GetFlagStatus(USART2, USART_FLAG_TXE)!=RESET)
{
aData = 0xff & dat;
USART_SendData(USART2, aData);
delay_us(200);
}
}
unsigned int CH375_RD_DAT_PORT() { ?
unsigned int dat;
while(USART_GetFlagStatus(USART2,USART_FLAG_RXNE)==RESET);
dat = USART_ReceiveData(USART2);
USART_ClearFlag(USART2,USART_FLAG_RXNE);
return(dat);
}
unsigned char mWaitInterrupt() { ?
unsigned char c;
CH375_INT_WIRE=GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1);
while( CH375_INT_WIRE ); ?
CH375_WR_CMD_PORT( CMD_GET_STATUS ); ?
c = CH375_RD_DAT_PORT( ); ?
if ( c == USB_INT_DISCONNECT ) mDeviceOnline = 0;?
else if ( c == USB_INT_CONNECT ) mDeviceOnline = 1;?
return( c );
}
unsigned charmCH375Init( )
{
unsigned chari,c;
CH375_WR_CMD_PORT( CMD_SET_USB_MODE );?
CH375_WR_DAT_PORT( 6 );?
for ( i = 0xff; i != 0; i -- ) {
c = CH375_RD_DAT_PORT( );
if ( c == CMD_RET_SUCCESS ) break;
}
if ( i != 0 ) return( TRUE ); ?
else return( FALSE );?
}