|
直接用串口接线出来能在电脑上打印出GPS发送的数据,但是通过程序无法收到接收消息,下面是我写的uart2初始化设置函数,每个分支都试过了,都不行(trace打印系统不会调用我的myapp_gps_uart_rx_cb),求大神帮看下:
#define GPS_UART_PORT uart_port2
#define GPS_UART_OWNERID ((module_type)(MOD_UART1_HISR + GPS_UART_PORT))
static void myapp_gps_uart_init(void)
{
myapp_trace("myapp_gps_uart_init");
#if 0
UART_DriverInit(GPS_UART_PORT, 0);
UART_PDN_Disable(GPS_UART_PORT); //串口休眠控制
//U_SetBaudRate(GPS_UART_PORT, UART_BAUD_9600, (module_type)(MOD_UART1_HISR + GPS_UART_PORT));
U_Register_RX_cb( GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT), myapp_gps_uart_rx_cb);
U_Register_TX_cb( GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT), myapp_gps_uart_tx_cb);
U_ClrRxBuffer(GPS_UART_PORT, UARTPort[GPS_UART_PORT].ownerid); /*clear sw RX buffer*/
U_ClrTxBuffer(GPS_UART_PORT, UARTPort[GPS_UART_PORT].ownerid); /*clear sw TX buffer*/
U_Purge(GPS_UART_PORT, RX_BUF, UARTPort[GPS_UART_PORT].ownerid);/*clear sw RX FIFO*/
U_Purge(GPS_UART_PORT, TX_BUF, UARTPort[GPS_UART_PORT].ownerid);/*clear sw TX FIFO*/
#else
#if 0
U_SetOwner(GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT));
UART_PDN_Disable(GPS_UART_PORT);
U_SetBaudRate(GPS_UART_PORT, UART_BAUD_9600, (module_type)(MOD_UART1_HISR + GPS_UART_PORT));
mmi_frm_set_protocol_event_handler(MSG_ID_UART_READY_TO_READ_IND, cl_ready_read_ind, MMI_TRUE);
U_Register_RX_cb( GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT), myapp_gps_uart_rx_cb);
U_Register_TX_cb( GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT), myapp_gps_uart_tx_cb);
UART_TurnOnPower(GPS_UART_PORT, KAL_TRUE);
if (U_Open(GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT)))
myapp_trace("uart2 open success");
else
myapp_trace("uart2 open fail");
//U_Open(GPS_UART_PORT, (module_type)(MOD_UART1_HISR + GPS_UART_PORT));
U_ClrRxBuffer(GPS_UART_PORT, UARTPort[GPS_UART_PORT].ownerid); /*clear sw RX buffer*/
U_ClrTxBuffer(GPS_UART_PORT, UARTPort[GPS_UART_PORT].ownerid); /*clear sw TX buffer*/
U_Purge(GPS_UART_PORT, RX_BUF, UARTPort[GPS_UART_PORT].ownerid);/*clear sw RX FIFO*/
U_Purge(GPS_UART_PORT, TX_BUF, UARTPort[GPS_UART_PORT].ownerid);/*clear sw TX FIFO*/
#else
UART_TurnOnPower(GPS_UART_PORT, KAL_TRUE);
if (U_Open(GPS_UART_PORT, GPS_UART_OWNERID))
myapp_trace("uart2 open success");
else
myapp_trace("uart2 open fail");
myapp_gps_uart_configure(9600, GPS_UART_PORT, GPS_UART_OWNERID);
U_ClrRxBuffer(GPS_UART_PORT, GPS_UART_OWNERID);
U_Register_RX_cb( GPS_UART_PORT, GPS_UART_OWNERID, myapp_gps_uart_rx_cb);
U_Register_TX_cb( GPS_UART_PORT, GPS_UART_OWNERID, myapp_gps_uart_tx_cb);
mmi_frm_set_protocol_event_handler(MSG_ID_UART_READY_TO_READ_IND, myapp_ready_read_ind, MMI_TRUE);
#endif
#endif
} |
|