X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=firmware%2Fadc.c;h=123dddd4dee4f319c5f536ccd3a5e817ed77c433;hb=47e678a90062fa2dbc6cb8f9e5efc81072f5dcc5;hp=5252ae7edc1cc2b6554ebb8e2f9486221e19eeec;hpb=990989cb746d45fbd2ebf634c6e7c19ce0cfe2df;p=bike-lights.git diff --git a/firmware/adc.c b/firmware/adc.c index 5252ae7..123dddd 100644 --- a/firmware/adc.c +++ b/firmware/adc.c @@ -10,9 +10,7 @@ static unsigned char adc_mux[] = { // pwmleds should be first // 1: pwmled 2: 1.1V, ADC2,1 (PA2,1), gain 20 _BV(REFS1) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1), // 2: pwmled 3: 1.1V, ADC4 (PA5), single-ended - // _BV(REFS1) | _BV(MUX2), - // 2: for testing the same as 1 - _BV(REFS1) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1), + _BV(REFS1) | _BV(MUX2), // 3: ambient light: 1.1V, ADC5 (PA6), single-ended _BV(REFS1) | _BV(MUX2) | _BV(MUX0), // 4: batt voltage: 1.1V, ADC6 (PA7), single-ended @@ -74,6 +72,12 @@ void init_adc() ADCSRA |= _BV(ADIE); // enable IRQ } +void susp_adc() +{ + ADCSRA = 0; + DIDR0 = 0; +} + ISR(ADC_vect) { // IRQ handler uint16_t adcval = ADCW; @@ -93,7 +97,8 @@ ISR(ADC_vect) { // IRQ handler pwmled_adc(current_adc, adcval); if (current_adc == AMBIENT_ADC) ambient_adc(adcval); - // TODO battery sense, etc. + if (current_adc == BATTERY_ADC) + battery_adc(adcval); start_next_adc(); }