X-Git-Url: https://robinkrens.nl/gitweb/?p=lra-as-sensor;a=blobdiff_plain;f=hbc.c;fp=hbc.c;h=30a17691cd17de494746474734a6df387d38a9d8;hp=38332a180a64a9eec360a56d3f095eb79d50dbd8;hb=5fcb373521bd82b6689cf119587905850a67b8fe;hpb=f99860f16348c1622450bb81db26a14ceb795a87 diff --git a/hbc.c b/hbc.c index 38332a1..30a1769 100644 --- a/hbc.c +++ b/hbc.c @@ -7,12 +7,12 @@ #include #include #include -#include "haptic.h" ISR(SIG_COMPARATOR) { if (ACSR & (1 << ACO)) { PORTB |= (1 << PB4); + /* turn of comparator on detection */ ACSR &= ~(1 << ACIE); } else { PORTB &= ~(1 << PB4); @@ -31,9 +31,6 @@ static void init_board(void) { power_adc_disable(); wdt_disable(); - /* enable interal reference for - * comparator - * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */ } static void set_ref_voltage(void) @@ -52,11 +49,14 @@ static void config_comparator(void) ADCSRA = 0; ADCSRB |= (1 << ACME); /* multiplex enable */ - //ADMUX |= (1 << MUX0); /* ADC1 as negative input */ + /* Use admux to set alternative negative pin */ + //ADMUX |= (1 << MUX0); + /* enable interal reference for + * comparator + * When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR). */ ACSR &= ~(1 << ACD); /* enable comparator */ ACSR |= (1 << ACBG); - //ACSR |= (1 << ACIS1) | (1 << ACIS0); DIDR0 |= (1 << AIN1D) | (1 << AIN0D); @@ -68,10 +68,8 @@ int main(void) init_board(); DDRB |= (1 << DDB4); - //PORTB |= (1 << PB1); cli(); - //set_ref_voltage(); config_comparator(); sei(); switch_idle();