From 48c3ef11252fa2081d70b71342a0c7232d36d087 Mon Sep 17 00:00:00 2001 From: Tianda Huang <37414124+tiandahuang@users.noreply.github.com> Date: Thu, 11 Jul 2024 00:09:10 -0500 Subject: [PATCH] add temperature reorder buf --- Apps/Src/Temperature.c | 11 +++++++++++ Tasks/Src/Task_Amperes.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Apps/Src/Temperature.c b/Apps/Src/Temperature.c index ff187a16..ad0a259b 100644 --- a/Apps/Src/Temperature.c +++ b/Apps/Src/Temperature.c @@ -30,6 +30,15 @@ static TemperatureFilter1_t TemperatureFilter1; #include "EMAFilter.h" static TemperatureFilter2_t TemperatureFilter2; +// hacky remapping for temperature hat error in pin assignment. TODO: fix this in HW +/** + * [1->1, 2->5, 3->9, 4->13 ], + * [5->2, 6->6, 7->10, 8->14 ], + * [9->3, 10->7, 11->11, 12->15], + * [13->4, 14->8, 15->12, 16->16] + */ +static const uint8_t temp_reindex[16] = {0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}; + // simulator bypasses ltc driver #ifndef SIMULATION // Interface to communicate with LTC6811 (Register values) @@ -102,6 +111,8 @@ ErrorStatus Temperature_ChannelConfig(uint8_t tempChannel) { #ifdef SIMULATION currentChannel = tempChannel; #else + // define actual temp channel in HW based on error in PCB. TODO: fix this in HW + tempChannel = temp_reindex[tempChannel]; uint8_t muxAddress; uint8_t otherMux; diff --git a/Tasks/Src/Task_Amperes.c b/Tasks/Src/Task_Amperes.c index 0302beab..1805eba2 100644 --- a/Tasks/Src/Task_Amperes.c +++ b/Tasks/Src/Task_Amperes.c @@ -41,10 +41,10 @@ void Task_AmperesMonitor(void *p_arg) { Amps_UpdateMeasurements(); CheckCurrent(); amps_data_count++; - amps_totals += Amps_GetReading(); + amps_totals += Amps_GetReading(false); // use filtered value here // update state of charge - Charge_Calculate(Amps_GetReading()); + Charge_Calculate(Amps_GetReading(true)); // use raw value here // NONBLOCKING ================== // Send CAN messages