@ -23,8 +23,21 @@
# include "../../inc/MarlinConfig.h"
# include "../../inc/MarlinConfig.h"
# define OVERSAMPLENR 16
# define THERMISTOR_TABLE_ADC_RESOLUTION 1024
# define OV(N) int16_t((N) * (OVERSAMPLENR))
# define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / (THERMISTOR_TABLE_ADC_RESOLUTION))
# if ENABLED(HAL_ADC_FILTERED)
# define OVERSAMPLENR 1
# else
# define OVERSAMPLENR 16
# endif
# define MAX_RAW_THERMISTOR_VALUE (HAL_ADC_RANGE * (OVERSAMPLENR) - 1)
// Currently Marlin stores all oversampled ADC values as int16_t, make sure the HAL settings do not overflow 15bit
# if MAX_RAW_THERMISTOR_VALUE > ((1 << 15) - 1)
# error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION."
# endif
# define OV(N) int16_t((N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE))
# define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTORBED == n || THERMISTORCHAMBER == n)
# define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTORBED == n || THERMISTORCHAMBER == n)
@ -251,74 +264,74 @@ static_assert(
// For thermocouples the highest temperature results in the highest ADC value
// For thermocouples the highest temperature results in the highest ADC value
# ifndef HEATER_0_RAW_HI_TEMP
# ifndef HEATER_0_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR)
# define HEATER_0_RAW_HI_TEMP 16383
# define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_0_RAW_LO_TEMP 0
# define HEATER_0_RAW_LO_TEMP 0
# else
# else
# define HEATER_0_RAW_HI_TEMP 0
# define HEATER_0_RAW_HI_TEMP 0
# define HEATER_0_RAW_LO_TEMP 16383
# define HEATER_0_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_1_RAW_HI_TEMP
# ifndef HEATER_1_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_1_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_1_USES_THERMISTOR)
# define HEATER_1_RAW_HI_TEMP 16383
# define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_1_RAW_LO_TEMP 0
# define HEATER_1_RAW_LO_TEMP 0
# else
# else
# define HEATER_1_RAW_HI_TEMP 0
# define HEATER_1_RAW_HI_TEMP 0
# define HEATER_1_RAW_LO_TEMP 16383
# define HEATER_1_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_2_RAW_HI_TEMP
# ifndef HEATER_2_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_2_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_2_USES_THERMISTOR)
# define HEATER_2_RAW_HI_TEMP 16383
# define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_2_RAW_LO_TEMP 0
# define HEATER_2_RAW_LO_TEMP 0
# else
# else
# define HEATER_2_RAW_HI_TEMP 0
# define HEATER_2_RAW_HI_TEMP 0
# define HEATER_2_RAW_LO_TEMP 16383
# define HEATER_2_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_3_RAW_HI_TEMP
# ifndef HEATER_3_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_3_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_3_USES_THERMISTOR)
# define HEATER_3_RAW_HI_TEMP 16383
# define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_3_RAW_LO_TEMP 0
# define HEATER_3_RAW_LO_TEMP 0
# else
# else
# define HEATER_3_RAW_HI_TEMP 0
# define HEATER_3_RAW_HI_TEMP 0
# define HEATER_3_RAW_LO_TEMP 16383
# define HEATER_3_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_4_RAW_HI_TEMP
# ifndef HEATER_4_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_4_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_4_USES_THERMISTOR)
# define HEATER_4_RAW_HI_TEMP 16383
# define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_4_RAW_LO_TEMP 0
# define HEATER_4_RAW_LO_TEMP 0
# else
# else
# define HEATER_4_RAW_HI_TEMP 0
# define HEATER_4_RAW_HI_TEMP 0
# define HEATER_4_RAW_LO_TEMP 16383
# define HEATER_4_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_5_RAW_HI_TEMP
# ifndef HEATER_5_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_5_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_5_USES_THERMISTOR)
# define HEATER_5_RAW_HI_TEMP 16383
# define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_5_RAW_LO_TEMP 0
# define HEATER_5_RAW_LO_TEMP 0
# else
# else
# define HEATER_5_RAW_HI_TEMP 0
# define HEATER_5_RAW_HI_TEMP 0
# define HEATER_5_RAW_LO_TEMP 16383
# define HEATER_5_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_BED_RAW_HI_TEMP
# ifndef HEATER_BED_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_BED_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_BED_USES_THERMISTOR)
# define HEATER_BED_RAW_HI_TEMP 16383
# define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_BED_RAW_LO_TEMP 0
# define HEATER_BED_RAW_LO_TEMP 0
# else
# else
# define HEATER_BED_RAW_HI_TEMP 0
# define HEATER_BED_RAW_HI_TEMP 0
# define HEATER_BED_RAW_LO_TEMP 16383
# define HEATER_BED_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif
# ifndef HEATER_CHAMBER_RAW_HI_TEMP
# ifndef HEATER_CHAMBER_RAW_HI_TEMP
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_CHAMBER_USES_THERMISTOR)
# if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_CHAMBER_USES_THERMISTOR)
# define HEATER_CHAMBER_RAW_HI_TEMP 16383
# define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
# define HEATER_CHAMBER_RAW_LO_TEMP 0
# define HEATER_CHAMBER_RAW_LO_TEMP 0
# else
# else
# define HEATER_CHAMBER_RAW_HI_TEMP 0
# define HEATER_CHAMBER_RAW_HI_TEMP 0
# define HEATER_CHAMBER_RAW_LO_TEMP 16383
# define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
# endif
# endif
# endif
# endif