请问初始化CH375为主机模式时,CH375一直无数据返回给
单片机是什么原因?无论写入什么命令,都无数据返回。
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 mWai
tinterrupt() {
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 );
}