From 26ac421d404100446fc2d8715abda128e5b15368 Mon Sep 17 00:00:00 2001 From: vuko Date: Tue, 20 Mar 2018 10:45:12 +0100 Subject: [PATCH] delete old cse7759 counter code --- soft/src/freq_counter.c | 43 ----------------------------------------- soft/src/freq_counter.h | 42 ---------------------------------------- 2 files changed, 85 deletions(-) delete mode 100644 soft/src/freq_counter.c delete mode 100644 soft/src/freq_counter.h diff --git a/soft/src/freq_counter.c b/soft/src/freq_counter.c deleted file mode 100644 index 0351ea1..0000000 --- a/soft/src/freq_counter.c +++ /dev/null @@ -1,43 +0,0 @@ -#include - -void freq_counter_init ( struct freq_counter *f, uint32_t cycle_len ) { - f->input_initialized = false; - f->input_state = false; - - f->counter = 0; - f->samples = 0; - f->cycle_len = cycle_len; - - f->new_measurement = false; - f->measurement = 0; -} - -void IRAM_ATTR freq_counter_update ( struct freq_counter *f, bool input ) { - if ( f->input_initialized == false ) { - // ignore first input value - f->input_state = input; - f->input_initialized = true; - } - if ( f->input_state != input) { - f->counter += 1; - f->input_state = input; - } - f->samples += 1; - if ( f->samples >= f->cycle_len ) { - /* cycle complete */ - f->measurement = f->counter; - f->new_measurement = true; - f->samples = 0; - f->counter = 0; - } -} - -bool freq_counter_get_measurement( struct freq_counter *f, uint32_t *measurement) { - if ( f->new_measurement == true ) { - *measurement = f->measurement; - f->new_measurement = false; - return true; - } else { - return false; - } -} diff --git a/soft/src/freq_counter.h b/soft/src/freq_counter.h deleted file mode 100644 index f0b1473..0000000 --- a/soft/src/freq_counter.h +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#ifndef FREQ_COUNTER_H -#define FREQ_COUNTER_H - -#ifndef IRAM_ATTR - #define IRAM_ATTR __attribute__((section(".iram.text"))) -#endif - -struct freq_counter { - bool input_initialized; /* false before first update call */ - bool input_state; /* last update input state */ - - uint32_t counter; /* input state changes counter */ - uint32_t samples; /* input samples counter */ - uint32_t cycle_len; /* number of samples in one cycle */ - - bool new_measurement; /* set to true after updating measurement */ - uint32_t measurement; /* number of state changes in last complete cycle */ -}; - -/** - * @brief initialize frequency counter structure - * - * @param cycle_len number of samples in one measurement cycle - */ -void freq_counter_init ( struct freq_counter *f, uint32_t cycle_len ); -void IRAM_ATTR freq_counter_update ( struct freq_counter *f, bool input ); - - -/** - * @brief get new measurement from freq_counter - * - * this function should be called at least twice per cycle in order to avoid - * concurrent rw acces to measurement variable - * @param measurement is set to new measurement value if returned true - * @return true if new measurement is available - */ -bool freq_counter_get_measurement( struct freq_counter *f, uint32_t *measurement); - -#endif /* end of include guard: FREQ_COUNTER_H */