From 2619f3fccf52cc75c2e84ad8482763d063fcf165 Mon Sep 17 00:00:00 2001 From: Pranay Oza <105095960+pranay-o@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:31:46 -0800 Subject: [PATCH] fixed changes --- firmware/quintuna/RSM/io/io_coolants.c | 20 +++++++++++++------- firmware/quintuna/RSM/io/io_coolants.h | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/firmware/quintuna/RSM/io/io_coolants.c b/firmware/quintuna/RSM/io/io_coolants.c index b592342fb6..628e1c683f 100644 --- a/firmware/quintuna/RSM/io/io_coolants.c +++ b/firmware/quintuna/RSM/io/io_coolants.c @@ -44,22 +44,28 @@ // below are constants for Steinhart Hart EQN used to model temprature as a function of a resistor for a thermistor #define BTERM_STEIN_EQN(rtherm) ((float)log((float)(rtherm / R0)) / B_COEFFIECENT) -static const Coolant a(coolantpressure1_3v3); -static const Coolant b(coolantpressure2_3v3); +const Coolant a = {coolantpressure1_3v3}; +const Coolant b = {coolantpressure2_3v3}; -void io_coolant_init(void) +static PwmInputFreqOnly flow_meter; + +void io_coolant_init(const PwmInputFreqOnlyConfig *config) { - coolant_config.init(); + hw_pwmInputFreqOnly_init(&flow_meter, config); } -void io_coolant_inputCaptureCallback(void) +void io_coolant_inputCaptureCallback(TIM_HandleTypeDef *htim) { - coolant_config.tick(); + if (htim == hw_pwmInputFreqOnly_getTimerHandle(&flow_meter) && + htim->Channel == hw_pwmInputFreqOnly_getTimerActiveChannel(&flow_meter)) + { + hw_pwmInputFreqOnly_tick(&flow_meter); + } } float io_coolant_getFlowRate(void) { - const float freq_read = coolant_config.getFrequency(); + const float freq_read = hw_pwmInputFreqOnly_getFrequency(coolant_config); return freq_read / FLOW_RATE_CONVERSION_FACTOR; } diff --git a/firmware/quintuna/RSM/io/io_coolants.h b/firmware/quintuna/RSM/io/io_coolants.h index 8d45ff8d20..33826a8c7b 100644 --- a/firmware/quintuna/RSM/io/io_coolants.h +++ b/firmware/quintuna/RSM/io/io_coolants.h @@ -32,5 +32,5 @@ typedef struct float io_coolant_getPressure(Coolant *coolant); float io_coolant_getTemperature(Coolant *coolant) - static extern const Coolant a; -static extern const Coolant b; +extern const Coolant a; +extern const Coolant b;