No changes between revisions
/Designs/GPSRL03A/main.c |
|
+ |
+/* Put a character to transmit */ |
+static |
+void uart_put (uint8_t d) |
+{ |
+ while (bit_is_clear(UCSR0A, UDRE0)); |
+ UDR0 = d; |
+} |
+ |
+ |
/* USART0 RXC interrupt */ |
ISR(USART_RX_vect) |
{ |
@@ -262,6 +272,21 @@ |
return c; |
} |
|
+ |
+ |
+/* Initialize GPS module (depends on each product) */ |
+static |
+void gp_init (void) |
+{ |
+ const prog_char *s = |
+ PSTR("$PSRF106,21*0F\r\n"); // Select datum of WGS84 (for EM-406A) |
+ char c; |
+ |
+ while ((c = pgm_read_byte(s++)) != 0) uart_put(c); |
+} |
+ |
+ |
+ |
/* Get a column item */ |
static |
BYTE* gp_col ( /* Returns pointer to the item (returns a NULL when not found) */ |
@@ -340,6 +365,7 @@ |
|
beep(5, 1); // Single beep. Start to get current time. |
uart_init(); |
+ gp_init(); // Initialize GPS module to let output data in NMEA-0183 format. |
do { // Wait for valid RMC sentence. |
b = get_line(); |
if (!b) break; |
@@ -370,14 +396,14 @@ |
) |
{ |
if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; }; |
-/* itoa(battery,&Value1,10); // convert binary number to character |
+ itoa(battery,&Value1,10); |
itoa(intensity,&Value2,10); |
strcpy(&Buff[0], Value1); |
strcpy_P(&Buff[4], PSTR(",")); |
strcpy(&Buff[5], Value2); |
strcpy_P(&Buff[9], PSTR("\r\n")); |
- if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 8; break; }; |
-*/ } |
+ if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 5; break; }; |
+ } |
if ((Stat & 4) == 0) continue; |
if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec. |
cli(); Stat &= 0xFB; sei(); // Clear sync request |