gps_main.c
来自「usoc在北京博创兴业有限公司的实验平台s3c2410上运行。 2. 各实验的全」· C语言 代码 · 共 106 行
C
106 行
/************************************************ * serial communication demo * by Zou jian guo <ah_zou@163.com> * 2003-12-22 **************************************************/#include <stdio.h>#include "../inc/gps.h"#include "../inc/sys/lib.h"#include "inc/drv/Serial.h"#include <string.h>#include "os_cpu.h"#include "../ucos-ii/includes.h"#include "../ucos-ii/ucos_ii.h"#define FALSE 0#define TRUE 1volatile int STOP=FALSE;GPS_INFO gps_info;int GET_GPS_OK=FALSE;char GPS_BUF[1024],*rxmsg;OS_EVENT *mbox;#define rULCON2 (*(volatile unsigned *)0x50008000)//p317#define rUCON2 (*(volatile unsigned *)0x50008004)//p318#define rUFCON2 (*(volatile unsigned *)0x50008008)//p320#define rUTRSTAT2 (*(volatile unsigned *)0x50008010)//p322#define rUERSTAT2 (*(volatile unsigned *)0x50008014)//p323#define rUFSTAT2 (*(volatile unsigned *)0x50008018)//p324#define rURXH2 (*(volatile unsigned *)0x50008024)//326#define rUBRDIV2 (*(volatile unsigned *)0x50008028)//327/*--------------------------------------------------------*//* modem input handler */void show_gps_info(void * Id){ char txmsg; INT8U err; while(1){ //Uart_Printf(0,"\n(3)Enter show_gps_info\n"); rxmsg=OSMboxPend(mbox,0,&err); gps_parse(rxmsg,&gps_info); show_gps(&gps_info); OSTimeDly(50); //Uart_Printf(0,"\nenter show_gps_info\n"); } }/*--------------------------------------------------------*//* modem input handler */void receive(void * Id){ int i=0,counter=0; char c; char buf[200]; GPS_INFO GPS; Uart_Init(2,4800); OpenUartRev(2); hudelay(100); mbox=OSMboxCreate((void *)0); while (1) { while(1){ //Uart_Printf(0,"\n(2)enter receive\n"); if(c=Uart_Getch(2)){ buf[i++] = c; if(i>=200){//防止buf[]越界 i=0; break; } } if(c == '\n'){ buf[i]=0; //Uart_Printf(0,"some message over buf[i++]=%s in the Function receive",buf); break; } } //end while(1) if(buf[0] == '$'){ i=0; //Uart_Printf(0,"\n(2)quit receive\n"); OSMboxPost(mbox,(void *)buf); } OSTimeDly(1000); }}/*--------------------------------------------------------*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?