//*****************************************************************************// 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 <stdio.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//#include "utm.h" // Lat Lon to UTM conversion#include <util/delay.h>// LCD Library#include "lcd_hd44780.h"static int lcd_putc_stream(char c, FILE *unused){return lcd_putc(c);}// Define Output Stream to LCDstatic FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putc_stream, NULL, _FDEV_SETUP_WRITE);// 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){sbi(DDRC, 0); // sets PC0 to be an outputcbi(PORTC, 0); // sets PC0 to output a HIGH_delay_ms(100);sbi(PORTC, 0); // sets PC0 to output a LOW_delay_ms(100);cbi(PORTC, 0); // sets PC0 to output a HIGH_delay_ms(100);sbi(PORTC, 0); // sets PC0 to output a LOW_delay_ms(100);// initialize our libraries// initialize the UART (serial port)// uartInit();uart1Init();sbi(DDRC, 1); // sets PC0 to be an outputcbi(PORTC, 1); // sets PC0 to output a HIGH_delay_ms(100);sbi(PORTC, 1); // sets PC0 to output a LOW_delay_ms(100);cbi(PORTC, 1); // sets PC0 to output a HIGH_delay_ms(100);sbi(PORTC, 1); // sets PC0 to output a LOW_delay_ms(100);// set the baud rate of UART 0 for our debug/reporting output// uartSetBaudRate(0,9600);// set uart0SendByte as the output for all rprintf statements// rprintfInit(uart0SendByte);// initialize the timer systemtimerInit();// initialize vt100 library// vt100Init();// print a little intro message so we know things are working// vt100ClearScreen();// rprintf("\r\nWelcome to GPS Test!\r\n");// timerPause(1000);lcd_init(); // Init LCD (interface and display module)rprintfInit(lcd_putc);rprintfProgStrM("Ahoj..."); rprintfCRLF();_delay_ms(500);lcd_clear();// run example gps processing loop// (pick the one appropriate for your GPS packet format)gpsNmeaTest();return 0;}void gpsNmeaTest(void){// set the baud rate of UART 1 for NMEAuartSetBaudRate(1,4800);// clear screen// vt100ClearScreen();// initialize gps librarygpsInit();// initialize gps packet decodernmeaInit();DDRD = 0b10100000; // sets PD7 O, PD6 I, PD5 Ocbi(PORTD, 7); // sets PD7 to output a LOWsbi(PORTD, 5); // sets PD5 to output a HIGH// begin gps packet processing loopwhile(1){// process received gps packets until receive buffer is exhaustedwhile( nmeaProcess(uartGetRxBuffer(1))== NMEA_NODATA);if((inb(PIND) & 0b01000000)==0)gpsInfoPrintLCD();elsegpsInfoPrintLCD2();sbi(DDRC, 0); // sets PC0 to be an outputcbi(PORTC, 0); // sets PC0 to output a LOW_delay_ms(5);sbi(PORTC, 0); // sets PC0 to output a HIGH}}