X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=projects%2Fstep-up%2Fadc.c;h=ea309357a429ad988b26960e3e1c381bda7248a9;hp=b8c253e24af5f84eba25e4334df7afcbddaec372;hb=fbbdcc41a590e41e87a05d3cac31f893cb52f8cb;hpb=ffb4982594d98b8d8ecd9efcfe37c17e0f2fc53b diff --git a/projects/step-up/adc.c b/projects/step-up/adc.c index b8c253e..ea30935 100644 --- a/projects/step-up/adc.c +++ b/projects/step-up/adc.c @@ -11,7 +11,7 @@ #define NUM_ADCS 2 volatile static unsigned char current_adc;; -static unsigned char need_battery_adc; +volatile unsigned char need_battery_adc; static uint16_t adc_sum, read_zero, drop_count, read_count, n_reads_log; volatile uint16_t jiffies; @@ -120,45 +120,15 @@ void init_adc() start_next_adc(); } -#if 0 void susp_adc() { ADCSRA = 0; DIDR0 = 0; } -static void adc1_gain20_adc(uint16_t adcsum) -{ - // running average - adc1_gain20_offset += adcsum - - (adc1_gain20_offset >> ADC1_GAIN20_OFFSET_SHIFT); -} -#endif - -static void inline adc_based_timer() -{ - static unsigned char count; - - if (++count < 40) // about 100 Hz jiffies - return; - - count = 0; - ++jiffies; - - if ((jiffies & 0x007F) == 1) { // about every 1s - need_battery_adc = 1; - } - if ((jiffies & 0x0007) == 0) { - patterns_next_tick(); - } - timer_check_buttons(); -} - ISR(ADC_vect) { // IRQ handler uint16_t adcval = ADCW; - adc_based_timer(); - if (read_zero) { setup_mux(current_adc); read_zero = 0;