1 /* $Id: time.c,v 1.2 2009/03/16 20:32:23 simimeie Exp $
2 * USB interface for ds1820
3 * This file provides time functions.
4 * (C) Michael "Fox" Meier 2009
7 #include <avr/interrupt.h>
10 static volatile uint32_t curts[2] = { 0, 0 };
11 static volatile uint8_t actts = 0;
13 void time_init(void) {
14 /* Set timer0 to run with CLK/1024. That gives 57.2 Overflow interrupts
15 * per second at 15 MHz. */
16 TCCR0B |= _BV(2) | _BV(0);
17 /* Enable timer interrupts */
21 /* ISR(TIM1_OVF_vect, ISR_NOBLOCK) doesn't work in the goddamn stoneage ubuntu version */
24 sei(); /* Workaround, should use ISR_NOBLOCK instead */
26 uint8_t nextts = (~actts) & 0x01;
32 uint32_t gettime(void)