求助这是什么问题,为何总无法完成初始化,这是改的UART_HW.C的函数
voidxWriteCH376Cmd( UINT8 mCmd ) /* 向CH376写命令 */
{
VMD642_UART_putChar(g_uartHandleA,SER_SYNC_CODE1);
mDelayuS( 50 );
VMD642_UART_putChar(g_uartHandleA,SER_SYNC_CODE2);
mDelayuS( 50 );
VMD642_UART_putChar(g_uartHandleA,mCmd);
}
voidxWriteCH376Data( UINT8 mData ) /* 向CH376写数据 */
{
VMD642_UART_putChar(g_uartHandleA,mData);
}
UINT8xReadCH376Data( void ) /* 从CH376读数据 */
{
Int16status,rbuf;
status = VMD642_UART_rget(g_uartHandleA, VMD642_UART_LSR);
if ((status & 1) == 1)
{
rbuf= VMD642_UART_getChar(g_uartHandleA);
return( rbuf );
}
return( 0 );
}
UINT8Query376Interrupt( void )
{
Int16status,rbuf;
status = VMD642_UART_rget(g_uartHandleA, VMD642_UART_LSR);
if ((status & 1) == 1)
{
return( TRUE );
}
return( FALSE );
}
UINT8mInitCH376Host( void ) /* 初始化CH376 */
{
UINT8res;
xWriteCH376Cmd( CMD11_CHECK_EXIST ); /* 测试单片机与CH376之间的通讯接口 */
mDelayuS( 50 );
xWriteCH376Data( 0x65 );
mDelayuS( 50 );
res = xReadCH376Data( );
if ( res != 0x9A ) return( ERR_USB_UNKNOWN ); /* 通讯接口不正常,可能原因有:接口连接异常,其它设备影响(片选不唯一),串口波特率,一直在复位,晶振不工作 */
xWriteCH376Cmd( CMD11_SET_USB_MODE ); /* 设备USB工作模式 */
mDelayuS( 50 );
xWriteCH376Data( 0x06 );
mDelayuS( 50 );
res = xReadCH376Data( );
if ( res == CMD_RET_SUCCESS ) return( USB_INT_SUCCESS );
else return( ERR_USB_UNKNOWN ); /* 设置模式错误 */
}