moved defines to funconfig.h

This commit is contained in:
Alessandro Mauri 2026-04-30 22:27:48 +02:00
parent ba23e42050
commit 14a33963b0
2 changed files with 39 additions and 39 deletions

View File

@ -1,12 +1,44 @@
#ifndef _FUNCONFIG_H #ifndef _FUNCONFIG_H
#define _FUNCONFIG_H #define _FUNCONFIG_H
#define FUNCONF_USE_DEBUGPRINTF 0 // can only have one printf #define FUNCONF_USE_DEBUGPRINTF 0 // can only have one printf
#define FUNCONF_USE_USBPRINTF 1 #define FUNCONF_USE_USBPRINTF 1
#define FUNCONF_DEBUG_HARDFAULT 0 #define FUNCONF_DEBUG_HARDFAULT 0
#define CH32X035 1 #define CH32X035 1
#define I2C_TARGET I2C1 #define I2C_TARGET I2C1
#define VCC_MV 3480 #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 #endif // _FUNCONFIG_H

View File

@ -6,33 +6,13 @@
#define USBPD_IMPLEMENTATION #define USBPD_IMPLEMENTATION
#include "usbpd.h" #include "usbpd.h"
#include "funconfig.h"
#include "lib_i2c.h" #include "lib_i2c.h"
#include "display.h" #include "display.h"
#include "filter.h" #include "filter.h"
#include "sc7a20.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 // constants
// LUT for converting NTC readings to degrees celsius // LUT for converting NTC readings to degrees celsius
// Nominal: 1kOhm, Beta: 3380, Step: 64 // Nominal: 1kOhm, Beta: 3380, Step: 64
@ -49,18 +29,6 @@ const int16_t ntc_lut[] = {
u8g2_t *u8g2; u8g2_t *u8g2;
int16_t encoder = 0; // rotary encoder counter int16_t encoder = 0; // rotary encoder counter
uint32_t last_interrupt = 0; // last time the encoder interrupt was triggered 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 // Current profile
struct profile_t { struct profile_t {