From 14a33963b06956a436f857ea6364a1f7b30d299c Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Thu, 30 Apr 2026 22:27:48 +0200 Subject: [PATCH] moved defines to funconfig.h --- fw/funconfig.h | 44 ++++++++++++++++++++++++++++++++++++++------ fw/main.c | 34 +--------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/fw/funconfig.h b/fw/funconfig.h index 956eec3..688ba79 100644 --- a/fw/funconfig.h +++ b/fw/funconfig.h @@ -1,12 +1,44 @@ #ifndef _FUNCONFIG_H #define _FUNCONFIG_H -#define FUNCONF_USE_DEBUGPRINTF 0 // can only have one printf -#define FUNCONF_USE_USBPRINTF 1 -#define FUNCONF_DEBUG_HARDFAULT 0 -#define CH32X035 1 -#define I2C_TARGET I2C1 -#define VCC_MV 3480 +#define FUNCONF_USE_DEBUGPRINTF 0 // can only have one printf +#define FUNCONF_USE_USBPRINTF 1 +#define FUNCONF_DEBUG_HARDFAULT 0 +#define CH32X035 1 +#define I2C_TARGET I2C1 +#define VCC_MV 3480 +#define FRAME_TIME_MS 20 // 50Hz +#define PWM_FREQ_HZ 150000 // TIM3 PWM frequency + +// Pin definitions +#define PIN_VBUS PA0 // vbus voltage feedback +#define PIN_CURRENT PA1 // current feedback +#define PIN_NTC PA2 // ntc temperature sensor +#define PIN_TEMP PA3 // thermocouple amplifier +#define PIN_12V PA5 // 12V regulator enable +#define PIN_HEATER PA6 // power mosfet gate control +#define PIN_ENC_A PB3 // rotary encoder A +#define PIN_ENC_B PB11 // rotary encoder B +#define PIN_BTN PB1 // rotary encoder button + +// Analog channel definitions +#define VBUS_ADC_CHANNEL ANALOG_0 // PA0 +#define CURRENT_ADC_CHANNEL ANALOG_1 // PA1 +#define NTC_ADC_CHANNEL ANALOG_2 // PA2 +#define TEMP_ADC_CHANNEL ANALOG_3 // PA3 + +#define ENCODER_DEBOUNCE 6000 + +// TODO: these need to be calibrated +// Tip mV to deg C conversion factor numerator +#define TC_CONV_NOM 151 +// Tip mV to deg C conversion factor denumerator +#define TC_CONV_DEN 1000 + +#define MAX_BOARD_TEMP 50 +#define MAX_TIP_TEMP 500 +#define TURN_OFF_DELAY 2 +#define CYCLES_PER_MEASURE 2 #endif // _FUNCONFIG_H diff --git a/fw/main.c b/fw/main.c index 750ea5e..5b37759 100644 --- a/fw/main.c +++ b/fw/main.c @@ -6,33 +6,13 @@ #define USBPD_IMPLEMENTATION #include "usbpd.h" +#include "funconfig.h" #include "lib_i2c.h" #include "display.h" #include "filter.h" #include "sc7a20.h" -// Pin definitions -#define PIN_VBUS PA0 // vbus voltage feedback -#define PIN_CURRENT PA1 // current feedback -#define PIN_NTC PA2 // ntc temperature sensor -#define PIN_TEMP PA3 // thermocouple amplifier -#define PIN_12V PA5 // 12V regulator enable -#define PIN_HEATER PA6 // power mosfet gate control -#define PIN_ENC_A PB3 // rotary encoder A -#define PIN_ENC_B PB11 // rotary encoder B -#define PIN_BTN PB1 // rotary encoder button - -// Analog channel definitions -#define VBUS_ADC_CHANNEL ANALOG_0 // PA0 -#define CURRENT_ADC_CHANNEL ANALOG_1 // PA1 -#define NTC_ADC_CHANNEL ANALOG_2 // PA2 -#define TEMP_ADC_CHANNEL ANALOG_3 // PA3 - -#define FRAME_TIME_MS 20 // 50Hz - -#define PWM_FREQ_HZ 150000 - // constants // LUT for converting NTC readings to degrees celsius // Nominal: 1kOhm, Beta: 3380, Step: 64 @@ -49,18 +29,6 @@ const int16_t ntc_lut[] = { u8g2_t *u8g2; int16_t encoder = 0; // rotary encoder counter uint32_t last_interrupt = 0; // last time the encoder interrupt was triggered -#define ENCODER_DEBOUNCE 6000 - -// TODO: these need to be calibrated -// Tip mV to deg C conversion factor numerator -#define TC_CONV_NOM 151 -// Tip mV to deg C conversion factor denumerator -#define TC_CONV_DEN 1000 - -#define MAX_BOARD_TEMP 50 -#define MAX_TIP_TEMP 500 -#define TURN_OFF_DELAY 2 -#define CYCLES_PER_MEASURE 2 // Current profile struct profile_t {