8 #include <avr/interrupt.h>
9 #include <util/delay.h>
14 if (ACSR & (1 << ACO)) {
22 EMPTY_INTERRUPT(TIM0_COMPA_vect);
24 static void switch_idle(void)
26 set_sleep_mode(SLEEP_MODE_IDLE);
30 static void init_board(void)
34 /* enable interal reference for
36 * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */
39 static void set_ref_voltage(void)
41 DDRB |= (1 << DDB1); /* set PB0 as output */
43 TCCR0A |= (1 << WGM01) | (1 << WGM00) | (1 << COM0B1);
44 TCCR0B |= (1 << CS00); /* clk/1024 prescaler */
45 OCR0B = 0x20; /* 25% duty cycle */
47 TIMSK = (1 << OCIE0B); /* enable interrupts for overflow and compare */
50 static void config_comparator(void)
53 ADCSRB |= (1 << ACME); /* multiplex enable */
55 //ADMUX |= (1 << MUX0); /* ADC1 as negative input */
57 ACSR &= ~(1 << ACD); /* enable comparator */
59 //ACSR |= (1 << ACIS1) | (1 << ACIS0);
61 DIDR0 |= (1 << AIN1D) | (1 << AIN0D);
63 ACSR |= (1 << ACIE); /* enable interrupts */
71 //PORTB |= (1 << PB1);