/Designs/GPSRL02A/SW/buffer/a2dtest.c
15,7 → 15,8
//----- Include Files ---------------------------------------------------------
#include <avr/io.h> // include I/O definitions (port names, pin names, etc)
#include <avr/interrupt.h> // include interrupt support
#include <avr/interrupt.h> // include interrupt support
#include <string.h>
 
#include "global.h" // include our global settings
#include "uart.h" // include uart function library
68,36 → 69,49
 
while(1)
{
u08 c=0;
u08 n;
char radka[100];
u08 c=0;
u08 n,i;
char radiace[10];
char radka[201];
 
for(n=0;n<100;n++) radka[n]=0;
for(n=0;n<=100;n++) radka[n]=0; // vynuluj bufferovaci pole
for(n=0;n<10;n++) radiace[n]=0; // vynuluj bufferovaci pole
 
n=0;
while(uartReceiveByte(&c))
{
radka[n]=c;
n++;
}
n=0;
while(1) // pockej na $ kterym zacina NMEA radka
{
uartReceiveByte(&c);
if(c == '$') break;
}
 
n=0;
while (0!=radka[n])
{
uartSendByte(radka[n]);
n++;
timerPause(31);
}
for(i=0;i<100;i++) // nacti maximalne 100 znaku do bufferu
{
radka[n]=c;
if(c == '\n') break; // kdyz narazis na konec radku zastav nacitani
uartReceiveByte(&c);
n++;
}
 
radka[n]=0; // naztav na konec retezce pro zpracovani pomoci strcat
 
 
itoa(a2dConvert10bit(2),&radiace,10); //a2dConvert8bit(1)
if(n != 0)
{
strcat(radka, radiace);
strcat(radka,"\r");
}
n=0;
uartFlushReceiveBuffer();
 
while (0!=radka[n])
{
uartSendByte(radka[n]);
n++;
timerPause(35);
}
 
/* // sample all a2d channels and print them to the terminal
vt100SetCursorPos(2,1);
for(i=0; i<6; i++)
{
rprintf("Channel %d: %d \r\n", i, a2dConvert8bit(i));
timerPause(1000);
}
// print the sample number so far
rprintf("Sample # : %d \r\n", a++);*/
}
return 0;