Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | //***************************************************************************** |
2 | // File Name : gpstest.c |
||
3 | // |
||
4 | // Title : example usage of gps processing library functions |
||
5 | // Revision : 1.0 |
||
6 | // Notes : |
||
7 | // Target MCU : Atmel AVR series |
||
8 | // Editor Tabs : 4 |
||
9 | // |
||
10 | // Revision History: |
||
11 | // When Who Description of change |
||
12 | // ----------- ----------- ----------------------- |
||
13 | // 10-Sep-2002 pstang Created the program |
||
14 | //***************************************************************************** |
||
15 | |||
16 | |||
17 | //----- Include Files --------------------------------------------------------- |
||
18 | #include <avr/io.h> // include I/O definitions (port names, pin names, etc) |
||
19 | #include <avr/interrupt.h> // include interrupt support |
||
20 | //#include <math.h> |
||
21 | #include <stdlib.h> |
||
22 | |||
23 | #include "global.h" // include our global settings |
||
24 | #include "uart2.h" // include dual-uart function library |
||
25 | #include "rprintf.h" // include printf function library |
||
26 | #include "timer.h" // include timer function library (timing, PWM, etc) |
||
27 | #include "gps.h" // include gps data support |
||
28 | #include "tsip.h" // include TSIP gps packet handling |
||
29 | #include "nmea.h" // include NMEA gps packet handling |
||
30 | #include "vt100.h" // include VT100 terminal commands |
||
31 | |||
32 | // uartRxOverflow is a global variable defined in uart.c/uart2.c |
||
33 | // we define it here as <extern> here so that we can use its value |
||
34 | // in code contained in this file |
||
35 | extern unsigned short uartRxOverflow[2]; |
||
36 | |||
37 | void gpsTsipTest(void); |
||
38 | void gpsNmeaTest(void); |
||
39 | |||
40 | //----- Begin Code ------------------------------------------------------------ |
||
41 | int main(void) |
||
42 | { |
||
43 | // initialize our libraries |
||
44 | // initialize the UART (serial port) |
||
45 | uartInit(); |
||
46 | // set the baud rate of UART 0 for our debug/reporting output |
||
47 | uartSetBaudRate(0,9600); |
||
48 | // set uart0SendByte as the output for all rprintf statements |
||
49 | rprintfInit(uart0SendByte); |
||
50 | // initialize the timer system |
||
51 | timerInit(); |
||
52 | // initialize vt100 library |
||
53 | vt100Init(); |
||
54 | |||
55 | // print a little intro message so we know things are working |
||
56 | vt100ClearScreen(); |
||
57 | rprintf("\r\nWelcome to GPS Test!\r\n"); |
||
58 | |||
59 | // run example gps processing loop |
||
60 | // (pick the one appropriate for your GPS packet format) |
||
61 | // gpsTsipTest(); |
||
62 | gpsNmeaTest(); |
||
63 | |||
64 | return 0; |
||
65 | } |
||
66 | |||
67 | void gpsTsipTest(void) |
||
68 | { |
||
69 | // set the baud rate of UART 1 for TSIP |
||
70 | uartSetBaudRate(1,9600); |
||
71 | |||
72 | // clear screen |
||
73 | vt100ClearScreen(); |
||
74 | // initialize gps library |
||
75 | gpsInit(); |
||
76 | // initialize gps packet decoder |
||
77 | tsipInit(uart1SendByte); // use uart1 for tsip packet output |
||
78 | |||
79 | // begin gps packet processing loop |
||
80 | while(1) |
||
81 | { |
||
82 | // process received gps packets until receive buffer is exhausted |
||
83 | while( tsipProcess(uartGetRxBuffer(1)) ); |
||
84 | |||
85 | // set cursor position to top left of screen |
||
86 | vt100SetCursorPos(0,0); |
||
87 | // print/dump current formatted GPS data |
||
88 | gpsInfoPrint(); |
||
89 | // print UART 1 overflow status to verify that we're processing packets |
||
90 | // fast enough and that our receive buffer is large enough |
||
91 | rprintf("Uart1RxOvfl: %d\r\n",uartRxOverflow[1]); |
||
92 | // pause for 100ms |
||
93 | timerPause(100); |
||
94 | } |
||
95 | } |
||
96 | |||
97 | void gpsNmeaTest(void) |
||
98 | { |
||
99 | // set the baud rate of UART 1 for NMEA |
||
100 | uartSetBaudRate(1,4800); |
||
101 | |||
102 | // clear screen |
||
103 | vt100ClearScreen(); |
||
104 | // initialize gps library |
||
105 | gpsInit(); |
||
106 | // initialize gps packet decoder |
||
107 | nmeaInit(); |
||
108 | |||
109 | // begin gps packet processing loop |
||
110 | while(1) |
||
111 | { |
||
112 | // process received gps packets until receive buffer is exhausted |
||
113 | while( nmeaProcess(uartGetRxBuffer(1)) ); |
||
114 | |||
115 | // set cursor position to top left of screen |
||
116 | vt100SetCursorPos(0,0); |
||
117 | // print/dump current formatted GPS data |
||
118 | gpsInfoPrint(); |
||
119 | // print UART 1 overflow status to verify that we're processing packets |
||
120 | // fast enough and that our receive buffer is large enough |
||
121 | rprintf("Uart1RxOvfl: %d\r\n",uartRxOverflow[1]); |
||
122 | // pause for 100ms |
||
123 | timerPause(100); |
||
124 | } |
||
125 | } |
||
126 |
Powered by WebSVN v2.8.3