Mercurial > templog
comparison main.c @ 315:7d409dded901
Import ds18x20 code
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 18 May 2012 23:57:08 +0800 |
parents | 7aebb1452422 |
children | 1bfe28c348dd |
comparison
equal
deleted
inserted
replaced
314:7aebb1452422 | 315:7d409dded901 |
---|---|
12 #include <util/delay.h> | 12 #include <util/delay.h> |
13 #include <avr/pgmspace.h> | 13 #include <avr/pgmspace.h> |
14 #include <util/crc16.h> | 14 #include <util/crc16.h> |
15 | 15 |
16 #include "integer.h" | 16 #include "integer.h" |
17 #include "onewire.h" | |
17 | 18 |
18 // configuration params | 19 // configuration params |
19 // - measurement interval | 20 // - measurement interval |
20 // - transmit interval | 21 // - transmit interval |
21 // - bluetooth params | 22 // - bluetooth params |
184 if (comms_count == COMMS_WAKE) | 185 if (comms_count == COMMS_WAKE) |
185 { | 186 { |
186 comms_count = 0; | 187 comms_count = 0; |
187 need_comms = 1; | 188 need_comms = 1; |
188 } | 189 } |
189 | |
190 PORT_LED ^= _BV(PIN_LED); | |
191 } | 190 } |
192 | 191 |
193 DWORD get_fattime (void) | 192 DWORD get_fattime (void) |
194 { | 193 { |
195 return 0; | 194 return 0; |
311 | 310 |
312 static void | 311 static void |
313 blink() | 312 blink() |
314 { | 313 { |
315 PORT_LED &= ~_BV(PIN_LED); | 314 PORT_LED &= ~_BV(PIN_LED); |
316 _delay_ms(100); | 315 _delay_ms(1); |
317 PORT_LED |= _BV(PIN_LED); | 316 PORT_LED |= _BV(PIN_LED); |
318 } | 317 } |
319 | 318 |
320 static void | 319 static void |
321 long_delay(int ms) | 320 long_delay(int ms) |
332 { | 331 { |
333 uart_on(); | 332 uart_on(); |
334 printf_P(PSTR("Bad interrupt\n")); | 333 printf_P(PSTR("Bad interrupt\n")); |
335 } | 334 } |
336 | 335 |
336 static void | |
337 set_2mhz() | |
338 { | |
339 cli(); | |
340 CLKPR = _BV(CLKPCE); | |
341 // divide by 4 | |
342 CLKPR = _BV(CLKPS1); | |
343 sei(); | |
344 } | |
345 | |
346 static void | |
347 test1wire() | |
348 { | |
349 ow_reset(); | |
350 } | |
351 | |
337 int main(void) | 352 int main(void) |
338 { | 353 { |
354 set_2mhz(); | |
355 | |
339 DDR_LED |= _BV(PIN_LED); | 356 DDR_LED |= _BV(PIN_LED); |
340 blink(); | 357 blink(); |
341 | 358 |
342 stdout = &mystdout; | 359 stdout = &mystdout; |
343 uart_on(); | 360 uart_on(); |
374 { | 391 { |
375 do_comms() | 392 do_comms() |
376 } | 393 } |
377 #else | 394 #else |
378 for(;;){ | 395 for(;;){ |
396 | |
397 test1wire(); | |
398 | |
379 /* insert your main loop code here */ | 399 /* insert your main loop code here */ |
380 if (need_measurement) | 400 if (need_measurement) |
381 { | 401 { |
382 do_measurement(); | 402 do_measurement(); |
383 continue; | 403 continue; |
388 do_comms(); | 408 do_comms(); |
389 continue; | 409 continue; |
390 } | 410 } |
391 | 411 |
392 deep_sleep(); | 412 deep_sleep(); |
413 blink(); | |
393 } | 414 } |
394 #endif | 415 #endif |
395 return 0; /* never reached */ | 416 return 0; /* never reached */ |
396 } | 417 } |