Blame | Last modification | View Log | Download
//*****************************************************************************// File Name : gpstest.c//// Title : example usage of gps processing library functions// Revision : 1.0// Notes :// Target MCU : Atmel AVR series// Editor Tabs : 4//// Revision History:// When Who Description of change// ----------- ----------- -----------------------// 10-Sep-2002 pstang Created the program//*****************************************************************************//----- Include Files ---------------------------------------------------------#include <avr/io.h> // include I/O definitions (port names, pin names, etc)#include <avr/interrupt.h> // include interrupt support//#include <math.h>#include <stdlib.h>#include "global.h" // include our global settings#include "uart2.h" // include dual-uart function library#include "rprintf.h" // include printf function library#include "timer.h" // include timer function library (timing, PWM, etc)#include "gps.h" // include gps data support#include "tsip.h" // include TSIP gps packet handling#include "nmea.h" // include NMEA gps packet handling#include "vt100.h" // include VT100 terminal commands// uartRxOverflow is a global variable defined in uart.c/uart2.c// we define it here as <extern> here so that we can use its value// in code contained in this fileextern unsigned short uartRxOverflow[2];void gpsTsipTest(void);void gpsNmeaTest(void);//----- Begin Code ------------------------------------------------------------int main(void){// initialize our libraries// initialize the UART (serial port)uartInit();// set the baud rate of UART 0 for our debug/reporting outputuartSetBaudRate(0,9600);// set uart0SendByte as the output for all rprintf statementsrprintfInit(uart0SendByte);// initialize the timer systemtimerInit();// initialize vt100 libraryvt100Init();// print a little intro message so we know things are workingvt100ClearScreen();rprintf("\r\nWelcome to GPS Test!\r\n");// run example gps processing loop// (pick the one appropriate for your GPS packet format)// gpsTsipTest();gpsNmeaTest();return 0;}void gpsTsipTest(void){// set the baud rate of UART 1 for TSIPuartSetBaudRate(1,9600);// clear screenvt100ClearScreen();// initialize gps librarygpsInit();// initialize gps packet decodertsipInit(uart1SendByte); // use uart1 for tsip packet output// begin gps packet processing loopwhile(1){// process received gps packets until receive buffer is exhaustedwhile( tsipProcess(uartGetRxBuffer(1)) );// set cursor position to top left of screenvt100SetCursorPos(0,0);// print/dump current formatted GPS datagpsInfoPrint();// print UART 1 overflow status to verify that we're processing packets// fast enough and that our receive buffer is large enoughrprintf("Uart1RxOvfl: %d\r\n",uartRxOverflow[1]);// pause for 100mstimerPause(100);}}void gpsNmeaTest(void){// set the baud rate of UART 1 for NMEAuartSetBaudRate(1,4800);// clear screenvt100ClearScreen();// initialize gps librarygpsInit();// initialize gps packet decodernmeaInit();// begin gps packet processing loopwhile(1){// process received gps packets until receive buffer is exhaustedwhile( nmeaProcess(uartGetRxBuffer(1)) );// set cursor position to top left of screenvt100SetCursorPos(0,0);// print/dump current formatted GPS datagpsInfoPrint();// print UART 1 overflow status to verify that we're processing packets// fast enough and that our receive buffer is large enoughrprintf("Uart1RxOvfl: %d\r\n",uartRxOverflow[1]);// pause for 100mstimerPause(100);}}