咦 代码怎么只有这一点
再来
UINT8 xReadCH376Data( void ) /* 从CH376读数据 */
{
INT8U ch;
while(SCI0SR1_RDRF == 0) { /* Is the transmitter empty? */
}
ch=SCI0DRL;
return ch;
}
unsigned char datatest=0x65;
//unsigned char datarecv;
DatMov g_DatProcess; //回调函数指针
INT8U init_ch376s(DatMov pFunc){
volatile UINT8 res1=0;
if(pFunc==NULL){ return;}
g_DatProcess=pFunc;
Init_SCI0(InitBaud); //376的默认波特率9600
xWriteCH376Cmd( CMD11_CHECK_EXIST );
xWriteCH376Data(datatest);
res1=xReadCH376Data();
LED=0b11111110;
if (res1 != 0x9A ){return (ERR_USB_UNKNOWN );}
/* xWriteCH376Cmd( CMD21_SET_BAUDRATE ); //设置串口通讯波特率
#if UART_WORK_BAUDRATE >= 6000000/256
xWriteCH376Data( 0x03 );
xWriteCH376Data( 256 - 6000000/UART_WORK_BAUDRATE );
#else
xWriteCH376Data( 0x02 );
xWriteCH376Data( 256 - 750000/UART_WORK_BAUDRATE );
#endif
Init_SCI0(WorkBaud); //设置单片机工作波特率与CH376s相同
LED=0b11111100;
res1 = xReadCH376Data( );
if( res1 != CMD_RET_SUCCESS ) return( ERR_USB_UNKNOWN ); */ // 设置模式错误
xWriteCH376Cmd( CMD11_SET_USB_MODE ); //设备USB工作模式
xWriteCH376Data( 0x06 );
res1 = xReadCH376Data( );
LED=0b11111100;
if ( res1 != CMD_RET_SUCCESS ) { return 0x02; }
Drv_INT0Interrupt(); //使能IRQ中断
Sys_SemCreate(&sem_ch376, 0); //创建信号量 sem_key
Sys_CreateTask(TASK_ID_CH376, Ch376Task, 0);
return (USB_INT_SUCCESS);
}
|