求助這是什么問題,為何總無法完成初始化,這是改的UART_HW.C的函數(shù)
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寫數(shù)據(jù) */
{
VMD642_UART_putChar(g_uartHandleA,mData);
}
UINT8xReadCH376Data( void ) ?/* 從CH376讀數(shù)據(jù) */
{
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 ); ?/* 通訊接口不正常,可能原因有:接口連接異常,其它設(shè)備影響(片選不唯一),串口波特率,一直在復(fù)位,晶振不工作 */
xWriteCH376Cmd( CMD11_SET_USB_MODE ); ?/* 設(shè)備USB工作模式 */
mDelayuS( 50 );
xWriteCH376Data( 0x06 );
mDelayuS( 50 );
res = xReadCH376Data( );
if ( res == CMD_RET_SUCCESS ) return( USB_INT_SUCCESS );
else return( ERR_USB_UNKNOWN ); ?/* 設(shè)置模式錯誤 */
}