Rev 1234 Rev 1271
Line 180... Line 180...
180 if(i >= sizeof(rxfifo.buff)) 180 if(i >= sizeof(rxfifo.buff))
181 i = 0; 181 i = 0;
182 rxfifo.idx_r = i; 182 rxfifo.idx_r = i;
183   183  
184 return d; 184 return d;
185 } 185 }
186   -  
187   -  
188 /* Put a character to transmit */ -  
189 static -  
190 void uart_put (uint8_t d) -  
191 { -  
192 while (bit_is_clear(UCSR0A, UDRE0)); -  
193 UDR0 = d; -  
194 } -  
195   -  
196   -  
197 /* USART0 RXC interrupt */ 186 /* USART0 RXC interrupt */
198 ISR(USART_RX_vect) 187 ISR(USART_RX_vect)
199 { 188 {
200 uint8_t d, n, i; 189 uint8_t d, n, i;
201   190  
Line 270... Line 259...
270 c = pgm_read_byte(str2++); 259 c = pgm_read_byte(str2++);
271 } while (c && c == *str1++); 260 } while (c && c == *str1++);
272 return c; 261 return c;
273 } 262 }
274   263  
275   -  
276   -  
277 /* Initialize GPS module (depends on each product) */ -  
278 static -  
279 void gp_init (void) -  
280 { -  
281 const prog_char *s = -  
282 PSTR("$PSRF106,21*0F\r\n"); // Select datum of WGS84 (for EM-406A) -  
283 char c; -  
284   -  
285 while ((c = pgm_read_byte(s++)) != 0) uart_put(c); -  
286 } -  
287   -  
288   -  
289   -  
290 /* Get a column item */ 264 /* Get a column item */
291 static 265 static
292 BYTE* gp_col ( /* Returns pointer to the item (returns a NULL when not found) */ 266 BYTE* gp_col ( /* Returns pointer to the item (returns a NULL when not found) */
293 const BYTE* buf, /* Pointer to the sentence */ 267 const BYTE* buf, /* Pointer to the sentence */
294 BYTE col /* Column number (0 is the 1st item) */ 268 BYTE col /* Column number (0 is the 1st item) */
Line 363... Line 337...
363 if ((Stat & 1) || (disk_status(0) & STA_NODISK)) Timer = 255; 337 if ((Stat & 1) || (disk_status(0) & STA_NODISK)) Timer = 255;
364 } while (Timer); 338 } while (Timer);
365   339  
366 beep(5, 1); // Single beep. Start to get current time. 340 beep(5, 1); // Single beep. Start to get current time.
367 uart_init(); 341 uart_init();
368 gp_init(); // Initialize GPS module to let output data in NMEA-0183 format. -  
369 do { // Wait for valid RMC sentence. 342 do { // Wait for valid RMC sentence.
370 b = get_line(); 343 b = get_line();
371 if (!b) break; 344 if (!b) break;
372 if (gp_comp(Buff, PSTR("$GPRMC"))) continue; 345 if (gp_comp(Buff, PSTR("$GPRMC"))) continue;
373 p = gp_col(Buff,2); 346 p = gp_col(Buff,2);
Line 394... Line 367...
394 // || !gp_comp(Buff, PSTR("$GPZDA")) 367 // || !gp_comp(Buff, PSTR("$GPZDA"))
395 // || !gp_comp(Buff, PSTR("$GPVTG")) 368 // || !gp_comp(Buff, PSTR("$GPVTG"))
396 ) 369 )
397 { 370 {
398 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; }; 371 if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; };
399 itoa(battery,&Value1,10); 372 /* itoa(battery,&Value1,10); // convert binary number to character
400 itoa(intensity,&Value2,10); 373 itoa(intensity,&Value2,10);
401 strcpy(&Buff[0], Value1); 374 strcpy(&Buff[0], Value1);
402 strcpy_P(&Buff[4], PSTR(",")); 375 strcpy_P(&Buff[4], PSTR(","));
403 strcpy(&Buff[5], Value2); 376 strcpy(&Buff[5], Value2);
404 strcpy_P(&Buff[9], PSTR("\r\n")); 377 strcpy_P(&Buff[9], PSTR("\r\n"));
405 if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 5; break; }; 378 if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 8; break; };
406 } 379 */ }
407 if ((Stat & 4) == 0) continue; 380 if ((Stat & 4) == 0) continue;
408 if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec. 381 if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec.
409 cli(); Stat &= 0xFB; sei(); // Clear sync request 382 cli(); Stat &= 0xFB; sei(); // Clear sync request
410 } 383 }
411 if (err) break; 384 if (err) break;