From 500478f9e0e03686dccde2fbbe7522593ba5cce5 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 27 Feb 2013 22:49:42 +0100 Subject: [PATCH] Revert "adc.c: make the ADC handlers non-atomic" This reverts commit eb2f91ea7806fd8f5b9a5597fcf5c13855911d71. We will probably not need non-atomic handlers. --- firmware/adc.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/firmware/adc.c b/firmware/adc.c index 9155f32..6ef638a 100644 --- a/firmware/adc.c +++ b/firmware/adc.c @@ -1,6 +1,5 @@ #include #include -#include #include "lights.h" @@ -15,7 +14,6 @@ static unsigned char sum_shift; static unsigned char adc_vals; #define ADC1_GAIN20_OFFSET_SHIFT 6 static uint16_t adc1_gain20_offset; -static unsigned char handler_running; static void inline setup_mux(unsigned char n) { @@ -88,7 +86,6 @@ void init_adc() { unsigned char i; current_adc = NUM_ADCS; - handler_running = 0; ADCSRA = _BV(ADEN) // enable | _BV(ADPS1) | _BV(ADPS0) // CLK/8 = 125 kHz @@ -157,28 +154,13 @@ ISR(ADC_vect) { // IRQ handler adc_sum = 0; } - if (handler_running & (1 << current_adc)) { - log_byte(0xB0 + current_adc); - - // drop the result, what else to do? - - start_next_adc(); - } else { - unsigned char current_adc_copy = current_adc; - uint16_t adc_sum_copy = adc_sum; - - start_next_adc(); - - handler_running |= (1 << current_adc_copy); - NONATOMIC_BLOCK(NONATOMIC_FORCEOFF) { - if (current_adc_copy < N_PWMLEDS) - pwmled_adc(current_adc_copy, adc_sum_copy); - if (current_adc_copy == AMBIENT_ADC) - ambient_adc(adc_sum_copy); - if (current_adc_copy == BATTERY_ADC) - battery_adc(adc_sum_copy); - } - handler_running &= ~(1 << current_adc_copy); - } + if (current_adc < N_PWMLEDS) + pwmled_adc(current_adc, adc_sum); + if (current_adc == AMBIENT_ADC) + ambient_adc(adcval); + if (current_adc == BATTERY_ADC) + battery_adc(adcval); + + start_next_adc(); } -- 2.39.3