From c7654d28ae4cc6685a7900c3439bee994f941cf7 Mon Sep 17 00:00:00 2001 From: bkleiner Date: Fri, 11 Aug 2023 16:39:22 +0200 Subject: [PATCH] move filter functions to ram --- src/flight/filter.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/flight/filter.c b/src/flight/filter.c index 91e896eb6..b9bcaf73f 100644 --- a/src/flight/filter.c +++ b/src/flight/filter.c @@ -48,7 +48,7 @@ void filter_lp_pt1_init(filter_lp_pt1 *filter, filter_state_t *state, uint8_t co filter_init_state(state, count); } -void filter_lp_pt1_coeff(filter_lp_pt1 *filter, float hz) { +RAM_FUNC void filter_lp_pt1_coeff(filter_lp_pt1 *filter, float hz) { if (filter->hz == hz && filter->sample_period_us == state.looptime_autodetect) { return; } @@ -61,7 +61,7 @@ void filter_lp_pt1_coeff(filter_lp_pt1 *filter, float hz) { filter->alpha = sample_period / (rc + sample_period); } -float filter_lp_pt1_step(filter_lp_pt1 *filter, filter_state_t *state, float in) { +RAM_FUNC float filter_lp_pt1_step(filter_lp_pt1 *filter, filter_state_t *state, float in) { state->delay_element[0] = state->delay_element[0] + filter->alpha * (in - state->delay_element[0]); return state->delay_element[0]; } @@ -71,7 +71,7 @@ void filter_lp_pt2_init(filter_lp_pt2 *filter, filter_state_t *state, uint8_t co filter_init_state(state, count); } -void filter_lp_pt2_coeff(filter_lp_pt2 *filter, float hz) { +RAM_FUNC void filter_lp_pt2_coeff(filter_lp_pt2 *filter, float hz) { if (filter->hz == hz && filter->sample_period_us == state.looptime_autodetect) { return; } @@ -84,7 +84,7 @@ void filter_lp_pt2_coeff(filter_lp_pt2 *filter, float hz) { filter->alpha = sample_period / (rc + sample_period); } -float filter_lp_pt2_step(filter_lp_pt2 *filter, filter_state_t *state, float in) { +RAM_FUNC float filter_lp_pt2_step(filter_lp_pt2 *filter, filter_state_t *state, float in) { state->delay_element[1] = state->delay_element[1] + filter->alpha * (in - state->delay_element[1]); state->delay_element[0] = state->delay_element[0] + filter->alpha * (state->delay_element[1] - state->delay_element[0]); return state->delay_element[0]; @@ -95,7 +95,7 @@ void filter_lp_pt3_init(filter_lp_pt3 *filter, filter_state_t *state, uint8_t co filter_init_state(state, count); } -void filter_lp_pt3_coeff(filter_lp_pt3 *filter, float hz) { +RAM_FUNC void filter_lp_pt3_coeff(filter_lp_pt3 *filter, float hz) { if (filter->hz == hz && filter->sample_period_us == state.looptime_autodetect) { return; } @@ -108,7 +108,7 @@ void filter_lp_pt3_coeff(filter_lp_pt3 *filter, float hz) { filter->alpha = sample_period / (rc + sample_period); } -float filter_lp_pt3_step(filter_lp_pt3 *filter, filter_state_t *state, float in) { +RAM_FUNC float filter_lp_pt3_step(filter_lp_pt3 *filter, filter_state_t *state, float in) { state->delay_element[1] = state->delay_element[1] + filter->alpha * (in - state->delay_element[1]); state->delay_element[2] = state->delay_element[2] + filter->alpha * (state->delay_element[1] - state->delay_element[2]); state->delay_element[0] = state->delay_element[0] + filter->alpha * (state->delay_element[2] - state->delay_element[0]); @@ -173,7 +173,7 @@ void filter_init(filter_type_t type, filter_t *filter, filter_state_t *state, ui } } -void filter_coeff(filter_type_t type, filter_t *filter, float hz) { +RAM_FUNC void filter_coeff(filter_type_t type, filter_t *filter, float hz) { switch (type) { case FILTER_LP_PT1: filter_lp_pt1_coeff(&filter->lp_pt1, hz); @@ -190,7 +190,7 @@ void filter_coeff(filter_type_t type, filter_t *filter, float hz) { } } -float filter_step(filter_type_t type, filter_t *filter, filter_state_t *state, float in) { +RAM_FUNC float filter_step(filter_type_t type, filter_t *filter, filter_state_t *state, float in) { switch (type) { case FILTER_LP_PT1: return filter_lp_pt1_step(&filter->lp_pt1, state, in);