static unsigned char adc_mux[] = { // pwmleds should be first
// 0: pwmled 0: 1.1V, ADC3 (PA4), single-ended
_BV(REFS1) | _BV(MUX1) | _BV(MUX0),
static unsigned char adc_mux[] = { // pwmleds should be first
// 0: pwmled 0: 1.1V, ADC3 (PA4), single-ended
_BV(REFS1) | _BV(MUX1) | _BV(MUX0),
-#define LAST_ADC (sizeof(adc_mux)/sizeof(char))
-volatile static unsigned char current_adc = LAST_ADC;
+#define LAST_ADC (sizeof(adc_mux)/sizeof(adc_mux[0]))
+volatile static unsigned char current_adc;
+static unsigned char adc_ignore;
found:
// ADCSRB |= _BV(GSEL); // gain 8 or 32
ADMUX = adc_mux[current_adc]; // set up mux, start one-shot conversion
found:
// ADCSRB |= _BV(GSEL); // gain 8 or 32
ADMUX = adc_mux[current_adc]; // set up mux, start one-shot conversion
ADCSRA = _BV(ADEN) // enable
| _BV(ADPS1) | _BV(ADPS0) // CLK/8 = 125 kHz
// | _BV(ADPS2) // CLK/16 = 62.5 kHz
ADCSRA = _BV(ADEN) // enable
| _BV(ADPS1) | _BV(ADPS0) // CLK/8 = 125 kHz
// | _BV(ADPS2) // CLK/16 = 62.5 kHz
if (current_adc < N_PWMLEDS)
pwmled_adc(current_adc, adcval);
if (current_adc == AMBIENT_ADC)
if (current_adc < N_PWMLEDS)
pwmled_adc(current_adc, adcval);
if (current_adc == AMBIENT_ADC)