STM32103VET6 库函数3.5
网上找了个处理GPS数据的例程,大概改了改,但是不出数。大家能给看看吗?
void USART1_IRQHandler(void)
{
u8 ch;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //若接收数据寄存器满
{
USART_ClearITPendingBit(USART1,USART_IT_RXNE); //清中断标志位
ch = USART_ReceiveData(USART1);
if ((ch == '$') && (gps_flag == 0)) //如果收到字符'$',便开始接收
{
rev_start = 1;
rev_stop = 0;
}
if (rev_start == 1) //标志位为1,开始接收
{
rev_buf[num++] = ch; //字符存到数组中
if (ch == '\n') //如果接收到换行
{
USART_ITConfig(USART1,USART_IT_RXNE,DISABLE); //关闭USART1 接收中断
rev_buf[num] = '\0';
rev_start = 0;
rev_stop = 1;
gps_flag = 1;
num = 0;
if (rev_stop) //如果接收完一行
{
if (GPS_GGA_Parse(rev_buf, &GPS)) //解析GPGGA
{
error_num = 0;
gps_flag = 0;
rev_stop = 0;
gpgga_flag = 1;
}
else
{
error_num++;
if (error_num >= 20) //如果数据无效超过20次
{
error_num = 20;
}
gps_flag = 0;
rev_stop = 0;
gpgga_flag = 0;
}
if (GPS_RMC_Parse(rev_buf, &GPS)) //解析GPRMC
{
error_num = 0;
gps_flag = 0;
rev_stop = 0;
gprmc_flag = 1;
}
else
{
error_num++;
if (error_num >= 20) //如果数据无效超过20次
{
error_num = 20;
}
gps_flag = 0;
rev_stop = 0;
gprmc_flag = 0;
}
if (GPS_GSV_Parse(rev_buf, &GPS)) //解析GPGGA
{
error_num = 0;
gps_flag = 0;
rev_stop = 0;
gpgsv_flag = 1;
}
else
{
error_num++;
if (error_num >= 20) //如果数据无效超过20次
{
error_num = 20;
}
gps_flag = 0;
rev_stop = 0;
gpgsv_flag = 0;
}
}
}
}
}
}
|