/FollowMe/trunk/analog.c |
---|
2,8 → 2,8 |
#include <stdlib.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include "analog.h" |
#include "printf_P.h" |
volatile uint16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
volatile uint8_t ADReady = 1; |
14,6 → 14,7 |
void ADC_Init(void) |
{ |
uint8_t sreg = SREG; |
printf("\r\n ADC init..."); |
// disable all interrupts before reconfiguration |
cli(); |
//ADC0 ... ADC7 is connected to PortA pin 0 ... 7 |
36,6 → 37,8 |
ADC_Enable(); |
// restore global interrupt flags |
SREG = sreg; |
sei(); |
printf("ok"); |
} |
/*****************************************************/ |
/FollowMe/trunk/button.c |
---|
1,5 → 1,6 |
#include "timer0.h" |
#include "button.h" |
#include "printf_P.h" |
#ifdef USE_FOLLOWME |
16,7 → 17,7 |
void Button_Init(void) |
{ |
printf("\r\n BUTTON init..."); |
// set port pin as input pullup |
#ifdef USE_FOLLOWME |
PORTC |= (1 << PORTC6); |
28,6 → 29,7 |
DDRC &= ~(1 << DDC3); |
#endif |
ButtonTimer = SetDelay(KEY_DELAY_MS); |
printf("ok"); |
} |
uint8_t GetButton(void) |
/FollowMe/trunk/gpx.c |
---|
60,10 → 60,7 |
#include "gpx.h" |
#include "gpx_header.h" |
#include "timer0.h" |
//#include "spi_slave.h" |
#include "main.h" |
#include "uart1.h" |
#include "ubx.h" |
//________________________________________________________________________________________________________________________________________ |
// Function: GPX_DocumentInit(GPX_Document_t *) |
95,6 → 92,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc == NULL) return(0); |
GPX_DocumentInit(doc); // intialize the document with resetvalues |
103,8 → 103,13 |
if(doc->file != NULL) // could the file be opened? |
{ |
retvalue = 1; // the document could be created on the drive. |
doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
fwrite_((void*)GPX_DOCUMENT_HEADER, sizeof(GPX_DOCUMENT_HEADER)-1,1,doc->file);// write the gpx-header to the document. |
doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
str = GPX_DOCUMENT_HEADER; // write the gpx-header to the document.. |
for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
} |
return(retvalue); |
123,6 → 128,9 |
{ |
uint8_t retvalue = 1; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc == NULL) return(0); |
141,7 → 149,12 |
case GPX_DOC_OPENED: // close the file on the memorycard |
if(doc->file != NULL) |
{ |
fwrite_((void*)GPX_DOCUMENT_FOOTER, sizeof(GPX_DOCUMENT_FOOTER)-1,1,doc->file); // write the gpx-footer to the document. |
str = GPX_DOCUMENT_FOOTER; // write the gpx-footer to the document. |
for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
fclose_(doc->file); |
retvalue = 1; |
} |
169,6 → 182,11 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == GPX_DOC_OPENED) |
{ |
if(doc->file != NULL) |
175,7 → 193,12 |
{ |
doc->state = GPX_DOC_TRACK_OPENED; |
retvalue = 1; |
fwrite_((void*)GPX_TRACK_HEADER, sizeof(GPX_TRACK_HEADER)-1,1,doc->file); |
str = GPX_TRACK_HEADER; |
for(i= 0; i < sizeof(GPX_TRACK_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
} |
} |
return(retvalue); |
194,6 → 217,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == GPX_DOC_TRACK_OPENED) |
{ |
200,8 → 226,12 |
if(doc->file != NULL) |
{ |
doc->state = GPX_DOC_OPENED; |
fwrite_((void*)GPX_TRACK_FOOTER, sizeof(GPX_TRACK_FOOTER)-1,1,doc->file); |
retvalue = 1; |
str = GPX_TRACK_FOOTER; |
for(i= 0; i < sizeof(GPX_TRACK_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
} |
} |
221,6 → 251,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == GPX_DOC_TRACK_OPENED) |
{ |
227,7 → 260,12 |
if(doc->file != NULL) |
{ |
doc->state = GPX_DOC_TRACKSEGMENT_OPENED; |
fwrite_((void*)GPX_TRACKSEGMENT_HEADER, sizeof(GPX_TRACKSEGMENT_HEADER)-1,1,doc->file); |
str = GPX_TRACKSEGMENT_HEADER; |
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
retvalue = 1; |
} |
} |
247,12 → 285,22 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == GPX_DOC_TRACKSEGMENT_OPENED) |
{ |
if(doc->file != NULL) |
{ |
doc->state = GPX_DOC_TRACK_OPENED; |
fwrite_((void*)GPX_TRACKSEGMENT_FOOTER, sizeof(GPX_TRACKSEGMENT_FOOTER)-1,1,doc->file); |
str = GPX_TRACKSEGMENT_FOOTER; |
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
retvalue = 1; |
} |
} |
/FollowMe/trunk/gpx_header.h |
---|
1,3 → 1,5 |
// all constant strings are within the flash to save space in the sram |
#include <avr/pgmspace.h> |
//________________________________________________________________________________________________________________________________________ |
// |
// Definition of gpx-header and footer elements for documents |
5,7 → 7,7 |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_DOCUMENT_HEADER[] = |
const prog_char GPX_DOCUMENT_HEADER[] = |
{ |
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\r\n" |
"<gpx creator=\"NC\" version=\"1.0\" >\r\n" |
23,7 → 25,7 |
// footer of an gpx-file. |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_DOCUMENT_FOOTER[] = |
const prog_char GPX_DOCUMENT_FOOTER[] = |
{ |
"</gpx>\r\n" |
}; |
34,7 → 36,7 |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_TRACK_HEADER[] = |
const prog_char GPX_TRACK_HEADER[] = |
{ |
"<trk>\r\n" |
"<name>Flight</name>\r\n" |
45,7 → 47,7 |
// Footer of a track |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_TRACK_FOOTER[] = |
const prog_char GPX_TRACK_FOOTER[] = |
{ |
"</trk>\r\n" |
}; |
55,7 → 57,7 |
// Header of a track segment |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_TRACKSEGMENT_HEADER[] = |
const prog_char GPX_TRACKSEGMENT_HEADER[] = |
{ |
"<trkseg>\r\n" |
}; |
65,7 → 67,7 |
// Footer of a track segment |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t GPX_TRACKSEGMENT_FOOTER[] = |
const prog_char GPX_TRACKSEGMENT_FOOTER[] = |
{ |
"</trkseg>\r\n" |
}; |
/FollowMe/trunk/kml.c |
---|
118,6 → 118,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc == NULL) return(0); |
127,10 → 130,14 |
if(doc->file != NULL) // could the file be opened? |
{ |
retvalue = 1; // the document could be created on the drive. |
doc->state = KML_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
fwrite_((void*)KML_DOCUMENT_HEADER, sizeof(KML_DOCUMENT_HEADER)-1,1,doc->file);// write the KML-header to the document. |
doc->state = KML_DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
str = KML_DOCUMENT_HEADER; // write the KML-header to the document. |
for(i= 0; i < sizeof(KML_DOCUMENT_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
} |
return(retvalue); |
} |
147,6 → 154,9 |
{ |
uint8_t retvalue = 1; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc == NULL) return(0); |
165,7 → 175,12 |
case KML_DOC_OPENED: // close the file on the memorycard |
if(doc->file != NULL) |
{ |
fwrite_((void*)KML_DOCUMENT_FOOTER, sizeof(KML_DOCUMENT_FOOTER)-1,1,doc->file); // write the KML- footer to the document. |
str = KML_DOCUMENT_FOOTER; // write the KML- footer to the document. |
for(i= 0; i < sizeof(KML_DOCUMENT_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
fclose_(doc->file); |
retvalue = 1; |
} |
193,6 → 208,10 |
uint8_t KML_PlaceMarkOpen(KML_Document_t *doc) |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == KML_DOC_OPENED) |
{ |
if(doc->file != NULL) |
199,7 → 218,12 |
{ |
doc->state = KML_DOC_PLACEMARK_OPENED; |
retvalue = 1; |
fwrite_((void*)KML_PLACEMARK_HEADER, sizeof(KML_PLACEMARK_HEADER)-1,1,doc->file); |
str = KML_PLACEMARK_HEADER; |
for(i= 0; i < sizeof(KML_PLACEMARK_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
} |
} |
return(retvalue); |
217,7 → 241,10 |
uint8_t KML_PlaceMarkClose(KML_Document_t *doc) |
{ |
uint8_t retvalue = 0; // close the Placemark-tag of the corosponding document. |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == KML_DOC_PLACEMARK_OPENED) |
{ |
224,11 → 251,15 |
if(doc->file != NULL) |
{ |
doc->state = KML_DOC_OPENED; |
fwrite_((void*)KML_PLACEMARK_FOOTER, sizeof(KML_PLACEMARK_FOOTER)-1,1,doc->file); |
str = KML_PLACEMARK_FOOTER; |
for(i= 0; i < sizeof(KML_PLACEMARK_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
retvalue = 1; |
} |
} |
return(retvalue); |
} |
245,6 → 276,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == KML_DOC_PLACEMARK_OPENED) |
{ |
251,7 → 285,12 |
if(doc->file != NULL) |
{ |
doc->state = KML_DOC_LINESTRING_OPENED; |
fwrite_((void*)KML_LINESTRING_HEADER, sizeof(KML_LINESTRING_HEADER)-1,1,doc->file); |
str = KML_LINESTRING_HEADER; |
for(i= 0; i < sizeof(KML_LINESTRING_HEADER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
retvalue = 1; |
} |
} |
271,6 → 310,9 |
{ |
uint8_t retvalue = 0; |
uint16_t i; |
int8_t c; |
const prog_char *str; |
if(doc->state == KML_DOC_LINESTRING_OPENED) |
{ |
277,7 → 319,12 |
if(doc->file != NULL) |
{ |
doc->state = KML_DOC_PLACEMARK_OPENED; |
fwrite_((void*)KML_LINESTRING_FOOTER, sizeof(KML_LINESTRING_FOOTER)-1,1,doc->file); |
str = KML_LINESTRING_FOOTER; |
for(i= 0; i < sizeof(KML_LINESTRING_FOOTER); i++) |
{ |
c = (int8_t)pgm_read_byte(str++); // get byte from flash |
fputc_(c, doc->file); // and write that to sd-card |
} |
retvalue = 1; |
} |
} |
298,7 → 345,6 |
uint8_t retvalue = 0; |
int8_t string[50]; |
// int32_t rel_altitude = 0; |
if(doc == NULL) return(0); |
331,7 → 377,6 |
} |
} |
} |
return(retvalue); |
} |
352,7 → 397,7 |
switch(doc->state) |
{ |
case KML_DOC_CLOSED: // document hasn't been opened yet therefore it will be initialized automatically |
retval = KML_DocumentOpen("default.kml",doc); // open the kml-document with a standardname. |
retval = KML_DocumentOpen("default.kml",doc); // open the kml-document with a standardname. |
break; |
case KML_DOC_OPENED: // if a document has been opened before but no placemark exists: |
/FollowMe/trunk/kml_header.h |
---|
1,9 → 1,12 |
// all constant strings are within the flash to save space in the sram |
#include <avr/pgmspace.h> |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// Definition of KML header and footer elements for documents, placemarks and linestrings |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_DOCUMENT_HEADER[] = |
const prog_char KML_DOCUMENT_HEADER[] = |
{ |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" |
"<kml xmlns=\"http://earth.google.com/kml/2.2\">\r\n" |
19,11 → 22,11 |
}; |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// footer of an KML- file. |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_DOCUMENT_FOOTER[] = |
const prog_char KML_DOCUMENT_FOOTER[] = |
{ |
"</Document>\r\n" |
"</kml>\r\n" |
30,11 → 33,11 |
}; |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// Header of an placemark |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_PLACEMARK_HEADER[] = |
const prog_char KML_PLACEMARK_HEADER[] = |
{ |
"<Placemark>\r\n" |
"<name>Flight</name>\r\n" |
42,11 → 45,11 |
}; |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// Footer of an placemark |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_PLACEMARK_FOOTER[] = |
const prog_char KML_PLACEMARK_FOOTER[] = |
{ |
"</Placemark>\r\n" |
}; |
53,11 → 56,11 |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// Header of an linestring |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_LINESTRING_HEADER[] = |
const prog_char KML_LINESTRING_HEADER[] = |
{ |
"<LineString>\r\n" |
"<tessellate>1</tessellate>\r\n" |
66,11 → 69,11 |
}; |
//________________________________________________________________________________________________________________________________________ |
// |
// |
// Footer of an linestring |
// |
// |
//________________________________________________________________________________________________________________________________________ |
const int8_t KML_LINESTRING_FOOTER[] = |
const prog_char KML_LINESTRING_FOOTER[] = |
{ |
"\r\n</coordinates>" |
"\r\n</LineString>\r\n" |
/FollowMe/trunk/main.c |
---|
36,7 → 36,7 |
static uint16_t FollowMe_Timer = 0; |
// disable interrupts global |
cli(); |
//cli(); |
// disable watchdog |
MCUSR &=~(1<<WDRF); |
55,17 → 55,16 |
// enable interrupts global |
sei(); |
LEDRED_OFF; |
LEDGRN_ON; |
// try to initialize the FAT 16 filesystem on the SD-Card |
Fat16_Init(); |
// initialize the settings |
Settings_Init(); |
// initialize logging (needs settings) |
Logging_Init(); |
LEDRED_OFF; |
LEDGRN_ON; |
#ifdef USE_SDLOGGER |
printf("\r\n\r\nHW: SD-Logger"); |
#endif |
/FollowMe/trunk/makefile |
---|
76,7 → 76,7 |
########################################################################################################## |
# List C source files here. (C dependencies are automatically generated.) |
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c logging.c kml.c |
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c logging.c kml.c gpx.c |
########################################################################################################## |
/FollowMe/trunk/timer0.c |
---|
66,8 → 66,8 |
CountMilliseconds = 0; |
SREG = sreg; |
sei(); |
} |
/FollowMe/trunk/uart0.c |
---|
7,6 → 7,7 |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/wdt.h> |
#include <stdarg.h> |
#include <string.h> |
28,7 → 29,6 |
#define FALSE 0 |
#define TRUE 1 |
uint8_t text[100]; // globally used text buffer |
//int8_t test __attribute__ ((section (".noinit"))); |
uint8_t Request_VerInfo = FALSE; |
55,11 → 55,12 |
UART_VersionInfo_t UART_VersionInfo; |
uint16_t DebugData_Timer; |
uint16_t DebugData_Interval = 500; // in 1ms |
uint16_t DebugData_Interval = 0; // in 1ms |
Waypoint_t FollowMe; |
const uint8_t ANALOG_LABEL[32][16] = |
// keep lables in flash to save 512 bytes of sram space |
const prog_uint8_t ANALOG_LABEL[32][16] = |
{ |
//1234567890123456 |
"Analog_Ch0 ", //0 |
174,6 → 175,8 |
// restore global interrupt flags |
SREG = sreg; |
sei(); |
printf("\r\n UART0 init...ok"); |
} |
/****************************************************************/ |
500,7 → 503,9 |
} |
if(Request_DebugLabel != 0xFF) // Texte für die Analogdaten |
{ |
SendOutData('A', FM_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), ANALOG_LABEL[Request_DebugLabel], 16); |
uint8_t label[16]; // local sram buffer |
memcpy_P(label, ANALOG_LABEL[Request_DebugLabel], 16); // read lable from flash to sram buffer |
SendOutData('A', FM_ADDRESS, 2, (uint8_t *) &Request_DebugLabel, sizeof(Request_DebugLabel), label, 16); |
Request_DebugLabel = 0xFF; |
} |
if(Request_ExternalControl && txd_complete) |
/FollowMe/trunk/uart0.h |
---|
22,7 → 22,6 |
extern uint8_t PcAccess; |
extern uint8_t RemotePollDisplayLine; |
extern uint8_t text[100]; // globally used text buffer |
typedef struct |
{ |
/FollowMe/trunk/uart1.c |
---|
3,6 → 3,7 |
#include "main.h" |
#include "uart1.h" |
#include "printf_P.h" |
#include "ubx.h" |
11,6 → 12,7 |
/****************************************************************/ |
void USART1_Init (void) |
{ |
printf("\r\n UART1 init..."); |
// USART1 Control and Status Register A, B, C and baud rate register |
uint8_t sreg = SREG; |
uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * USART1_BAUD) - 1); |
70,7 → 72,8 |
// restore global interrupt flags |
SREG = sreg; |
sei(); |
printf("ok"); |
} |
/****************************************************************/ |
/FollowMe/trunk/ubx.c |
---|
208,11 → 208,13 |
/********************************************************/ |
void UBX_Init(void) |
{ |
printf("\r\n UBX init..."); |
// mark msg buffers invalid |
UbxSol.Status = INVALID; |
UbxPosLlh.Status = INVALID; |
UbxVelNed.Status = INVALID; |
GPSData.Status = INVALID; |
printf("ok"); |
} |
/********************************************************/ |