Line 13... |
Line 13... |
13 |
// 20-Oct-2002 pstang Created the program |
13 |
// 20-Oct-2002 pstang Created the program |
14 |
//***************************************************************************** |
14 |
//***************************************************************************** |
15 |
|
15 |
|
16 |
//----- Include Files --------------------------------------------------------- |
16 |
//----- Include Files --------------------------------------------------------- |
17 |
#include <avr/io.h> // include I/O definitions (port names, pin names, etc) |
17 |
#include <avr/io.h> // include I/O definitions (port names, pin names, etc) |
18 |
#include <avr/interrupt.h> // include interrupt support |
18 |
#include <avr/interrupt.h> // include interrupt support |
- |
|
19 |
#include <string.h> |
19 |
|
20 |
|
20 |
#include "global.h" // include our global settings |
21 |
#include "global.h" // include our global settings |
21 |
#include "uart.h" // include uart function library |
22 |
#include "uart.h" // include uart function library |
22 |
#include "rprintf.h" // include printf function library |
23 |
#include "rprintf.h" // include printf function library |
23 |
#include "timer.h" // include timer function library (timing, PWM, etc) |
24 |
#include "timer.h" // include timer function library (timing, PWM, etc) |
Line 66... |
Line 67... |
66 |
// use a2dConvert8bit(channel#) to get an 8bit a2d reading |
67 |
// use a2dConvert8bit(channel#) to get an 8bit a2d reading |
67 |
// use a2dConvert10bit(channel#) to get a 10bit a2d reading |
68 |
// use a2dConvert10bit(channel#) to get a 10bit a2d reading |
68 |
|
69 |
|
69 |
while(1) |
70 |
while(1) |
70 |
{ |
71 |
{ |
71 |
u08 c=0; |
72 |
u08 c=0; |
72 |
u08 n; |
73 |
u08 n,i; |
- |
|
74 |
char radiace[10]; |
- |
|
75 |
|
73 |
char radka[100]; |
76 |
char radka[201]; |
74 |
|
77 |
|
75 |
for(n=0;n<100;n++) radka[n]=0; |
78 |
for(n=0;n<=100;n++) radka[n]=0; // vynuluj bufferovaci pole |
- |
|
79 |
for(n=0;n<10;n++) radiace[n]=0; // vynuluj bufferovaci pole |
76 |
|
80 |
|
77 |
n=0; |
81 |
n=0; |
78 |
while(uartReceiveByte(&c)) |
82 |
while(1) // pockej na $ kterym zacina NMEA radka |
79 |
{ |
83 |
{ |
80 |
radka[n]=c; |
84 |
uartReceiveByte(&c); |
81 |
n++; |
85 |
if(c == '$') break; |
82 |
} |
86 |
} |
83 |
|
87 |
|
- |
|
88 |
for(i=0;i<100;i++) // nacti maximalne 100 znaku do bufferu |
84 |
n=0; |
89 |
{ |
85 |
while (0!=radka[n]) |
90 |
radka[n]=c; |
86 |
{ |
- |
|
- |
|
91 |
if(c == '\n') break; // kdyz narazis na konec radku zastav nacitani |
87 |
uartSendByte(radka[n]); |
92 |
uartReceiveByte(&c); |
88 |
n++; |
93 |
n++; |
89 |
timerPause(31); |
- |
|
90 |
} |
94 |
} |
91 |
|
95 |
|
92 |
/* // sample all a2d channels and print them to the terminal |
96 |
radka[n]=0; // naztav na konec retezce pro zpracovani pomoci strcat |
- |
|
97 |
|
- |
|
98 |
|
93 |
vt100SetCursorPos(2,1); |
99 |
itoa(a2dConvert10bit(2),&radiace,10); //a2dConvert8bit(1) |
94 |
for(i=0; i<6; i++) |
100 |
if(n != 0) |
95 |
{ |
101 |
{ |
96 |
rprintf("Channel %d: %d \r\n", i, a2dConvert8bit(i)); |
102 |
strcat(radka, radiace); |
97 |
timerPause(1000); |
103 |
strcat(radka,"\r"); |
98 |
} |
104 |
} |
- |
|
105 |
n=0; |
99 |
// print the sample number so far |
106 |
uartFlushReceiveBuffer(); |
- |
|
107 |
|
- |
|
108 |
while (0!=radka[n]) |
- |
|
109 |
{ |
100 |
rprintf("Sample # : %d \r\n", a++);*/ |
110 |
uartSendByte(radka[n]); |
- |
|
111 |
n++; |
- |
|
112 |
timerPause(35); |
- |
|
113 |
} |
- |
|
114 |
|
101 |
} |
115 |
} |
102 |
|
116 |
|
103 |
return 0; |
117 |
return 0; |
104 |
} |
118 |
} |