From 79b38d894b421b9a0b571bb3b1845b32b68c8651 Mon Sep 17 00:00:00 2001 From: Scott Smith Date: Sun, 2 Jan 2022 22:46:00 -0800 Subject: [PATCH] GDI/HPFP: Set HPFP current/timing params on MC33816 (#3736) --- firmware/hw_layer/mc33816.cpp | 14 ++++++++++++++ firmware/hw_layer/mc33816_memory_map.h | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/firmware/hw_layer/mc33816.cpp b/firmware/hw_layer/mc33816.cpp index 618c313849..fad078b825 100644 --- a/firmware/hw_layer/mc33816.cpp +++ b/firmware/hw_layer/mc33816.cpp @@ -172,6 +172,20 @@ static void setTimings() { mcUpdateDram(MC33816Mem::Tbypass, (MC_CK * engineConfiguration->mc33_t_bypass)); mcUpdateDram(MC33816Mem::Thold_off, (MC_CK * engineConfiguration->mc33_t_hold_off)); mcUpdateDram(MC33816Mem::Thold_tot, (MC_CK * engineConfiguration->mc33_t_hold_tot)); + + // HPFP solenoid settings + mcUpdateDram(MC33816Mem::HPFP_Ipeak, + dacEquation(engineConfiguration->mc33_hpfp_i_peak * 100)); + mcUpdateDram(MC33816Mem::HPFP_Ihold, + dacEquation(engineConfiguration->mc33_hpfp_i_hold * 100)); + mcUpdateDram(MC33816Mem::HPFP_Thold_off, + std::min(MC_CK * engineConfiguration->mc33_hpfp_i_hold_off, + UINT16_MAX)); + // Note, if I'm reading this right, the use of the short and the given clock speed means + // the max time here is approx 10ms. + mcUpdateDram(MC33816Mem::HPFP_Thold_tot, + std::min(MC_CK * 1000 * engineConfiguration->mc33_hpfp_max_hold, + UINT16_MAX)); } void setBoostVoltage(float volts) diff --git a/firmware/hw_layer/mc33816_memory_map.h b/firmware/hw_layer/mc33816_memory_map.h index 284fbecad4..4fa839a7b7 100644 --- a/firmware/hw_layer/mc33816_memory_map.h +++ b/firmware/hw_layer/mc33816_memory_map.h @@ -2,14 +2,18 @@ typedef enum { Iboost = 0, Ipeak = 1, - Ihold = 2, - Tpeak_off = 3, - Tpeak_tot = 4, - Tbypass = 5, - Thold_off = 6, - Thold_tot = 7, - Vboost_high = 64, - Vboost_low = 65, - Isense4_high = 66, - Isense4_low = 67 + Ihold = 2, + Tpeak_off = 3, + Tpeak_tot = 4, + Tbypass = 5, + Thold_off = 6, + Thold_tot = 7, + Vboost_high = 64, + Vboost_low = 65, + Isense4_high = 66, + Isense4_low = 67, + HPFP_Ipeak = 69, + HPFP_Ihold = 70, + HPFP_Thold_off = 71, + HPFP_Thold_tot = 72, } MC33816Mem;