Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Filter/Filter_FIR.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions Filter/Filter_FIR.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef FILTER_FIR_H
#define FILTER_FIR_H

// ##### Including #####
#include <stdint.h>
//#include <stdint.h>
#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 */

Expand All @@ -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 #####
Expand All @@ -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 */