From 4dcd8a6308153ec76bb901016bbe5445ffcb5e6c Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 18 Jan 2021 18:54:18 -0500 Subject: [PATCH] https://refactoring.com/catalog/replaceMagicLiteral.html --- firmware/hw_layer/ports/stm32/stm32_common.cpp | 10 +++++++--- firmware/integration/rusefi_config.txt | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/firmware/hw_layer/ports/stm32/stm32_common.cpp b/firmware/hw_layer/ports/stm32/stm32_common.cpp index 11d5623ba9..7cc5902b16 100644 --- a/firmware/hw_layer/ports/stm32/stm32_common.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_common.cpp @@ -14,6 +14,8 @@ #define EFI_PIN_ADC9 GPIOB_1 #endif /* EFI_PIN_ADC9 */ +#define _2_MHZ 2_000_000 + #if EFI_PROD_CODE #include "mpu_util.h" #include "backup_ram.h" @@ -154,7 +156,7 @@ public: } // 2MHz, 16-bit timer gets us a usable frequency range of 31hz to 10khz - static constexpr uint32_t c_timerFrequency = 2000000; + static constexpr uint32_t c_timerFrequency = _2_MHZ; void start(const char* msg, const stm32_pwm_config& config, float frequency, float duty) { m_driver = config.Driver; @@ -170,8 +172,10 @@ public: // If we have too few usable bits, we run out of resolution, so don't allow that either. // 200 counts = 0.5% resolution - if (m_period < 200) { - firmwareError(CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high % hz on pin \"%s\"", frequency, msg); + if (m_period < _2_MHZ / ETB_HW_MAX_FREQUENCY) { + firmwareError(CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d limit %d hz on pin \"%s\"", frequency, + ETB_HW_MAX_FREQUENCY, + msg); return; } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index cf193f5562..62c4dd8009 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1308,7 +1308,7 @@ tle8888_mode_e tle8888mode; ThermistorConf auxTempSensor1;todo: finish implementation #332 ThermistorConf auxTempSensor2;todo: finish implementation #332 uint8_t[6] unused2508;;"units", 1, 0, -20, 100, 0 - int16_t etbFreq;;"Hz", 1, 0, 0, 30000, 0 + int16_t etbFreq;;"Hz", 1, 0, 0, @@ETB_HW_MAX_FREQUENCY@@, 0 pid_s etbWastegatePid; uint8_t[4] unused2536;;"units", 1, 0, -20, 100, 0