Mercurial > templog
diff main.c @ 9:7da9a3f23592
Import ds18x20 code
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 18 May 2012 23:57:08 +0800 |
parents | c55321727d02 |
children | 1bfe28c348dd |
line wrap: on
line diff
--- a/main.c Fri May 18 20:38:40 2012 +0800 +++ b/main.c Fri May 18 23:57:08 2012 +0800 @@ -14,6 +14,7 @@ #include <util/crc16.h> #include "integer.h" +#include "onewire.h" // configuration params // - measurement interval @@ -186,8 +187,6 @@ comms_count = 0; need_comms = 1; } - - PORT_LED ^= _BV(PIN_LED); } DWORD get_fattime (void) @@ -313,7 +312,7 @@ blink() { PORT_LED &= ~_BV(PIN_LED); - _delay_ms(100); + _delay_ms(1); PORT_LED |= _BV(PIN_LED); } @@ -334,8 +333,26 @@ printf_P(PSTR("Bad interrupt\n")); } +static void +set_2mhz() +{ + cli(); + CLKPR = _BV(CLKPCE); + // divide by 4 + CLKPR = _BV(CLKPS1); + sei(); +} + +static void +test1wire() +{ + ow_reset(); +} + int main(void) { + set_2mhz(); + DDR_LED |= _BV(PIN_LED); blink(); @@ -376,6 +393,9 @@ } #else for(;;){ + + test1wire(); + /* insert your main loop code here */ if (need_measurement) { @@ -390,6 +410,7 @@ } deep_sleep(); + blink(); } #endif return 0; /* never reached */