diff --git a/Filter/Filter_FIR.c b/Filter/Filter_FIR.c index 14136f6..29c7f38 100644 --- a/Filter/Filter_FIR.c +++ b/Filter/Filter_FIR.c @@ -16,7 +16,7 @@ // ##### function ##### -void Filter_AV_8_init (struct FIR_AV_8 *Data) { +void Filter_AV_8_init (FIR_AV_8 *Data) { uint_fast8_t i; for (i = 0; i < 8; i++) { @@ -28,7 +28,7 @@ void Filter_AV_8_init (struct FIR_AV_8 *Data) { } } -void Filter_AV_8(struct FIR_AV_8 *Data, uint_fast16_t *Sample) { +void Filter_AV_8(FIR_AV_8 *Data, uint_fast16_t *Sample) { //Lösche Ältesten Eintrag aus der Liste und Positioniere dort den Neuesten Data->total -= Data->Samples[Data->pointer]; Data->total += *Sample; diff --git a/Filter/Filter_FIR.h b/Filter/Filter_FIR.h index ed7e64d..99a6873 100644 --- a/Filter/Filter_FIR.h +++ b/Filter/Filter_FIR.h @@ -1,5 +1,9 @@ +#ifndef FILTER_FIR_H +#define FILTER_FIR_H + // ##### Including ##### -#include +//#include +#include "../../../global.h" /** Inspired by stevenvh (https://electronics.stackexchange.com/users/2064/stevenvh) Post https://electronics.stackexchange.com/questions/42734/fastest-moving-averaging-techniques-with-minimum-footprint */ @@ -10,13 +14,13 @@ // ##### definition ##### /** Average over 8 16bit. */ -struct FIR_AV_8{ +typedef struct { uint_fast16_t Samples[8]; /**< Speicher der Messwerte. */ uint_fast16_t average; /**< Mittelwert aus den Samples. */ uint_fast32_t total; /**< Sammples aufsummiert. */ uint_fast8_t pointer; /**< Zeigt auf den Aeltesten Sampel Eintrag. */ unsigned erg_nvalid : 1; /**< 0 Wenn das erste Mall alle sampels in den Speicher eingelesn wurde und den average Ergebnissen vertraut werden kann. */ -}; +} FIR_AV_8; // ##### Status definition ##### @@ -27,9 +31,11 @@ struct FIR_AV_8{ // ##### function ##### -void Filter_AV_8_init (struct FIR_AV_8 *Data); +void Filter_AV_8_init (FIR_AV_8 *Data); /** FIR Filter Average over 8 16bit. * param[in] Data Filter Speicher Struktur. * param[in] Sample Neuer Messwert der Verechnet werden muss */ -void Filter_AV_8 (struct FIR_AV_8 *Data, uint_fast16_t *Sample); +void Filter_AV_8 (FIR_AV_8 *Data, uint_fast16_t *Sample); + +#endif /* FILTER_FIR_H */ \ No newline at end of file