diff --git a/firmware/lib/bughal.c b/firmware/lib/bughal.c index ed6309e..a959499 100644 --- a/firmware/lib/bughal.c +++ b/firmware/lib/bughal.c @@ -58,12 +58,18 @@ void init_buzzr(void){ void init_mic(void){ - //its on B2 and C5, for reasons - // - DDRC |= (1 << PORTC5); - DDRB |= (1 << PORTB2); - //switch it off - buzzr_off(); + //buzzer is on B2 and C5, for reasons + // we use it as a mic + DDRC &= ~(1 << PORTC5); //switch C5 to input + DDRB |= (1 << PORTB2); //B2 as output + PORTB &= ~(1 << PORTB2);//and to GND + ADMUX = (1<0) {led_on(LED_R|LED_L);} else {led_off(LED_R|LED_L);}; maxval=0; - buzzr_inv(); - }; //end if timer_expired - maxval++; - + + }; //end if timer_expired + + // single measurement + ADMUX = (ADMUX & ~(0x1F)) | 5; // select channel 5 + ADCSRA |= (1<maxval) ? curval : maxval; + }; //end do_mode0 + + + + + + + + + + + + + + + void do_mode1(void){ static uint16_t tone; if (ModeChanged){