3866
- 收藏
- 点赞
- 分享
- 举报
GPS数据采集显示,实时更新(STM32F103RBT6)
前几天在am这买的GPS,调个usart3都调了半天,想在主程序里加上临界区,即时禁止和开启接收中断
不知道怎么用
USART_ITConfig(USART3, USART_IT_RXNE, DISABLE);
DoSomthing();
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
这对函数
一用就少数据 - -!
后来投机取巧绕过了这个问题,直接在中断里面处理字符串,在外面显示,避开了这个疑点,现在可以正常工作了。
//=================== stm32f10x_it.c ===============================================================================
void USART3_IRQHandler(void)
{
unsigned int temp = 0;
unsigned char *p_data = 0;
unsigned char *p_data_temp = 0;
unsigned char *p_GPS_type = 0;
unsigned int com_cnt = 0; //number of the comment symbol
temp = temp;
//static unsigned int GPS_data_cnt = 0;
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
flag_usart3Rx = 1;
usart3_data_r = USART_ReceiveData(USART3);
// RXNE pending bit can be also cleared by a read to the USART_DR register (USART_ReceiveData())
*p_GPS_data_buff = usart3_data_r;
if( usart3_data_r == 0x0A )
{
//USART_ITConfig(USART3, USART_IT_RXNE, DISABLE);
LED3_ON();
flag_GPS_data_updated = 1;
*(p_GPS_data_buff + 1) = '\0';
p_GPS_data_buff = GPS_data_buff;
}
else
{
LED3_OFF();
flag_GPS_data_updated = 0;
p_GPS_data_buff++;
}
if( flag_GPS_data_updated )
{
p_data = &GPS_data_buff[1];
p_GPS_keyword = GPS_keyword;
while( p_GPS_keyword < &GPS_keyword[5] )
{
*p_GPS_keyword++ = *p_data++;
}
*p_GPS_keyword = '\0';
if( strcmp( GPS_keyword, "GPGGA" ) == 0 )
{
com_cnt = 0;
for( p_data = &GPS_data_buff[6]; *p_data != '\0'; p_data++ )
{
if( *p_data == ',' )
{
com_cnt += 1;
if( com_cnt == 2 )
{
p_GPS_type = GPS_data.latitude;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else if( com_cnt == 3 )
{
p_GPS_type = &GPS_data.lat_ew;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else if( com_cnt == 4 )
{
p_GPS_type = GPS_data.longitude;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else if( com_cnt == 5 )
{
p_GPS_type = &GPS_data.long_ns;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else if( com_cnt == 7 )
{
p_GPS_type = GPS_data.satellites;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else if( com_cnt == 9 )
{
p_GPS_type = GPS_data.altitude;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
//*p_GPS_type = '\0';
p_data = p_data_temp - 1;
}
else
{
continue;
}
}
}
}
else if( strcmp( GPS_keyword, "GPGSA" ) == 0 )
{
}
else if( strcmp( GPS_keyword, "GPRMC" ) == 0 )
{
com_cnt = 0;
for( p_data = &GPS_data_buff[6]; *p_data != '\0'; p_data++ )
{
if( *p_data == ',' )
{
com_cnt += 1;
if( com_cnt == 1 )
{
p_GPS_type = GPS_data.time;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
p_data = p_data_temp - 1;
}
else if( com_cnt == 2 )
{
p_GPS_type = &GPS_data.status;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
p_data = p_data_temp - 1;
}
else if( com_cnt == 9 )
{
p_GPS_type = GPS_data.date;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
p_data = p_data_temp - 1;
}
else
{
continue;
}
}
}
}
else if( strcmp( GPS_keyword, "GPGSV" ) == 0 )
{
com_cnt = 0;
for( p_data = &GPS_data_buff[6]; *p_data != '\0'; p_data++ )
{
if( *p_data == ',' )
{
com_cnt += 1;
if( com_cnt == 3 )
{
p_GPS_type = GPS_data.satellites_inview;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
p_data = p_data_temp - 1;
}
else if( com_cnt == 4 )
{
p_GPS_type = GPS_data.satellites_id;
p_data_temp = p_data + 1;
while( *p_data_temp != ',' )
{
*p_GPS_type++ = *p_data_temp++;
}
p_data = p_data_temp - 1;
}
else
{
continue;
}
}
}
}
else
{
}
}
else
{
}
//printf( "%c", usart3_data_r );
//Wait_ms(1); //Why???????
}
}
//=================== gps.h ========================
/************************ (C) COPYLEFT 2010 Leafgrass *************************
* File Name : gps.h
* Author : Librae
* Last Modified Date : 08/19/2010
* Description : Provide GPS related functions and variables.
******************************************************************************/
/* Define to prevent recursive inclusion ----------------------------------- */
#ifndef __GPS_H__
#define __GPS_H__
/* Includes ---------------------------------------------------------------- */
/* Exported types ---------------------------------------------------------- */
typedef struct type_GPS_data
{
unsigned char status;
unsigned char lat_ew;
unsigned char latitude[11];
unsigned char long_ns;
unsigned char longitude[12];
unsigned char altitude[6];
unsigned char date[7];
unsigned char time[11];
unsigned char satellites[3];
unsigned char satellites_inview[3];
unsigned char satellites_id[3];
unsigned char speed;
//int direction;
float hdop;
}t_GPS_data;
/* Exported constants ------------------------------------------------------ */
/* Exported macro ---------------------------------------------------------- */
/* Exported variables ------------------------------------------------------ */
extern unsigned char GPS_keyword[5];
extern unsigned char GPS_data_buff[80];
extern unsigned char *p_GPS_data_buff;
extern unsigned char *p_GPS_keyword;
extern t_GPS_data GPS_data;
extern BOOLEAN flag_GPS_data_updated;
extern BOOLEAN flag_GPS_data_processed;
/* Exported functions ------------------------------------------------------ */
void GPS_Test(void);
#endif
/************************ (C) COPYLEFT 2010 Leafgrass ************************/
//=================== gps.c ===========================================================================
/************************ (C) COPYLEFT 2010 Leafgrass *************************
* File Name : gps.c
* Author : Librae
* Last Modified Date : 08/19/2010
* Description : This file provides the definition of
GPS related functions and variables.
******************************************************************************/
/* Includes -----------------------------------------------------------------*/
#include "includes.h"
/* Private typedef ----------------------------------------------------------*/
/* Private define -----------------------------------------------------------*/
/* Private macro ------------------------------------------------------------*/
/* Private variables --------------------------------------------------------*/
unsigned char GPS_keyword[5];
unsigned char GPS_data_buff[80];
unsigned char *p_GPS_data_buff = GPS_data_buff;
unsigned char *p_GPS_keyword = GPS_keyword;
t_GPS_data GPS_data;
BOOLEAN flag_GPS_data_updated = 1;
BOOLEAN flag_GPS_data_processed = 0;
/* Private function prototypes ----------------------------------------------*/
/* Private functions --------------------------------------------------------*/
void GPS_Test(void)
{
LCD_DispString( "GPS Test", YELLOW, BLACK, 11, 1 );
LCD_DispString( "Keyword: ", CYAN, BLACK, 0, 6 );
LCD_DispString( "Latitude: ", CYAN, BLACK, 0, 7 );
LCD_DispString( "Longitude: ", CYAN, BLACK, 0, 8 );
LCD_DispString( "Altitude: ", CYAN, BLACK, 0, 10 );
LCD_DispString( "Status: ", CYAN, BLACK, 0, 11 );
LCD_DispString( "UTC Time: ", CYAN, BLACK, 0, 12 );
LCD_DispString( "UTC Date: ", CYAN, BLACK, 0, 13 );
LCD_DispString( "Satellites used: ", CYAN, BLACK, 0, 15 );
LCD_DispString( "Satellites in view: ", CYAN, BLACK, 0, 16 );
LCD_DispString( "Satellites ID: ", CYAN, BLACK, 0, 17 );
for(;;)
{
if( flag_GPS_data_updated )
{
LCD_Clear_SelectArea( BLACK, 0, 48, 240, 48 );
LCD_DispString( GPS_data_buff, WHITE, BLACK, 0, 3 );
LCD_DispString( GPS_keyword, WHITE, BLACK, 9, 6 );
LCD_DispChar( GPS_data.lat_ew, WHITE, BLACK, 10, 7 );
LCD_DispString( GPS_data.latitude, WHITE, BLACK, 12, 7 );
LCD_DispChar( GPS_data.long_ns, WHITE, BLACK, 11, 8 );
LCD_DispString( GPS_data.longitude, WHITE, BLACK, 13, 8 );
LCD_DispString( GPS_data.altitude, WHITE, BLACK, 10, 10 );
LCD_DispChar( GPS_data.status, RED, BLACK, 8, 11 );
LCD_DispString( GPS_data.time, WHITE, BLACK, 10, 12 );
LCD_DispString( GPS_data.date, WHITE, BLACK, 10, 13 );
LCD_DispString( GPS_data.satellites, WHITE, BLACK, 17, 15 );
LCD_DispString( GPS_data.satellites_inview, WHITE, BLACK, 20, 16 );
LCD_DispString( GPS_data.satellites_id, WHITE, BLACK, 15, 17 );
flag_GPS_data_updated = 0;
//USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
}
if( flag_usart3Rx )
{
flag_usart3Rx = 0;
}
}
}
/************************ (C) COPYLEFT 2010 Leafgrass ************************/
下面是keil工程
代码主要在gps.h gps.c 和 stm32f10x_it.c里
文件: RTOS_STM32(v2.4).rar
下载
我来回答
回答1个
时间排序
认可量排序
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2013-06-29 12:30:23
-
2018-12-29 15:37:34
-
2018-12-11 09:01:00
-
2018-12-11 08:59:22
-
2018-12-03 16:05:52
-
2018-12-06 15:17:11
-
2018-12-31 13:22:03
-
2013-08-24 22:51:57
-
2018-12-11 09:02:19
-
2018-12-06 11:16:35
-
2018-10-22 11:24:52
-
2010-06-01 23:11:38
-
2018-11-07 16:57:45
-
2013-11-18 21:45:29
-
2018-12-09 11:56:00
-
2018-12-11 09:06:40
-
2019-01-23 16:28:16
-
2019-01-31 10:26:36
-
2020-11-11 15:38:13
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认