Rev 1220 Rev 1361
Line 1... Line 1...
1 /* mija 2008 1 /* mija 2008
2 demo for LCD NOKIA5110 and MCP9800 and GPS modul 2 demo for LCD NOKIA5110 and MCP9800 and GPS modul
3   3  
4 CPU ATMEGA644P 4 CPU ATMEGA644P
5 fcpu = 1MHz 5 fcpu = 7372800
6   6  
7 !! define PIN,PORT,DDR for IOpin !! 7 !! define PIN,PORT,DDR for IOpin !!
8 */ 8 */
9   9  
10   10  
11 //************************************************************************ 11 //************************************************************************
12 // defines 12 // defines
13   13  
-   14 #define POINTNAME " DOMOV"
14 #define MY_LAT 48*60+57.7647 15 #define MY_LAT 48*60+57.7647
15 #define MY_LON 14*60+28.0836 16 #define MY_LON 14*60+28.0836
16   17  
-   18 /*
-   19 // 50°7'38.768"N, 13°32'43.132"E
-   20 #define POINTNAME " ORACOV"
-   21 #define MY_LAT 50*60+7.64613
-   22 #define MY_LON 13*60+32.7189
-   23 */
-   24 /*
-   25 // 50°7'38.768"N, 13°32'43.132"E
-   26 #define POINTNAME " ZAMEK"
-   27 #define MY_LAT 50*60+6.191
-   28 #define MY_LON 13*60+32.118
-   29 */
-   30  
17 #define KEY_TIME_DEAD 5 //cca 50ms 8*5 31 #define KEY_TIME_DEAD 5 //cca 50ms 8*5
18 //#define KEY_TIME_START_REPEAT 100 //cca 1s 32 //#define KEY_TIME_START_REPEAT 100 //cca 1s
19 //#define KEY_TIME_REPEAT 20 //cca 240ms 33 //#define KEY_TIME_REPEAT 20 //cca 240ms
20 #define KEY_TIME_FIRST 50 34 #define KEY_TIME_FIRST 50
21   35  
Line 31... Line 45...
31 #define CLOCK1S 100 45 #define CLOCK1S 100
32 #define CLOCK2S 200 46 #define CLOCK2S 200
33 #define CLOCK5S 255; 47 #define CLOCK5S 255;
34 #define CLOCK50MS 5 48 #define CLOCK50MS 5
35   49  
36 #define DEBUG 50 //#define DEBUG
37   51  
38 //************************************************************************ 52 //************************************************************************
39 //including 53 //including
40   54  
41 #include <avr/io.h> 55 #include <avr/io.h>
Line 165... Line 179...
165 UBRR0 = 95; 179 UBRR0 = 95;
166 //UCSR0A = 180 //UCSR0A =
167 UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0); 181 UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0);
168   182  
169 //*** USART1 *** RX PD2, TX PD3 PC 183 //*** USART1 *** RX PD2, TX PD3 PC
-   184 DDRD |= _BV(PD3);
-   185 PORTD &= (~(_BV(PD3)));
-   186  
170 #ifndef DEBUG 187 #ifndef DEBUG
171 UBRR1 = 95; 188 UBRR1 = 95;
172 #else 189 #else
173 UBRR1 = 3; 190 UBRR1 = 3;
174 #endif 191 #endif
175 //UCSR0A = 192 //UCSR0A =
176 UCSR1B = _BV(RXCIE1) | _BV(RXEN0) | _BV(TXEN1); 193 UCSR1B = _BV(RXCIE1) | _BV(RXEN1) | _BV(TXEN1);
177   194  
178 //*** ADC *** 195 //*** ADC ***
179 ADMUX = _BV(REFS1) | _BV(MUX0); 196 ADMUX = _BV(REFS1) | _BV(MUX0);
180 ADCSRA = _BV(ADPS1) | _BV(ADPS2); 197 ADCSRA = _BV(ADPS1) | _BV(ADPS2);
181   198  
Line 253... Line 270...
253   270  
254 uint8_t first_char_usart1 = 0; 271 uint8_t first_char_usart1 = 0;
255   272  
256 ISR(USART1_RX_vect) 273 ISR(USART1_RX_vect)
257 { 274 {
-   275  
258 #ifndef DEBUG 276 #ifndef DEBUG
259 UDR0 = UDR1; 277 UDR0 = UDR1;
260 #else 278 #else
261 if (TL1_INPUT && TL3_INPUT) BOOT(); 279 if (TL1_INPUT && TL3_INPUT) BOOT();
262 //bootloader(); 280 //bootloader();
Line 268... Line 286...
268 if ((!TL3_INPUT) && (!TL1_INPUT)) RESET(); 286 if ((!TL3_INPUT) && (!TL1_INPUT)) RESET();
269 } 287 }
270   288  
271 ISR(PCINT3_vect) 289 ISR(PCINT3_vect)
272 { 290 {
-   291 if (USB_PIN) USART_PC_ON;
-   292 else USART_PC_OFF;
273 if (!TL2_INPUT && USB_INPUT) 293 if (!TL2_INPUT && USB_INPUT)
274 { 294 {
275 cli(); 295 cli();
276 buffer_clr(); 296 buffer_clr();
277 gotoxy(2,3); 297 gotoxy(2,3);
Line 283... Line 303...
283 BOOT(); 303 BOOT();
284 } 304 }
285 305
286 } 306 }
287   307  
288 EMPTY_INTERRUPT(INT0_vect) 308 //EMPTY_INTERRUPT(INT0_vect)
289 EMPTY_INTERRUPT(INT2_vect) 309 //EMPTY_INTERRUPT(INT2_vect)
290 EMPTY_INTERRUPT(WDT_vect) 310 //EMPTY_INTERRUPT(WDT_vect)
291   311  
292 //************************************************************************ 312 //************************************************************************
293 // delay_ms functions /define fcpu / 313 // delay_ms functions /define fcpu /
294   314  
295 void delay_ms(uint16_t time) 315 void delay_ms(uint16_t time)
Line 883... Line 903...
883   903  
884 //gotoxy(10,3); 904 //gotoxy(10,3);
885 printf("%4.0fm",gps.altitude); 905 printf("%4.0fm",gps.altitude);
886   906  
887 gotoxy(7,2); 907 gotoxy(7,2);
888 printf("go home"); 908 printf(POINTNAME);
889 909
890 gotoxy(9,4); 910 gotoxy(9,4);
891 if (temp < 10000) 911 if (temp < 10000)
892 { 912 {
893 if (temp<1000) fprintf(&mystdout2,"%.1f ",temp); 913 if (temp<1000) fprintf(&mystdout2,"%.1f ",temp);
Line 1196... Line 1216...
1196 fprintf(&mystdout2,"OFF"); 1216 fprintf(&mystdout2,"OFF");
1197 lcd_refresh(); 1217 lcd_refresh();
1198 GPS_OFF; 1218 GPS_OFF;
1199 REF_OFF; 1219 REF_OFF;
1200 ADC_OFF; 1220 ADC_OFF;
-   1221 USART_PC_OFF;
1201 delay_ms(1000); 1222 delay_ms(1000);
1202 LED_OFF; 1223 LED_OFF;
1203 N5110_send_command(POWER_DOWN); 1224 N5110_send_command(POWER_DOWN);
1204 1225
1205 temp_wiev = 0; 1226 temp_wiev = 0;
Line 1220... Line 1241...
1220 } 1241 }
1221 if (!TL3_INPUT) {N5110_send_command(POWER_DOWN);temp_wiev = 0;} 1242 if (!TL3_INPUT) {N5110_send_command(POWER_DOWN);temp_wiev = 0;}
1222 if (temp_wiev) temp(); 1243 if (temp_wiev) temp();
1223   1244  
1224 } 1245 }
-   1246  
-   1247 if (USB_PIN) USART_PC_ON;
-   1248 else USART_PC_OFF;
-   1249  
1225 null_variables(); 1250 null_variables();
1226 LCD_N5110_INIT(); 1251 LCD_N5110_INIT();
1227 displ_start(); 1252 displ_start();
1228 } 1253 }
1229   1254  
Line 1322... Line 1347...
1322 general_cpu_init(); 1347 general_cpu_init();
1323 //GPS_ON; 1348 //GPS_ON;
1324 LCD_N5110_INIT(); 1349 LCD_N5110_INIT();
1325   1350  
1326 //set_static_navigation(0); 1351 //set_static_navigation(0);
-   1352 if (USB_PIN) USART_PC_ON;
1327 1353 else USART_PC_OFF;
1328 stdout = &mystdout; 1354 stdout = &mystdout;
1329 sei(); 1355 sei();
1330 1356
1331 for (;;) 1357 for (;;)
1332 { 1358 {