| Line 15... |
Line 15... |
| 15 |
#define BEEP_ON() TCCR0B=0b011 |
15 |
#define BEEP_ON() TCCR0B=0b011 |
| 16 |
#define BEEP_OFF() TCCR0B=0b000 |
16 |
#define BEEP_OFF() TCCR0B=0b000 |
| 17 |
#define GPS_ON() PORTB|=0x02 |
17 |
#define GPS_ON() PORTB|=0x02 |
| 18 |
#define GPS_OFF() PORTB&=0xFD |
18 |
#define GPS_OFF() PORTB&=0xFD |
| 19 |
#define DELAY(dly) for(Timer=dly;Timer;) |
19 |
#define DELAY(dly) for(Timer=dly;Timer;) |
| - |
|
20 |
|
| - |
|
21 |
#define GPS_BAUDRATE 9600 // Enable USRAT0 in N81,9600bps |
| 20 |
|
22 |
|
| 21 |
#define VTH_LOW (WORD)(8000UL*100/3838) |
23 |
#define VTH_LOW (WORD)(8000UL*100/3838) |
| 22 |
#define VTH_HIGH (WORD)(11500UL*100/3838) |
24 |
#define VTH_HIGH (WORD)(11500UL*100/3838) |
| 23 |
#define POWER_check 0b01000000 | 1 |
25 |
#define POWER_check 0b01000000 | 1 |
| 24 |
#define ANALOG_IN1 0b01000000 | 2 |
26 |
#define ANALOG_IN1 0b01000000 | 2 |
| Line 148... |
Line 150... |
| 148 |
cli(); |
150 |
cli(); |
| 149 |
UCSR0B = 0; |
151 |
UCSR0B = 0; |
| 150 |
rxfifo.idx_r = 0; |
152 |
rxfifo.idx_r = 0; |
| 151 |
rxfifo.idx_w = 0; |
153 |
rxfifo.idx_w = 0; |
| 152 |
rxfifo.count = 0; |
154 |
rxfifo.count = 0; |
| 153 |
UBRR0L = SYSCLK/16/9600; // Enable USRAT0 in N81,4800bps |
155 |
UBRR0L = SYSCLK/16/GPS_BAUDRATE; |
| 154 |
UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0); |
156 |
UCSR0B = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0); |
| 155 |
Stat &= 0xFD; // Clear overflow flag |
157 |
Stat &= 0xFD; // Clear overflow flag |
| 156 |
sei(); |
158 |
sei(); |
| 157 |
} |
159 |
} |
| 158 |
|
160 |
|
| Line 216... |
Line 218... |
| 216 |
|
218 |
|
| 217 |
|
219 |
|
| 218 |
for (;;) { |
220 |
for (;;) { |
| 219 |
if (Stat & 1) return 0; // When power fail is detected, return with zero. |
221 |
if (Stat & 1) return 0; // When power fail is detected, return with zero. |
| 220 |
c = uart_get(); |
222 |
c = uart_get(); |
| 221 |
if (Stat & 2) { // When buffer overflow has occured, restert to receive line. |
223 |
if (Stat & 2) { // When buffer overflow has occured, restart to receive line. |
| 222 |
uart_init(); |
224 |
uart_init(); |
| 223 |
i = 0; c = 0; |
225 |
i = 0; c = 0; |
| 224 |
} |
226 |
} |
| 225 |
if (!c || (i == 0 && c != '$')) continue; |
227 |
if (!c || (i == 0 && c != '$')) continue; |
| 226 |
Buff[i++] = c; |
228 |
Buff[i++] = c; |
| Line 367... |
Line 369... |
| 367 |
// || !gp_comp(Buff, PSTR("$GPZDA")) |
369 |
// || !gp_comp(Buff, PSTR("$GPZDA")) |
| 368 |
// || !gp_comp(Buff, PSTR("$GPVTG")) |
370 |
// || !gp_comp(Buff, PSTR("$GPVTG")) |
| 369 |
) |
371 |
) |
| 370 |
{ |
372 |
{ |
| 371 |
if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; }; |
373 |
if (f_write(&file1, Buff, b, &s) || b != s) { err = 5; break; }; |
| 372 |
/* itoa(battery,&Value1,10); // convert binary number to character |
374 |
itoa(battery,&Value1,10); // convert number to character |
| 373 |
itoa(intensity,&Value2,10); |
375 |
itoa(intensity,&Value2,10); |
| 374 |
strcpy(&Buff[0], Value1); |
- |
|
| 375 |
strcpy_P(&Buff[4], PSTR(",")); |
- |
|
| 376 |
strcpy(&Buff[5], Value2); |
376 |
sprintf(Buff,"%d,%d\n",Value1,Value2); |
| 377 |
strcpy_P(&Buff[9], PSTR("\r\n")); |
- |
|
| 378 |
if (f_write(&file1, Buff, 11, &s) || 11 != s) { err = 8; break; }; |
377 |
if (f_write(&file1, Buff,strlen(Buff), &s) || (strlen(Buff) != s)) { err = 8; break; }; |
| 379 |
*/ } |
378 |
} |
| 380 |
if ((Stat & 4) == 0) continue; |
379 |
if ((Stat & 4) == 0) continue; |
| 381 |
if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec. |
380 |
if (f_sync(&file1)) { err = 6; break; };// Synchronize the file in interval of 300 sec. |
| 382 |
cli(); Stat &= 0xFB; sei(); // Clear sync request |
381 |
cli(); Stat &= 0xFB; sei(); // Clear sync request |
| 383 |
} |
382 |
} |
| 384 |
if (err) break; |
383 |
if (err) break; |