From b8acc93c2b97e158bd6bbe570bb8c81557cae139 Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Wed, 5 Apr 2023 22:41:51 +0200
Subject: [PATCH 01/12] SoC Temperature Sensor
---
Marlin/Configuration.h | 12 +
Marlin/src/HAL/STM32/HAL.h | 1 +
Marlin/src/HAL/STM32/inc/SanityCheck.h | 4 +
Marlin/src/HAL/STM32/internal_temp.h | 349 +++++++++++++++++++++++++
Marlin/src/inc/Conditionals_adv.h | 48 +++-
Marlin/src/inc/SanityCheck.h | 2 +
Marlin/src/module/temperature.cpp | 2 +
7 files changed, 408 insertions(+), 10 deletions(-)
create mode 100644 Marlin/src/HAL/STM32/internal_temp.h
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index d36ceab4916b..33594e710206 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -456,6 +456,18 @@
*
* Temperature sensors available:
*
+ * Board (SoC) Internal Temperature Sensor - IMPORTANT: Only available for TEMP_SENSOR_BOARD
+ * -------
+ * -100 : Use chip internal temperature sensor
+ *
+ * NOTE: The use of the chip internal temperature sensor is to measure the silicon temperature.
+ * It is in NO WAY meant to be an accurate reading of the ambient temperature.
+ * Can only be used with TEMP_SENSOR_BOARD.
+ *
+ * NOTE: Requires TEMP_INTERNAL_SENSOR(RAW) macro to convert the ADC value of the TEMP_BOARD_PIN to the temperature.
+ * HAL\STM32\internal_temp.h provides this macro for STM32 HAL using ATEMP pin and the specs of various STM32 chips.
+ * Therefore, defining TEMP_SENSOR_BOARD -1000 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
+ *
* SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below!
* -------
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1)
diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h
index 61569c793738..17411d81b0ba 100644
--- a/Marlin/src/HAL/STM32/HAL.h
+++ b/Marlin/src/HAL/STM32/HAL.h
@@ -28,6 +28,7 @@
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
+#include "internal_temp.h"
#include "fastio.h"
#include "Servo.h"
#include "MarlinSerial.h"
diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h
index eaad8db4d33d..27373e30a8aa 100644
--- a/Marlin/src/HAL/STM32/inc/SanityCheck.h
+++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h
@@ -51,6 +51,10 @@
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
#endif
+#if TEMP_SENSOR_BOARD_IS_INTERNAL && TEMP_BOARD_PIN != ATEMP
+ #error "TEMP_SENSOR_BOARD=-100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
+#endif
+
/**
* Check for common serial pin conflicts
*/
diff --git a/Marlin/src/HAL/STM32/internal_temp.h b/Marlin/src/HAL/STM32/internal_temp.h
new file mode 100644
index 000000000000..a29832cd310e
--- /dev/null
+++ b/Marlin/src/HAL/STM32/internal_temp.h
@@ -0,0 +1,349 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+// Using STM32 internal temp sensor (TEMP_SENSOR_BOARD -100) requires TEMP_BOARD_PIN ATEMP.
+#define TEMP_BOARD_PIN ATEMP
+
+#if defined(STM32F0xx)
+ /*
+ STM32F030x4 STM32F030x6 STM32F030x8 STM32F030xC https://www.st.com/resource/en/datasheet/stm32f030f4.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32F031x4 STM32F031x6 https://www.st.com/resource/en/datasheet/stm32f031c4.pdf
+ STM32F038x6 https://www.st.com/resource/en/datasheet/stm32f038c6.pdf
+ STM32F042x4 STM32F042x6 https://www.st.com/resource/en/datasheet/stm32f042c4.pdf
+ STM32F048C6 STM32F048G6 STM32F048T6 https://www.st.com/resource/en/datasheet/stm32f048c6.pdf
+ STM32F051x4 STM32F051x6 STM32F051x8 https://www.st.com/resource/en/datasheet/dm00039193.pdf
+ STM32F058C8 STM32F058R8 STM32F058T8 https://www.st.com/resource/en/datasheet/stm32f058c8.pdf
+ STM32F070CB STM32F070RB STM32F070C6 STM32F070F6 https://www.st.com/resource/en/datasheet/stm32f070c6.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32F071x8 STM32F071xB https://www.st.com/resource/en/datasheet/stm32f071cb.pdf
+ STM32F072x8 STM32F072xB https://www.st.com/resource/en/datasheet/stm32f072c8.pdf
+ STM32F078CB STM32F078RB STM32F078VB https://www.st.com/resource/en/datasheet/stm32f078cb.pdf
+ STM32F091xB STM32F091xC https://www.st.com/resource/en/datasheet/stm32f091cc.pdf
+ STM32F098CC STM32F098RC STM32F098VC https://www.st.com/resource/en/datasheet/stm32f098cc.pdf
+ */
+ #define TS_CAL1_TEMP 30 // Calibration temperature of TS_CAL1 (see specific SoC datasheet)
+ #define TS_CAL1_REGOFFSET 0x1FFFF7B8 // Memory address of TS_CAL1 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
+ #define TS_CAL2_TEMP 110 // Calibration temperature of TS_CAL2 (see specific SoC datasheet)
+ #define TS_CAL2_REGOFFSET 0x1FFFF7C2 // Memory address of TS_CAL2 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
+
+#elif defined(STM32F1xx)
+ /*
+ STM32F100xC STM32F100xD STM32F100xE https://www.st.com/resource/en/datasheet/stm32f100rc.pdf
+ --> V=1.41
+ STM32F100x4 STM32F100x6 STM32F100x8 STM32F100xB https://www.st.com/resource/en/datasheet/stm32f100cb.pdf
+ --> V=1.41
+ STM32F101x8 STM32F101xB https://www.st.com/resource/en/datasheet/stm32f101r8.pdf
+ STM32F101xC STM32F101xD STM32F101xE https://www.st.com/resource/en/datasheet/stm32f101rc.pdf
+ STM32F101x4 STM32F101x6 https://www.st.com/resource/en/datasheet/stm32f101c4.pdf
+ STM32F101xF STM32F101xG https://www.st.com/resource/en/datasheet/stm32f101vf.pdf
+ STM32F102x8 STM32F102xB https://www.st.com/resource/en/datasheet/stm32f102c8.pdf
+ --> V=1.42 / Slope=4.35
+ STM32F102x4 STM32F102x6 https://www.st.com/resource/en/datasheet/stm32f102c4.pdf
+ --> V=1.42 / Slope=4.35
+ STM32F103x8 STM32F103xB https://www.st.com/resource/en/datasheet/stm32f103c8.pdf
+ STM32F103xC STM32F103xD STM32F103xE https://www.st.com/resource/en/datasheet/stm32f103rc.pdf
+ STM32F103x4 STM32F103x6 https://www.st.com/resource/en/datasheet/stm32f103c4.pdf
+ STM32F103xF STM32F103xG https://www.st.com/resource/en/datasheet/stm32f103rg.pdf
+ STM32F105xx STM32F107xx https://www.st.com/resource/en/datasheet/stm32f105r8.pdf
+ */
+ #define TS_TYPICAL_V 1.43
+ #define TS_TYPICAL_TEMP 25
+ #define TS_TYPICAL_SLOPE 4.3
+
+#elif defined(STM32F2xx)
+ /*
+ STM32F205xx STM32F207xx https://www.st.com/resource/en/datasheet/stm32f205rb.pdf
+ STM32F215xx STM32F217xx https://www.st.com/resource/en/datasheet/stm32f215re.pdf
+ */
+ #define TS_TYPICAL_V 0.76
+ #define TS_TYPICAL_TEMP 25
+ #define TS_TYPICAL_SLOPE 2.5
+
+#elif defined(STM32F3xx)
+ /*
+ STM32F301x6 STM32F301x8 https://www.st.com/resource/en/datasheet/stm32f301c6.pdf
+ STM32F302xD STM32F302xE https://www.st.com/resource/en/datasheet/stm32f302re.pdf
+ STM32F302x6 STM32F302x8 https://www.st.com/resource/en/datasheet/stm32f302r6.pdf
+ STM32F302xB STM32F302xC https://www.st.com/resource/en/datasheet/stm32f302cb.pdf
+ STM32F303xD STM32F303xE https://www.st.com/resource/en/datasheet/stm32f303re.pdf
+ STM32F303xB STM32F303xC https://www.st.com/resource/en/datasheet/stm32f303cb.pdf
+ STM32F303x6/x8 https://www.st.com/resource/en/datasheet/stm32f303c6.pdf
+ STM32F334x4 STM32F334x6 STM32F334x8 https://www.st.com/resource/en/datasheet/stm32f334k4.pdf
+ STM32F373xx https://www.st.com/resource/en/datasheet/stm32f373cc.pdf
+ STM32F358xC https://www.st.com/resource/en/datasheet/stm32f358cc.pdf
+ STM32F378xx https://www.st.com/resource/en/datasheet/stm32f378cc.pdf
+ STM32F318C8 STM32F318K8 https://www.st.com/resource/en/datasheet/stm32f318c8.pdf
+ STM32F328C8 https://www.st.com/resource/en/datasheet/stm32f328c8.pdf
+ STM32F398VE https://www.st.com/resource/en/datasheet/stm32f398ve.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFFF7B8
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FFFF7C2
+
+#elif defined(STM32F4xx)
+ /*
+ STM32F401xD STM32F401xE https://www.st.com/resource/en/datasheet/stm32f401re.pdf
+ STM32F411xC STM32F411xE https://www.st.com/resource/en/datasheet/stm32f411ce.pdf
+ STM32F446xC/E https://www.st.com/resource/en/datasheet/stm32f446mc.pdf
+ STM32F479xx https://www.st.com/resource/en/datasheet/stm32f479ai.pdf
+ STM32F412xE STM32F412xG https://www.st.com/resource/en/datasheet/stm32f412ce.pdf
+ STM32F410x8 STM32F410xB https://www.st.com/resource/en/datasheet/stm32f410cb.pdf
+ STM32F469xx https://www.st.com/resource/en/datasheet/stm32f469ae.pdf
+ STM32F423xH https://www.st.com/resource/en/datasheet/stm32f423ch.pdf
+ STM32F413xG STM32F413xH https://www.st.com/resource/en/datasheet/stm32f413cg.pdf
+ STM32F415xx STM32F417xx https://www.st.com/resource/en/datasheet/stm32f415rg.pdf
+ STM32F405xx STM32F407xx https://www.st.com/resource/en/datasheet/stm32f405rg.pdf
+ STM32F427xx STM32F429xx https://www.st.com/resource/en/datasheet/stm32f427vg.pdf
+ STM32F437xx STM32F439xx https://www.st.com/resource/en/datasheet/stm32f437vg.pdf
+ STM32F401xB STM32F401xC https://www.st.com/resource/en/datasheet/stm32f401cb.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF7A2C
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FFF7A2E
+
+#elif defined(STM32F7xx)
+ /*
+ STM32F756xx https://www.st.com/resource/en/datasheet/stm32f756bg.pdf
+ STM32F745xx STM32F746xx https://www.st.com/resource/en/datasheet/stm32f745ie.pdf
+ STM32F777xx STM32F778Ax STM32F779xx https://www.st.com/resource/en/datasheet/stm32f777bi.pdf
+ STM32F765xx STM32F767xx STM32F768Ax STM32F769xx https://www.st.com/resource/en/datasheet/stm32f765bi.pdf
+ STM32F722xx STM32F723xx https://www.st.com/resource/en/datasheet/stm32f722ic.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ STM32F732xx STM32F733xx https://www.st.com/resource/en/datasheet/stm32f732ie.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ STM32F750x8 https://www.st.com/resource/en/datasheet/stm32f750n8.pdf
+ STM32F730x8 https://www.st.com/resource/en/datasheet/stm32f730i8.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF0F44C
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FF0F44E
+
+#elif defined(STM32G0xx)
+ /*
+ STM32G030x6/x8 https://www.st.com/resource/en/datasheet/stm32g030c6.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32G050x6/x8 https://www.st.com/resource/en/datasheet/stm32g050c6.pdf
+ STM32G0B0KE/CE/RE/VE https://www.st.com/resource/en/datasheet/stm32g0b0ce.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32G081xB https://www.st.com/resource/en/datasheet/stm32g081cb.pdf
+ STM32G071x8/xB https://www.st.com/resource/en/datasheet/stm32g071c8.pdf
+ STM32G031x4/x6/x8 https://www.st.com/resource/en/datasheet/stm32g031c6.pdf
+ STM32G041x6/x8 https://www.st.com/resource/en/datasheet/stm32g041c8.pdf
+ STM32G051x6/x8 https://www.st.com/resource/en/datasheet/stm32g051c6.pdf
+ STM32G061x6/x8 https://www.st.com/resource/en/datasheet/stm32g061c6.pdf
+ STM32G0B1xB/xC/xE https://www.st.com/resource/en/datasheet/stm32g0b1cc.pdf
+ STM32G0C1xC/xE https://www.st.com/resource/en/datasheet/stm32g0c1cc.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
+
+#elif defined(STM32G4xx)
+ /*
+ STM32G431x6 STM32G431x8 STM32G431xB https://www.st.com/resource/en/datasheet/stm32g431c6.pdf
+ STM32G441xB https://www.st.com/resource/en/datasheet/stm32g441cb.pdf
+ STM32G491xC STM32G491xE https://www.st.com/resource/en/datasheet/stm32g491cc.pdf
+ STM32G4A1xE https://www.st.com/resource/en/datasheet/stm32g4a1ce.pdf
+ STM32G473xB STM32G473xC STM32G473xE https://www.st.com/resource/en/datasheet/stm32g473cb.pdf
+ STM32G483xE https://www.st.com/resource/en/datasheet/stm32g483ce.pdf
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32G474xB STM32G474xC STM32G474xE https://www.st.com/resource/en/datasheet/stm32g474cb.pdf
+ STM32G484xE https://www.st.com/resource/en/datasheet/stm32g484ce.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
+
+#elif defined(STM32H7xx)
+ /*
+ STM32H7A3xI/G
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H7B0xB
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H7B3xI
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H725xE/G
+ STM32H735xG
+ STM32H723VE STM32H723VG STM32H723ZE STM32H723ZG
+ STM32H730AB STM32H730IB STM32H730VB STM32H730ZB
+ STM32H733VG STM32H733ZG
+ STM32H742xI/G STM32H743xI/G
+ --> CAL2_TEMP = 110
+ STM32H745xI/G
+ STM32H747xI/G
+ STM32H753xI
+ STM32H755xI
+ STM32H757xI
+ STM32H750VB STM32H750ZB STM32H750IB STM32H750XB
+ --> CAL2_TEMP = 110
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF1E820
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FF1E840
+
+#elif defined(STM32L0xx)
+ /*
+ STM32L010RB
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010F4 STM32L010K4
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010C6
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010K8 STM32L010R8
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L011x3 STM32L011x4
+ --> TS_CAL1 not defined in datasheet
+ STM32L021D4 STM32L021F4 STM32L021G4 STM32L021K4
+ --> TS_CAL1 not defined in datasheet
+ STM32L031x4 STM32L031x6
+ STM32L041x6
+ STM32L051x6 STM32L051x8
+ STM32L071x8 STM32L071xB STM32L071xZ
+ STM32L081CB STM32L081CZ STM32L081KZ
+ STM32L052x6 STM32L052x8
+ STM32L062K8 STM32L062T8 STM32L062C8
+ STM32L072x8 STM32L072xB STM32L072xZ
+ STM32L082KB STM32L082KZ STM32L082CZ
+ STM32L053C6 STM32L053C8 STM32L053R6 STM32L053R8
+ STM32L063C8 STM32L063R8
+ STM32L073x8 STM32L073xB STM32L073xZ
+ STM32L083x8 STM32L083xB STM32L083xZ
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF8007A
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FF8007E
+
+#elif defined(STM32L1xx)
+ /*
+ STM32L100x6/8/B-A
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L100RC
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L100C6 STM32L100R8/RB
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L151x6/8/B-A STM32L152x6/8/B-A
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32L151xD STM32L152xD
+ STM32L151VD-X STM32L152VD-X
+ STM32L15xCC STM32L15xRC STM32L15xUC STM32L15xVC
+ STM32L15xQC STM32L15xRC-A STM32L15xVC-A STM32L15xZC
+ STM32L162xE
+ STM32L162VD STM32L162ZD STM32L162QD STM32L162RD
+ STM32L162VC STM32L162RC
+ STM32L162VD-X
+ STM32L162QC STM32L162VC-A STM32L162ZC STM32L162RC-A
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF800FA
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FF800FE
+
+#elif defined(STM32L4xx)
+ /*
+ STM32L431xx
+ STM32L451xx
+ STM32L471xx
+ --> CAL2_TEMP = 110
+ STM32L412xx
+ STM32L422xx
+ STM32L432KB STM32L432KC
+ STM32L442KC
+ STM32L452xx
+ STM32L462CE STM32L462RE STM32L462VE
+ STM32L433xx
+ STM32L443CC STM32L443RC STM32L443VC
+ STM32L475xx
+ --> CAL2_TEMP = 110
+ STM32L476xx
+ --> CAL2_TEMP = 110
+ STM32L486xx :
+ --> CAL2_TEMP = 110
+ STM32L496xx
+ STM32L4A6xG
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
+
+#elif defined(STM32MP1xx)
+ /*
+ STM32MP131A STM32MP131D
+ STM32MP131C STM32MP131F
+ STM32MP133A STM32MP133D
+ STM32MP133C STM32MP133F
+ STM32MP135A STM32MP135D
+ STM32MP135C STM32MP135F
+ STM32MP151A/D
+ STM32MP151C/F
+ STM32MP153A/D
+ STM32MP153C/F
+ STM32MP157A/D
+ STM32MP157C/F
+ */
+ // BSEC -> RCC
+ //#define TS_CAL1_TEMP 30
+ //#define TS_CAL1_REGOFFSET 0x5C00 525C[15:0]
+ //#define TS_CAL2_TEMP 130
+ //#define TS_CAL2_REGOFFSET 0x5C00 525C[31:16]
+
+#elif defined(STM32WBxx)
+ /*
+ STM32WB10CC
+ STM32WB50CG STM32WB30CE
+ STM32WB15CC
+ STM32WB55xx STM32WB35xx
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
+#endif
+
+// TODO implement voltage scaling (calibrated Vrefint) and ADC resolution scaling (when applicable)
+
+/**
+ * When provided in datasheet, the use of calibrated values (TS_CAL1, TS_CAL2) should always be preferred over typical values.
+ * Typical values may result in important variation from the actual temperature.
+ *
+ * If calibrated values are not provided in datasheet, it is encouraged to calibrate your specific chip yourself.
+ */
+#if defined(TS_CAL1_TEMP) && defined(TS_CAL1_REGOFFSET) && defined(TS_CAL2_TEMP) && defined(TS_CAL2_REGOFFSET)
+
+ #define READMEMORY(ADDR) (*((uint16_t const *)(ADDR)))
+ #define TEMP_INTERNAL_SENSOR(RAW) (float((TS_CAL2_TEMP) - (TS_CAL1_TEMP)) / (READMEMORY(TS_CAL2_REGOFFSET) - READMEMORY(TS_CAL1_REGOFFSET)) * ((RAW) / float(OVERSAMPLENR) - READMEMORY(TS_CAL1_REGOFFSET)) + (TS_CAL1_TEMP))
+
+#elif defined(TS_TYPICAL_V) && defined(TS_TYPICAL_SLOPE) && defined(TS_TYPICAL_TEMP)
+
+ #define TEMP_INTERNAL_SENSOR(RAW) ((TS_TYPICAL_V - (RAW) / float(OVERSAMPLENR) / float(HAL_ADC_RANGE) * float(ADC_VREF)) / (TS_TYPICAL_SLOPE/1000) + TS_TYPICAL_TEMP)
+
+#endif
diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index 329562672238..f4082f4c50c9 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -320,6 +320,8 @@
#define TEMP_SENSOR_0_IS_AD8495 1
#elif TEMP_SENSOR_0 == -1
#define TEMP_SENSOR_0_IS_AD595 1
+#elif TEMP_SENSOR_0 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_0."
#elif TEMP_SENSOR_0 == 1000
#define TEMP_SENSOR_0_IS_CUSTOM 1
#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999
@@ -365,6 +367,8 @@
#define TEMP_SENSOR_1_IS_AD8495 1
#elif TEMP_SENSOR_1 == -1
#define TEMP_SENSOR_1_IS_AD595 1
+#elif TEMP_SENSOR_1 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_1."
#elif TEMP_SENSOR_1 == 1000
#define TEMP_SENSOR_1_IS_CUSTOM 1
#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999
@@ -410,6 +414,8 @@
#define TEMP_SENSOR_2_IS_AD8495 1
#elif TEMP_SENSOR_2 == -1
#define TEMP_SENSOR_2_IS_AD595 1
+#elif TEMP_SENSOR_2 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == 1000
#define TEMP_SENSOR_2_IS_CUSTOM 1
#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
@@ -537,6 +543,8 @@
#define TEMP_SENSOR_REDUNDANT_IS_AD8495 1
#elif TEMP_SENSOR_REDUNDANT == -1
#define TEMP_SENSOR_REDUNDANT_IS_AD595 1
+#elif TEMP_SENSOR_REDUNDANT == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_REDUNDANT."
#elif TEMP_SENSOR_REDUNDANT > 0
#define TEMP_SENSOR_REDUNDANT_IS_THERMISTOR 1
#if TEMP_SENSOR_REDUNDANT == 1000
@@ -559,7 +567,9 @@
#define HAS_MAX31865 1
#endif
-#if TEMP_SENSOR_3 == -4
+#if TEMP_SENSOR_3 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_3."
+#elif TEMP_SENSOR_3 == -4
#define TEMP_SENSOR_3_IS_AD8495 1
#elif TEMP_SENSOR_3 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
@@ -579,7 +589,9 @@
#undef HEATER_3_MAXTEMP
#endif
-#if TEMP_SENSOR_4 == -4
+#if TEMP_SENSOR_4 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_4."
+#elif TEMP_SENSOR_4 == -4
#define TEMP_SENSOR_4_IS_AD8495 1
#elif TEMP_SENSOR_4 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
@@ -599,7 +611,9 @@
#undef HEATER_4_MAXTEMP
#endif
-#if TEMP_SENSOR_5 == -4
+#if TEMP_SENSOR_5 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_5."
+#elif TEMP_SENSOR_5 == -4
#define TEMP_SENSOR_5_IS_AD8495 1
#elif TEMP_SENSOR_5 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
@@ -619,7 +633,9 @@
#undef HEATER_5_MAXTEMP
#endif
-#if TEMP_SENSOR_6 == -4
+#if TEMP_SENSOR_6 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_6."
+#elif TEMP_SENSOR_6 == -4
#define TEMP_SENSOR_6_IS_AD8495 1
#elif TEMP_SENSOR_6 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6."
@@ -639,7 +655,9 @@
#undef HEATER_6_MAXTEMP
#endif
-#if TEMP_SENSOR_7 == -4
+#if TEMP_SENSOR_7 == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_7."
+#elif TEMP_SENSOR_7 == -4
#define TEMP_SENSOR_7_IS_AD8495 1
#elif TEMP_SENSOR_7 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7."
@@ -659,7 +677,9 @@
#undef HEATER_7_MAXTEMP
#endif
-#if TEMP_SENSOR_BED == -4
+#if TEMP_SENSOR_BED == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_BED."
+#elif TEMP_SENSOR_BED == -4
#define TEMP_SENSOR_BED_IS_AD8495 1
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
@@ -681,7 +701,9 @@
#undef BED_MAXTEMP
#endif
-#if TEMP_SENSOR_CHAMBER == -4
+#if TEMP_SENSOR_CHAMBER == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_CHAMBER."
+#elif TEMP_SENSOR_CHAMBER == -4
#define TEMP_SENSOR_CHAMBER_IS_AD8495 1
#elif TEMP_SENSOR_CHAMBER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
@@ -702,7 +724,9 @@
#undef CHAMBER_MAXTEMP
#endif
-#if TEMP_SENSOR_COOLER == -4
+#if TEMP_SENSOR_COOLER == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_COOLER."
+#elif TEMP_SENSOR_COOLER == -4
#define TEMP_SENSOR_COOLER_IS_AD8495 1
#elif TEMP_SENSOR_COOLER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER."
@@ -723,7 +747,9 @@
#undef COOLER_MAXTEMP
#endif
-#if TEMP_SENSOR_PROBE == -4
+#if TEMP_SENSOR_PROBE == -100
+ #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_PROBE."
+#elif TEMP_SENSOR_PROBE == -4
#define TEMP_SENSOR_PROBE_IS_AD8495 1
#elif TEMP_SENSOR_PROBE == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE."
@@ -740,7 +766,9 @@
#endif
#endif
-#if TEMP_SENSOR_BOARD == -4
+#if TEMP_SENSOR_BOARD == -100
+ #define TEMP_SENSOR_BOARD_IS_INTERNAL 1
+#elif TEMP_SENSOR_BOARD == -4
#define TEMP_SENSOR_BOARD_IS_AD8495 1
#elif TEMP_SENSOR_BOARD == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BOARD."
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index ce657f24a63d..df5300c3a0e4 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -2727,6 +2727,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN."
#elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP))
#error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP."
+ #elif TEMP_SENSOR_BOARD_IS_INTERNAL && !defined(TEMP_INTERNAL_SENSOR)
+ #error "TEMP_SENSOR_BOARD=-100 requires TEMP_INTERNAL_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
#endif
#elif CONTROLLER_FAN_MIN_BOARD_TEMP
#error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD."
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index 29c3a787c5b6..ad6c3fdab16d 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -2360,6 +2360,8 @@ void Temperature::task() {
return TEMP_AD595(raw);
#elif TEMP_SENSOR_BOARD_IS_AD8495
return TEMP_AD8495(raw);
+ #elif TEMP_SENSOR_BOARD_IS_INTERNAL
+ return TEMP_INTERNAL_SENSOR(raw);
#else
UNUSED(raw);
return 0;
From 620a48fc1c30c5c89300d18f82bde60b70ab99fb Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Wed, 5 Apr 2023 22:51:46 +0200
Subject: [PATCH 02/12] Prevent BOARD_PIN definition
---
Marlin/Configuration.h | 2 +-
Marlin/Configuration_adv.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 33594e710206..8729300a81f0 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -466,7 +466,7 @@
*
* NOTE: Requires TEMP_INTERNAL_SENSOR(RAW) macro to convert the ADC value of the TEMP_BOARD_PIN to the temperature.
* HAL\STM32\internal_temp.h provides this macro for STM32 HAL using ATEMP pin and the specs of various STM32 chips.
- * Therefore, defining TEMP_SENSOR_BOARD -1000 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
+ * Therefore, defining TEMP_SENSOR_BOARD -100 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
*
* SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below!
* -------
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 18e5d9e64766..fc7d04a13b18 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -276,7 +276,7 @@
#define THERMAL_PROTECTION_BOARD // Halt the printer if the board sensor leaves the temp range below.
#define BOARD_MINTEMP 8 // (°C)
#define BOARD_MAXTEMP 70 // (°C)
- #ifndef TEMP_BOARD_PIN
+ #if !defined(TEMP_BOARD_PIN) && TEMP_SENSOR_BOARD != -100
//#define TEMP_BOARD_PIN -1 // Board temp sensor pin, if not set in pins file.
#endif
#endif
From a0799ab9e6d241bd16ef1c486869d3be81dca325 Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Thu, 6 Apr 2023 15:36:14 -0500
Subject: [PATCH 03/12] Delete [ \t]+$
---
Marlin/Configuration.h | 8 ++++----
Marlin/src/HAL/STM32/inc/SanityCheck.h | 2 +-
Marlin/src/HAL/STM32/internal_temp.h | 12 ++++++------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 8729300a81f0..305105eca837 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -459,15 +459,15 @@
* Board (SoC) Internal Temperature Sensor - IMPORTANT: Only available for TEMP_SENSOR_BOARD
* -------
* -100 : Use chip internal temperature sensor
- *
+ *
* NOTE: The use of the chip internal temperature sensor is to measure the silicon temperature.
* It is in NO WAY meant to be an accurate reading of the ambient temperature.
* Can only be used with TEMP_SENSOR_BOARD.
- *
+ *
* NOTE: Requires TEMP_INTERNAL_SENSOR(RAW) macro to convert the ADC value of the TEMP_BOARD_PIN to the temperature.
* HAL\STM32\internal_temp.h provides this macro for STM32 HAL using ATEMP pin and the specs of various STM32 chips.
- * Therefore, defining TEMP_SENSOR_BOARD -100 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
- *
+ * Therefore, defining TEMP_SENSOR_BOARD -100 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
+ *
* SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below!
* -------
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1)
diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h
index 27373e30a8aa..482d0e383467 100644
--- a/Marlin/src/HAL/STM32/inc/SanityCheck.h
+++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h
@@ -52,7 +52,7 @@
#endif
#if TEMP_SENSOR_BOARD_IS_INTERNAL && TEMP_BOARD_PIN != ATEMP
- #error "TEMP_SENSOR_BOARD=-100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
+ #error "TEMP_SENSOR_BOARD=-100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
#endif
/**
diff --git a/Marlin/src/HAL/STM32/internal_temp.h b/Marlin/src/HAL/STM32/internal_temp.h
index a29832cd310e..e5c7a58b7760 100644
--- a/Marlin/src/HAL/STM32/internal_temp.h
+++ b/Marlin/src/HAL/STM32/internal_temp.h
@@ -146,10 +146,10 @@
#elif defined(STM32G0xx)
/*
STM32G030x6/x8 https://www.st.com/resource/en/datasheet/stm32g030c6.pdf
- --> TS_CAL2 not defined in datasheet
+ --> TS_CAL2 not defined in datasheet
STM32G050x6/x8 https://www.st.com/resource/en/datasheet/stm32g050c6.pdf
STM32G0B0KE/CE/RE/VE https://www.st.com/resource/en/datasheet/stm32g0b0ce.pdf
- --> TS_CAL2 not defined in datasheet
+ --> TS_CAL2 not defined in datasheet
STM32G081xB https://www.st.com/resource/en/datasheet/stm32g081cb.pdf
STM32G071x8/xB https://www.st.com/resource/en/datasheet/stm32g071c8.pdf
STM32G031x4/x6/x8 https://www.st.com/resource/en/datasheet/stm32g031c6.pdf
@@ -239,8 +239,8 @@
*/
#define TS_CAL1_TEMP 30
#define TS_CAL1_REGOFFSET 0x1FF8007A
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FF8007E
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FF8007E
#elif defined(STM32L1xx)
/*
@@ -334,8 +334,8 @@
/**
* When provided in datasheet, the use of calibrated values (TS_CAL1, TS_CAL2) should always be preferred over typical values.
* Typical values may result in important variation from the actual temperature.
- *
- * If calibrated values are not provided in datasheet, it is encouraged to calibrate your specific chip yourself.
+ *
+ * If calibrated values are not provided in datasheet, it is encouraged to calibrate your specific chip yourself.
*/
#if defined(TS_CAL1_TEMP) && defined(TS_CAL1_REGOFFSET) && defined(TS_CAL2_TEMP) && defined(TS_CAL2_REGOFFSET)
From f9e66c567e845772aaa049320c249e5d5ae7ca18 Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Thu, 6 Apr 2023 15:59:36 -0500
Subject: [PATCH 04/12] misc. cleanup
---
Marlin/Configuration_adv.h | 4 +-
Marlin/src/HAL/STM32/inc/SanityCheck.h | 4 +-
Marlin/src/HAL/STM32/internal_temp.h | 558 +++++++++---------
Marlin/src/inc/Conditionals_adv.h | 50 +-
Marlin/src/inc/SanityCheck.h | 7 +-
.../src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h | 5 +-
Marlin/src/pins/rambo/pins_EINSY_RAMBO.h | 5 +-
Marlin/src/pins/sam/pins_DUE3DOM_MINI.h | 5 +-
.../src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h | 18 +-
.../src/pins/stm32f4/pins_BTT_BTT002_V1_0.h | 5 +-
10 files changed, 328 insertions(+), 333 deletions(-)
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index fc7d04a13b18..442f638cf6ec 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -276,9 +276,7 @@
#define THERMAL_PROTECTION_BOARD // Halt the printer if the board sensor leaves the temp range below.
#define BOARD_MINTEMP 8 // (°C)
#define BOARD_MAXTEMP 70 // (°C)
- #if !defined(TEMP_BOARD_PIN) && TEMP_SENSOR_BOARD != -100
- //#define TEMP_BOARD_PIN -1 // Board temp sensor pin, if not set in pins file.
- #endif
+ //#define TEMP_BOARD_PIN -1 // Board temp sensor pin override.
#endif
/**
diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h
index 482d0e383467..56e24a65a841 100644
--- a/Marlin/src/HAL/STM32/inc/SanityCheck.h
+++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h
@@ -51,8 +51,8 @@
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
#endif
-#if TEMP_SENSOR_BOARD_IS_INTERNAL && TEMP_BOARD_PIN != ATEMP
- #error "TEMP_SENSOR_BOARD=-100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
+#if TEMP_SENSOR_BOARD_IS_INTERNAL && defined(ATEMP) && TEMP_BOARD_PIN != ATEMP
+ #error "TEMP_SENSOR_BOARD -100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
#endif
/**
diff --git a/Marlin/src/HAL/STM32/internal_temp.h b/Marlin/src/HAL/STM32/internal_temp.h
index e5c7a58b7760..a43ca4713659 100644
--- a/Marlin/src/HAL/STM32/internal_temp.h
+++ b/Marlin/src/HAL/STM32/internal_temp.h
@@ -22,311 +22,313 @@
#pragma once
// Using STM32 internal temp sensor (TEMP_SENSOR_BOARD -100) requires TEMP_BOARD_PIN ATEMP.
-#define TEMP_BOARD_PIN ATEMP
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN ATEMP
+#endif
-#if defined(STM32F0xx)
- /*
- STM32F030x4 STM32F030x6 STM32F030x8 STM32F030xC https://www.st.com/resource/en/datasheet/stm32f030f4.pdf
- --> TS_CAL2 not defined in datasheet
- STM32F031x4 STM32F031x6 https://www.st.com/resource/en/datasheet/stm32f031c4.pdf
- STM32F038x6 https://www.st.com/resource/en/datasheet/stm32f038c6.pdf
- STM32F042x4 STM32F042x6 https://www.st.com/resource/en/datasheet/stm32f042c4.pdf
- STM32F048C6 STM32F048G6 STM32F048T6 https://www.st.com/resource/en/datasheet/stm32f048c6.pdf
- STM32F051x4 STM32F051x6 STM32F051x8 https://www.st.com/resource/en/datasheet/dm00039193.pdf
- STM32F058C8 STM32F058R8 STM32F058T8 https://www.st.com/resource/en/datasheet/stm32f058c8.pdf
- STM32F070CB STM32F070RB STM32F070C6 STM32F070F6 https://www.st.com/resource/en/datasheet/stm32f070c6.pdf
- --> TS_CAL2 not defined in datasheet
- STM32F071x8 STM32F071xB https://www.st.com/resource/en/datasheet/stm32f071cb.pdf
- STM32F072x8 STM32F072xB https://www.st.com/resource/en/datasheet/stm32f072c8.pdf
- STM32F078CB STM32F078RB STM32F078VB https://www.st.com/resource/en/datasheet/stm32f078cb.pdf
- STM32F091xB STM32F091xC https://www.st.com/resource/en/datasheet/stm32f091cc.pdf
- STM32F098CC STM32F098RC STM32F098VC https://www.st.com/resource/en/datasheet/stm32f098cc.pdf
- */
- #define TS_CAL1_TEMP 30 // Calibration temperature of TS_CAL1 (see specific SoC datasheet)
- #define TS_CAL1_REGOFFSET 0x1FFFF7B8 // Memory address of TS_CAL1 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
- #define TS_CAL2_TEMP 110 // Calibration temperature of TS_CAL2 (see specific SoC datasheet)
- #define TS_CAL2_REGOFFSET 0x1FFFF7C2 // Memory address of TS_CAL2 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
+#ifdef STM32F0xx
+ /*
+ STM32F030x4 STM32F030x6 STM32F030x8 STM32F030xC https://www.st.com/resource/en/datasheet/stm32f030f4.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32F031x4 STM32F031x6 https://www.st.com/resource/en/datasheet/stm32f031c4.pdf
+ STM32F038x6 https://www.st.com/resource/en/datasheet/stm32f038c6.pdf
+ STM32F042x4 STM32F042x6 https://www.st.com/resource/en/datasheet/stm32f042c4.pdf
+ STM32F048C6 STM32F048G6 STM32F048T6 https://www.st.com/resource/en/datasheet/stm32f048c6.pdf
+ STM32F051x4 STM32F051x6 STM32F051x8 https://www.st.com/resource/en/datasheet/dm00039193.pdf
+ STM32F058C8 STM32F058R8 STM32F058T8 https://www.st.com/resource/en/datasheet/stm32f058c8.pdf
+ STM32F070CB STM32F070RB STM32F070C6 STM32F070F6 https://www.st.com/resource/en/datasheet/stm32f070c6.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32F071x8 STM32F071xB https://www.st.com/resource/en/datasheet/stm32f071cb.pdf
+ STM32F072x8 STM32F072xB https://www.st.com/resource/en/datasheet/stm32f072c8.pdf
+ STM32F078CB STM32F078RB STM32F078VB https://www.st.com/resource/en/datasheet/stm32f078cb.pdf
+ STM32F091xB STM32F091xC https://www.st.com/resource/en/datasheet/stm32f091cc.pdf
+ STM32F098CC STM32F098RC STM32F098VC https://www.st.com/resource/en/datasheet/stm32f098cc.pdf
+ */
+ #define TS_CAL1_TEMP 30 // Calibration temperature of TS_CAL1 (see specific SoC datasheet)
+ #define TS_CAL1_REGOFFSET 0x1FFFF7B8 // Memory address of TS_CAL1 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
+ #define TS_CAL2_TEMP 110 // Calibration temperature of TS_CAL2 (see specific SoC datasheet)
+ #define TS_CAL2_REGOFFSET 0x1FFFF7C2 // Memory address of TS_CAL2 for STM32F030x4/x6/x8/xC (see specific SoC datasheet)
#elif defined(STM32F1xx)
- /*
- STM32F100xC STM32F100xD STM32F100xE https://www.st.com/resource/en/datasheet/stm32f100rc.pdf
- --> V=1.41
- STM32F100x4 STM32F100x6 STM32F100x8 STM32F100xB https://www.st.com/resource/en/datasheet/stm32f100cb.pdf
- --> V=1.41
- STM32F101x8 STM32F101xB https://www.st.com/resource/en/datasheet/stm32f101r8.pdf
- STM32F101xC STM32F101xD STM32F101xE https://www.st.com/resource/en/datasheet/stm32f101rc.pdf
- STM32F101x4 STM32F101x6 https://www.st.com/resource/en/datasheet/stm32f101c4.pdf
- STM32F101xF STM32F101xG https://www.st.com/resource/en/datasheet/stm32f101vf.pdf
- STM32F102x8 STM32F102xB https://www.st.com/resource/en/datasheet/stm32f102c8.pdf
- --> V=1.42 / Slope=4.35
- STM32F102x4 STM32F102x6 https://www.st.com/resource/en/datasheet/stm32f102c4.pdf
- --> V=1.42 / Slope=4.35
- STM32F103x8 STM32F103xB https://www.st.com/resource/en/datasheet/stm32f103c8.pdf
- STM32F103xC STM32F103xD STM32F103xE https://www.st.com/resource/en/datasheet/stm32f103rc.pdf
- STM32F103x4 STM32F103x6 https://www.st.com/resource/en/datasheet/stm32f103c4.pdf
- STM32F103xF STM32F103xG https://www.st.com/resource/en/datasheet/stm32f103rg.pdf
- STM32F105xx STM32F107xx https://www.st.com/resource/en/datasheet/stm32f105r8.pdf
- */
- #define TS_TYPICAL_V 1.43
- #define TS_TYPICAL_TEMP 25
- #define TS_TYPICAL_SLOPE 4.3
+ /*
+ STM32F100xC STM32F100xD STM32F100xE https://www.st.com/resource/en/datasheet/stm32f100rc.pdf
+ --> V=1.41
+ STM32F100x4 STM32F100x6 STM32F100x8 STM32F100xB https://www.st.com/resource/en/datasheet/stm32f100cb.pdf
+ --> V=1.41
+ STM32F101x8 STM32F101xB https://www.st.com/resource/en/datasheet/stm32f101r8.pdf
+ STM32F101xC STM32F101xD STM32F101xE https://www.st.com/resource/en/datasheet/stm32f101rc.pdf
+ STM32F101x4 STM32F101x6 https://www.st.com/resource/en/datasheet/stm32f101c4.pdf
+ STM32F101xF STM32F101xG https://www.st.com/resource/en/datasheet/stm32f101vf.pdf
+ STM32F102x8 STM32F102xB https://www.st.com/resource/en/datasheet/stm32f102c8.pdf
+ --> V=1.42 / Slope=4.35
+ STM32F102x4 STM32F102x6 https://www.st.com/resource/en/datasheet/stm32f102c4.pdf
+ --> V=1.42 / Slope=4.35
+ STM32F103x8 STM32F103xB https://www.st.com/resource/en/datasheet/stm32f103c8.pdf
+ STM32F103xC STM32F103xD STM32F103xE https://www.st.com/resource/en/datasheet/stm32f103rc.pdf
+ STM32F103x4 STM32F103x6 https://www.st.com/resource/en/datasheet/stm32f103c4.pdf
+ STM32F103xF STM32F103xG https://www.st.com/resource/en/datasheet/stm32f103rg.pdf
+ STM32F105xx STM32F107xx https://www.st.com/resource/en/datasheet/stm32f105r8.pdf
+ */
+ #define TS_TYPICAL_V 1.43
+ #define TS_TYPICAL_TEMP 25
+ #define TS_TYPICAL_SLOPE 4.3
#elif defined(STM32F2xx)
- /*
- STM32F205xx STM32F207xx https://www.st.com/resource/en/datasheet/stm32f205rb.pdf
- STM32F215xx STM32F217xx https://www.st.com/resource/en/datasheet/stm32f215re.pdf
- */
- #define TS_TYPICAL_V 0.76
- #define TS_TYPICAL_TEMP 25
- #define TS_TYPICAL_SLOPE 2.5
+ /*
+ STM32F205xx STM32F207xx https://www.st.com/resource/en/datasheet/stm32f205rb.pdf
+ STM32F215xx STM32F217xx https://www.st.com/resource/en/datasheet/stm32f215re.pdf
+ */
+ #define TS_TYPICAL_V 0.76
+ #define TS_TYPICAL_TEMP 25
+ #define TS_TYPICAL_SLOPE 2.5
#elif defined(STM32F3xx)
- /*
- STM32F301x6 STM32F301x8 https://www.st.com/resource/en/datasheet/stm32f301c6.pdf
- STM32F302xD STM32F302xE https://www.st.com/resource/en/datasheet/stm32f302re.pdf
- STM32F302x6 STM32F302x8 https://www.st.com/resource/en/datasheet/stm32f302r6.pdf
- STM32F302xB STM32F302xC https://www.st.com/resource/en/datasheet/stm32f302cb.pdf
- STM32F303xD STM32F303xE https://www.st.com/resource/en/datasheet/stm32f303re.pdf
- STM32F303xB STM32F303xC https://www.st.com/resource/en/datasheet/stm32f303cb.pdf
- STM32F303x6/x8 https://www.st.com/resource/en/datasheet/stm32f303c6.pdf
- STM32F334x4 STM32F334x6 STM32F334x8 https://www.st.com/resource/en/datasheet/stm32f334k4.pdf
- STM32F373xx https://www.st.com/resource/en/datasheet/stm32f373cc.pdf
- STM32F358xC https://www.st.com/resource/en/datasheet/stm32f358cc.pdf
- STM32F378xx https://www.st.com/resource/en/datasheet/stm32f378cc.pdf
- STM32F318C8 STM32F318K8 https://www.st.com/resource/en/datasheet/stm32f318c8.pdf
- STM32F328C8 https://www.st.com/resource/en/datasheet/stm32f328c8.pdf
- STM32F398VE https://www.st.com/resource/en/datasheet/stm32f398ve.pdf
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFFF7B8
- #define TS_CAL2_TEMP 110
- #define TS_CAL2_REGOFFSET 0x1FFFF7C2
+ /*
+ STM32F301x6 STM32F301x8 https://www.st.com/resource/en/datasheet/stm32f301c6.pdf
+ STM32F302xD STM32F302xE https://www.st.com/resource/en/datasheet/stm32f302re.pdf
+ STM32F302x6 STM32F302x8 https://www.st.com/resource/en/datasheet/stm32f302r6.pdf
+ STM32F302xB STM32F302xC https://www.st.com/resource/en/datasheet/stm32f302cb.pdf
+ STM32F303xD STM32F303xE https://www.st.com/resource/en/datasheet/stm32f303re.pdf
+ STM32F303xB STM32F303xC https://www.st.com/resource/en/datasheet/stm32f303cb.pdf
+ STM32F303x6/x8 https://www.st.com/resource/en/datasheet/stm32f303c6.pdf
+ STM32F334x4 STM32F334x6 STM32F334x8 https://www.st.com/resource/en/datasheet/stm32f334k4.pdf
+ STM32F373xx https://www.st.com/resource/en/datasheet/stm32f373cc.pdf
+ STM32F358xC https://www.st.com/resource/en/datasheet/stm32f358cc.pdf
+ STM32F378xx https://www.st.com/resource/en/datasheet/stm32f378cc.pdf
+ STM32F318C8 STM32F318K8 https://www.st.com/resource/en/datasheet/stm32f318c8.pdf
+ STM32F328C8 https://www.st.com/resource/en/datasheet/stm32f328c8.pdf
+ STM32F398VE https://www.st.com/resource/en/datasheet/stm32f398ve.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFFF7B8
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FFFF7C2
#elif defined(STM32F4xx)
- /*
- STM32F401xD STM32F401xE https://www.st.com/resource/en/datasheet/stm32f401re.pdf
- STM32F411xC STM32F411xE https://www.st.com/resource/en/datasheet/stm32f411ce.pdf
- STM32F446xC/E https://www.st.com/resource/en/datasheet/stm32f446mc.pdf
- STM32F479xx https://www.st.com/resource/en/datasheet/stm32f479ai.pdf
- STM32F412xE STM32F412xG https://www.st.com/resource/en/datasheet/stm32f412ce.pdf
- STM32F410x8 STM32F410xB https://www.st.com/resource/en/datasheet/stm32f410cb.pdf
- STM32F469xx https://www.st.com/resource/en/datasheet/stm32f469ae.pdf
- STM32F423xH https://www.st.com/resource/en/datasheet/stm32f423ch.pdf
- STM32F413xG STM32F413xH https://www.st.com/resource/en/datasheet/stm32f413cg.pdf
- STM32F415xx STM32F417xx https://www.st.com/resource/en/datasheet/stm32f415rg.pdf
- STM32F405xx STM32F407xx https://www.st.com/resource/en/datasheet/stm32f405rg.pdf
- STM32F427xx STM32F429xx https://www.st.com/resource/en/datasheet/stm32f427vg.pdf
- STM32F437xx STM32F439xx https://www.st.com/resource/en/datasheet/stm32f437vg.pdf
- STM32F401xB STM32F401xC https://www.st.com/resource/en/datasheet/stm32f401cb.pdf
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFF7A2C
- #define TS_CAL2_TEMP 110
- #define TS_CAL2_REGOFFSET 0x1FFF7A2E
+ /*
+ STM32F401xD STM32F401xE https://www.st.com/resource/en/datasheet/stm32f401re.pdf
+ STM32F411xC STM32F411xE https://www.st.com/resource/en/datasheet/stm32f411ce.pdf
+ STM32F446xC/E https://www.st.com/resource/en/datasheet/stm32f446mc.pdf
+ STM32F479xx https://www.st.com/resource/en/datasheet/stm32f479ai.pdf
+ STM32F412xE STM32F412xG https://www.st.com/resource/en/datasheet/stm32f412ce.pdf
+ STM32F410x8 STM32F410xB https://www.st.com/resource/en/datasheet/stm32f410cb.pdf
+ STM32F469xx https://www.st.com/resource/en/datasheet/stm32f469ae.pdf
+ STM32F423xH https://www.st.com/resource/en/datasheet/stm32f423ch.pdf
+ STM32F413xG STM32F413xH https://www.st.com/resource/en/datasheet/stm32f413cg.pdf
+ STM32F415xx STM32F417xx https://www.st.com/resource/en/datasheet/stm32f415rg.pdf
+ STM32F405xx STM32F407xx https://www.st.com/resource/en/datasheet/stm32f405rg.pdf
+ STM32F427xx STM32F429xx https://www.st.com/resource/en/datasheet/stm32f427vg.pdf
+ STM32F437xx STM32F439xx https://www.st.com/resource/en/datasheet/stm32f437vg.pdf
+ STM32F401xB STM32F401xC https://www.st.com/resource/en/datasheet/stm32f401cb.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF7A2C
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FFF7A2E
#elif defined(STM32F7xx)
- /*
- STM32F756xx https://www.st.com/resource/en/datasheet/stm32f756bg.pdf
- STM32F745xx STM32F746xx https://www.st.com/resource/en/datasheet/stm32f745ie.pdf
- STM32F777xx STM32F778Ax STM32F779xx https://www.st.com/resource/en/datasheet/stm32f777bi.pdf
- STM32F765xx STM32F767xx STM32F768Ax STM32F769xx https://www.st.com/resource/en/datasheet/stm32f765bi.pdf
- STM32F722xx STM32F723xx https://www.st.com/resource/en/datasheet/stm32f722ic.pdf
- --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
- STM32F732xx STM32F733xx https://www.st.com/resource/en/datasheet/stm32f732ie.pdf
- --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
- STM32F750x8 https://www.st.com/resource/en/datasheet/stm32f750n8.pdf
- STM32F730x8 https://www.st.com/resource/en/datasheet/stm32f730i8.pdf
- --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FF0F44C
- #define TS_CAL2_TEMP 110
- #define TS_CAL2_REGOFFSET 0x1FF0F44E
+ /*
+ STM32F756xx https://www.st.com/resource/en/datasheet/stm32f756bg.pdf
+ STM32F745xx STM32F746xx https://www.st.com/resource/en/datasheet/stm32f745ie.pdf
+ STM32F777xx STM32F778Ax STM32F779xx https://www.st.com/resource/en/datasheet/stm32f777bi.pdf
+ STM32F765xx STM32F767xx STM32F768Ax STM32F769xx https://www.st.com/resource/en/datasheet/stm32f765bi.pdf
+ STM32F722xx STM32F723xx https://www.st.com/resource/en/datasheet/stm32f722ic.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ STM32F732xx STM32F733xx https://www.st.com/resource/en/datasheet/stm32f732ie.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ STM32F750x8 https://www.st.com/resource/en/datasheet/stm32f750n8.pdf
+ STM32F730x8 https://www.st.com/resource/en/datasheet/stm32f730i8.pdf
+ --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF0F44C
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FF0F44E
#elif defined(STM32G0xx)
- /*
- STM32G030x6/x8 https://www.st.com/resource/en/datasheet/stm32g030c6.pdf
- --> TS_CAL2 not defined in datasheet
- STM32G050x6/x8 https://www.st.com/resource/en/datasheet/stm32g050c6.pdf
- STM32G0B0KE/CE/RE/VE https://www.st.com/resource/en/datasheet/stm32g0b0ce.pdf
- --> TS_CAL2 not defined in datasheet
- STM32G081xB https://www.st.com/resource/en/datasheet/stm32g081cb.pdf
- STM32G071x8/xB https://www.st.com/resource/en/datasheet/stm32g071c8.pdf
- STM32G031x4/x6/x8 https://www.st.com/resource/en/datasheet/stm32g031c6.pdf
- STM32G041x6/x8 https://www.st.com/resource/en/datasheet/stm32g041c8.pdf
- STM32G051x6/x8 https://www.st.com/resource/en/datasheet/stm32g051c6.pdf
- STM32G061x6/x8 https://www.st.com/resource/en/datasheet/stm32g061c6.pdf
- STM32G0B1xB/xC/xE https://www.st.com/resource/en/datasheet/stm32g0b1cc.pdf
- STM32G0C1xC/xE https://www.st.com/resource/en/datasheet/stm32g0c1cc.pdf
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFF75A8
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FFF75CA
+ /*
+ STM32G030x6/x8 https://www.st.com/resource/en/datasheet/stm32g030c6.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32G050x6/x8 https://www.st.com/resource/en/datasheet/stm32g050c6.pdf
+ STM32G0B0KE/CE/RE/VE https://www.st.com/resource/en/datasheet/stm32g0b0ce.pdf
+ --> TS_CAL2 not defined in datasheet
+ STM32G081xB https://www.st.com/resource/en/datasheet/stm32g081cb.pdf
+ STM32G071x8/xB https://www.st.com/resource/en/datasheet/stm32g071c8.pdf
+ STM32G031x4/x6/x8 https://www.st.com/resource/en/datasheet/stm32g031c6.pdf
+ STM32G041x6/x8 https://www.st.com/resource/en/datasheet/stm32g041c8.pdf
+ STM32G051x6/x8 https://www.st.com/resource/en/datasheet/stm32g051c6.pdf
+ STM32G061x6/x8 https://www.st.com/resource/en/datasheet/stm32g061c6.pdf
+ STM32G0B1xB/xC/xE https://www.st.com/resource/en/datasheet/stm32g0b1cc.pdf
+ STM32G0C1xC/xE https://www.st.com/resource/en/datasheet/stm32g0c1cc.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
#elif defined(STM32G4xx)
- /*
- STM32G431x6 STM32G431x8 STM32G431xB https://www.st.com/resource/en/datasheet/stm32g431c6.pdf
- STM32G441xB https://www.st.com/resource/en/datasheet/stm32g441cb.pdf
- STM32G491xC STM32G491xE https://www.st.com/resource/en/datasheet/stm32g491cc.pdf
- STM32G4A1xE https://www.st.com/resource/en/datasheet/stm32g4a1ce.pdf
- STM32G473xB STM32G473xC STM32G473xE https://www.st.com/resource/en/datasheet/stm32g473cb.pdf
- STM32G483xE https://www.st.com/resource/en/datasheet/stm32g483ce.pdf
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32G474xB STM32G474xC STM32G474xE https://www.st.com/resource/en/datasheet/stm32g474cb.pdf
- STM32G484xE https://www.st.com/resource/en/datasheet/stm32g484ce.pdf
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFF75A8
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FFF75CA
+ /*
+ STM32G431x6 STM32G431x8 STM32G431xB https://www.st.com/resource/en/datasheet/stm32g431c6.pdf
+ STM32G441xB https://www.st.com/resource/en/datasheet/stm32g441cb.pdf
+ STM32G491xC STM32G491xE https://www.st.com/resource/en/datasheet/stm32g491cc.pdf
+ STM32G4A1xE https://www.st.com/resource/en/datasheet/stm32g4a1ce.pdf
+ STM32G473xB STM32G473xC STM32G473xE https://www.st.com/resource/en/datasheet/stm32g473cb.pdf
+ STM32G483xE https://www.st.com/resource/en/datasheet/stm32g483ce.pdf
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32G474xB STM32G474xC STM32G474xE https://www.st.com/resource/en/datasheet/stm32g474cb.pdf
+ STM32G484xE https://www.st.com/resource/en/datasheet/stm32g484ce.pdf
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
#elif defined(STM32H7xx)
- /*
- STM32H7A3xI/G
- --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
- STM32H7B0xB
- --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
- STM32H7B3xI
- --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
- STM32H725xE/G
- STM32H735xG
- STM32H723VE STM32H723VG STM32H723ZE STM32H723ZG
- STM32H730AB STM32H730IB STM32H730VB STM32H730ZB
- STM32H733VG STM32H733ZG
- STM32H742xI/G STM32H743xI/G
- --> CAL2_TEMP = 110
- STM32H745xI/G
- STM32H747xI/G
- STM32H753xI
- STM32H755xI
- STM32H757xI
- STM32H750VB STM32H750ZB STM32H750IB STM32H750XB
- --> CAL2_TEMP = 110
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FF1E820
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FF1E840
+ /*
+ STM32H7A3xI/G
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H7B0xB
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H7B3xI
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32H725xE/G
+ STM32H735xG
+ STM32H723VE STM32H723VG STM32H723ZE STM32H723ZG
+ STM32H730AB STM32H730IB STM32H730VB STM32H730ZB
+ STM32H733VG STM32H733ZG
+ STM32H742xI/G STM32H743xI/G
+ --> CAL2_TEMP = 110
+ STM32H745xI/G
+ STM32H747xI/G
+ STM32H753xI
+ STM32H755xI
+ STM32H757xI
+ STM32H750VB STM32H750ZB STM32H750IB STM32H750XB
+ --> CAL2_TEMP = 110
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF1E820
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FF1E840
#elif defined(STM32L0xx)
- /*
- STM32L010RB
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L010F4 STM32L010K4
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L010C6
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L010K8 STM32L010R8
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L011x3 STM32L011x4
- --> TS_CAL1 not defined in datasheet
- STM32L021D4 STM32L021F4 STM32L021G4 STM32L021K4
- --> TS_CAL1 not defined in datasheet
- STM32L031x4 STM32L031x6
- STM32L041x6
- STM32L051x6 STM32L051x8
- STM32L071x8 STM32L071xB STM32L071xZ
- STM32L081CB STM32L081CZ STM32L081KZ
- STM32L052x6 STM32L052x8
- STM32L062K8 STM32L062T8 STM32L062C8
- STM32L072x8 STM32L072xB STM32L072xZ
- STM32L082KB STM32L082KZ STM32L082CZ
- STM32L053C6 STM32L053C8 STM32L053R6 STM32L053R8
- STM32L063C8 STM32L063R8
- STM32L073x8 STM32L073xB STM32L073xZ
- STM32L083x8 STM32L083xB STM32L083xZ
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FF8007A
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FF8007E
+ /*
+ STM32L010RB
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010F4 STM32L010K4
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010C6
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L010K8 STM32L010R8
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L011x3 STM32L011x4
+ --> TS_CAL1 not defined in datasheet
+ STM32L021D4 STM32L021F4 STM32L021G4 STM32L021K4
+ --> TS_CAL1 not defined in datasheet
+ STM32L031x4 STM32L031x6
+ STM32L041x6
+ STM32L051x6 STM32L051x8
+ STM32L071x8 STM32L071xB STM32L071xZ
+ STM32L081CB STM32L081CZ STM32L081KZ
+ STM32L052x6 STM32L052x8
+ STM32L062K8 STM32L062T8 STM32L062C8
+ STM32L072x8 STM32L072xB STM32L072xZ
+ STM32L082KB STM32L082KZ STM32L082CZ
+ STM32L053C6 STM32L053C8 STM32L053R6 STM32L053R8
+ STM32L063C8 STM32L063R8
+ STM32L073x8 STM32L073xB STM32L073xZ
+ STM32L083x8 STM32L083xB STM32L083xZ
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF8007A
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FF8007E
#elif defined(STM32L1xx)
- /*
- STM32L100x6/8/B-A
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L100RC
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L100C6 STM32L100R8/RB
- --> TS_CAL1/TS_CAL2 not defined in datasheet
- STM32L151x6/8/B-A STM32L152x6/8/B-A
- --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
- STM32L151xD STM32L152xD
- STM32L151VD-X STM32L152VD-X
- STM32L15xCC STM32L15xRC STM32L15xUC STM32L15xVC
- STM32L15xQC STM32L15xRC-A STM32L15xVC-A STM32L15xZC
- STM32L162xE
- STM32L162VD STM32L162ZD STM32L162QD STM32L162RD
- STM32L162VC STM32L162RC
- STM32L162VD-X
- STM32L162QC STM32L162VC-A STM32L162ZC STM32L162RC-A
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FF800FA
- #define TS_CAL2_TEMP 110
- #define TS_CAL2_REGOFFSET 0x1FF800FE
+ /*
+ STM32L100x6/8/B-A
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L100RC
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L100C6 STM32L100R8/RB
+ --> TS_CAL1/TS_CAL2 not defined in datasheet
+ STM32L151x6/8/B-A STM32L152x6/8/B-A
+ --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818
+ STM32L151xD STM32L152xD
+ STM32L151VD-X STM32L152VD-X
+ STM32L15xCC STM32L15xRC STM32L15xUC STM32L15xVC
+ STM32L15xQC STM32L15xRC-A STM32L15xVC-A STM32L15xZC
+ STM32L162xE
+ STM32L162VD STM32L162ZD STM32L162QD STM32L162RD
+ STM32L162VC STM32L162RC
+ STM32L162VD-X
+ STM32L162QC STM32L162VC-A STM32L162ZC STM32L162RC-A
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FF800FA
+ #define TS_CAL2_TEMP 110
+ #define TS_CAL2_REGOFFSET 0x1FF800FE
#elif defined(STM32L4xx)
- /*
- STM32L431xx
- STM32L451xx
- STM32L471xx
- --> CAL2_TEMP = 110
- STM32L412xx
- STM32L422xx
- STM32L432KB STM32L432KC
- STM32L442KC
- STM32L452xx
- STM32L462CE STM32L462RE STM32L462VE
- STM32L433xx
- STM32L443CC STM32L443RC STM32L443VC
- STM32L475xx
- --> CAL2_TEMP = 110
- STM32L476xx
- --> CAL2_TEMP = 110
- STM32L486xx :
- --> CAL2_TEMP = 110
- STM32L496xx
- STM32L4A6xG
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFF75A8
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FFF75CA
+ /*
+ STM32L431xx
+ STM32L451xx
+ STM32L471xx
+ --> CAL2_TEMP = 110
+ STM32L412xx
+ STM32L422xx
+ STM32L432KB STM32L432KC
+ STM32L442KC
+ STM32L452xx
+ STM32L462CE STM32L462RE STM32L462VE
+ STM32L433xx
+ STM32L443CC STM32L443RC STM32L443VC
+ STM32L475xx
+ --> CAL2_TEMP = 110
+ STM32L476xx
+ --> CAL2_TEMP = 110
+ STM32L486xx :
+ --> CAL2_TEMP = 110
+ STM32L496xx
+ STM32L4A6xG
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
#elif defined(STM32MP1xx)
- /*
- STM32MP131A STM32MP131D
- STM32MP131C STM32MP131F
- STM32MP133A STM32MP133D
- STM32MP133C STM32MP133F
- STM32MP135A STM32MP135D
- STM32MP135C STM32MP135F
- STM32MP151A/D
- STM32MP151C/F
- STM32MP153A/D
- STM32MP153C/F
- STM32MP157A/D
- STM32MP157C/F
- */
- // BSEC -> RCC
- //#define TS_CAL1_TEMP 30
- //#define TS_CAL1_REGOFFSET 0x5C00 525C[15:0]
- //#define TS_CAL2_TEMP 130
- //#define TS_CAL2_REGOFFSET 0x5C00 525C[31:16]
+ /*
+ STM32MP131A STM32MP131D
+ STM32MP131C STM32MP131F
+ STM32MP133A STM32MP133D
+ STM32MP133C STM32MP133F
+ STM32MP135A STM32MP135D
+ STM32MP135C STM32MP135F
+ STM32MP151A/D
+ STM32MP151C/F
+ STM32MP153A/D
+ STM32MP153C/F
+ STM32MP157A/D
+ STM32MP157C/F
+ */
+ // BSEC -> RCC
+ //#define TS_CAL1_TEMP 30
+ //#define TS_CAL1_REGOFFSET 0x5C00 525C[15:0]
+ //#define TS_CAL2_TEMP 130
+ //#define TS_CAL2_REGOFFSET 0x5C00 525C[31:16]
#elif defined(STM32WBxx)
- /*
- STM32WB10CC
- STM32WB50CG STM32WB30CE
- STM32WB15CC
- STM32WB55xx STM32WB35xx
- */
- #define TS_CAL1_TEMP 30
- #define TS_CAL1_REGOFFSET 0x1FFF75A8
- #define TS_CAL2_TEMP 130
- #define TS_CAL2_REGOFFSET 0x1FFF75CA
+ /*
+ STM32WB10CC
+ STM32WB50CG STM32WB30CE
+ STM32WB15CC
+ STM32WB55xx STM32WB35xx
+ */
+ #define TS_CAL1_TEMP 30
+ #define TS_CAL1_REGOFFSET 0x1FFF75A8
+ #define TS_CAL2_TEMP 130
+ #define TS_CAL2_REGOFFSET 0x1FFF75CA
#endif
// TODO implement voltage scaling (calibrated Vrefint) and ADC resolution scaling (when applicable)
diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index f4082f4c50c9..3c917465b96f 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -280,9 +280,9 @@
#define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I)
#define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I)
#define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N))
-#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) \
- _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) \
- _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) _SENSOR_IS(N,REDUNDANT) )
+#define ANY_EXT_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) _SENSOR_IS(N,REDUNDANT) \
+ _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) _SENSOR_IS(N,COOLER) )
+#define ANY_THERMISTOR_IS(N) ( ANY_EXT_THERMISTOR_IS(N) _SENSOR_IS(N,BOARD) )
#if ANY_THERMISTOR_IS(1000)
#define HAS_USER_THERMISTORS 1
@@ -320,8 +320,6 @@
#define TEMP_SENSOR_0_IS_AD8495 1
#elif TEMP_SENSOR_0 == -1
#define TEMP_SENSOR_0_IS_AD595 1
-#elif TEMP_SENSOR_0 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_0."
#elif TEMP_SENSOR_0 == 1000
#define TEMP_SENSOR_0_IS_CUSTOM 1
#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999
@@ -367,8 +365,6 @@
#define TEMP_SENSOR_1_IS_AD8495 1
#elif TEMP_SENSOR_1 == -1
#define TEMP_SENSOR_1_IS_AD595 1
-#elif TEMP_SENSOR_1 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_1."
#elif TEMP_SENSOR_1 == 1000
#define TEMP_SENSOR_1_IS_CUSTOM 1
#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999
@@ -414,8 +410,6 @@
#define TEMP_SENSOR_2_IS_AD8495 1
#elif TEMP_SENSOR_2 == -1
#define TEMP_SENSOR_2_IS_AD595 1
-#elif TEMP_SENSOR_2 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == 1000
#define TEMP_SENSOR_2_IS_CUSTOM 1
#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
@@ -543,8 +537,6 @@
#define TEMP_SENSOR_REDUNDANT_IS_AD8495 1
#elif TEMP_SENSOR_REDUNDANT == -1
#define TEMP_SENSOR_REDUNDANT_IS_AD595 1
-#elif TEMP_SENSOR_REDUNDANT == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_REDUNDANT."
#elif TEMP_SENSOR_REDUNDANT > 0
#define TEMP_SENSOR_REDUNDANT_IS_THERMISTOR 1
#if TEMP_SENSOR_REDUNDANT == 1000
@@ -567,9 +559,7 @@
#define HAS_MAX31865 1
#endif
-#if TEMP_SENSOR_3 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_3."
-#elif TEMP_SENSOR_3 == -4
+#if TEMP_SENSOR_3 == -4
#define TEMP_SENSOR_3_IS_AD8495 1
#elif TEMP_SENSOR_3 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
@@ -589,9 +579,7 @@
#undef HEATER_3_MAXTEMP
#endif
-#if TEMP_SENSOR_4 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_4."
-#elif TEMP_SENSOR_4 == -4
+#if TEMP_SENSOR_4 == -4
#define TEMP_SENSOR_4_IS_AD8495 1
#elif TEMP_SENSOR_4 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
@@ -611,9 +599,7 @@
#undef HEATER_4_MAXTEMP
#endif
-#if TEMP_SENSOR_5 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_5."
-#elif TEMP_SENSOR_5 == -4
+#if TEMP_SENSOR_5 == -4
#define TEMP_SENSOR_5_IS_AD8495 1
#elif TEMP_SENSOR_5 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
@@ -633,9 +619,7 @@
#undef HEATER_5_MAXTEMP
#endif
-#if TEMP_SENSOR_6 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_6."
-#elif TEMP_SENSOR_6 == -4
+#if TEMP_SENSOR_6 == -4
#define TEMP_SENSOR_6_IS_AD8495 1
#elif TEMP_SENSOR_6 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6."
@@ -655,9 +639,7 @@
#undef HEATER_6_MAXTEMP
#endif
-#if TEMP_SENSOR_7 == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_7."
-#elif TEMP_SENSOR_7 == -4
+#if TEMP_SENSOR_7 == -4
#define TEMP_SENSOR_7_IS_AD8495 1
#elif TEMP_SENSOR_7 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7."
@@ -677,9 +659,7 @@
#undef HEATER_7_MAXTEMP
#endif
-#if TEMP_SENSOR_BED == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_BED."
-#elif TEMP_SENSOR_BED == -4
+#if TEMP_SENSOR_BED == -4
#define TEMP_SENSOR_BED_IS_AD8495 1
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
@@ -701,9 +681,7 @@
#undef BED_MAXTEMP
#endif
-#if TEMP_SENSOR_CHAMBER == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_CHAMBER."
-#elif TEMP_SENSOR_CHAMBER == -4
+#if TEMP_SENSOR_CHAMBER == -4
#define TEMP_SENSOR_CHAMBER_IS_AD8495 1
#elif TEMP_SENSOR_CHAMBER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
@@ -724,9 +702,7 @@
#undef CHAMBER_MAXTEMP
#endif
-#if TEMP_SENSOR_COOLER == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_COOLER."
-#elif TEMP_SENSOR_COOLER == -4
+#if TEMP_SENSOR_COOLER == -4
#define TEMP_SENSOR_COOLER_IS_AD8495 1
#elif TEMP_SENSOR_COOLER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER."
@@ -747,9 +723,7 @@
#undef COOLER_MAXTEMP
#endif
-#if TEMP_SENSOR_PROBE == -100
- #error "Board Internal Temperature Sensor (-100) not supported for TEMP_SENSOR_PROBE."
-#elif TEMP_SENSOR_PROBE == -4
+#if TEMP_SENSOR_PROBE == -4
#define TEMP_SENSOR_PROBE_IS_AD8495 1
#elif TEMP_SENSOR_PROBE == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE."
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index df5300c3a0e4..9ae18439c5e7 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -736,6 +736,11 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#undef _ISMAX_1
#undef _ISSNS_1
+// Internal Temperature Sensor
+#if ANY_EXT_THERMISTOR_IS(-100)
+ #error "Board Internal Temperature Sensor (-100) is only supported for TEMP_SENSOR_BOARD."
+#endif
+
/**
* Hephestos 2 Heated Bed Kit requirements
*/
@@ -2728,7 +2733,7 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP))
#error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP."
#elif TEMP_SENSOR_BOARD_IS_INTERNAL && !defined(TEMP_INTERNAL_SENSOR)
- #error "TEMP_SENSOR_BOARD=-100 requires TEMP_INTERNAL_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
+ #error "TEMP_SENSOR_BOARD -100 requires TEMP_INTERNAL_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
#endif
#elif CONTROLLER_FAN_MIN_BOARD_TEMP
#error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD."
diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
index 70f7f748c064..58f5eb5ed4b3 100644
--- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
+++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
@@ -171,7 +171,10 @@
#define TEMP_0_PIN P0_24
#define TEMP_1_PIN P0_23
#define TEMP_BED_PIN P0_25
-#define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K
+
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K
+#endif
//
// Heaters / Fans
diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h
index be1af14bb18d..3fb5f3113972 100644
--- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h
+++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h
@@ -118,10 +118,13 @@
//
#define TEMP_0_PIN 0 // Analog Input, Header J2
#define TEMP_1_PIN 1 // Analog Input, Header J3
-#define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1
#define TEMP_BED_PIN 2 // Analog Input, Header J6
#define TEMP_PROBE_PIN 3 // Analog Input, Header J15
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1
+#endif
+
//
// Heaters / Fans
//
diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h
index 9d56d3626457..fd9ee9510c20 100644
--- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h
+++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h
@@ -69,7 +69,10 @@
#define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor)
#define TEMP_1_PIN 2 // Analog Input (unused)
#define TEMP_BED_PIN 1 // Analog Input (BED thermistor)
-#define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950)
+
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950)
+#endif
// SPI for MAX Thermocouple
#if DISABLED(SDSUPPORT)
diff --git a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h
index f5a285170e99..05b93db121e3 100644
--- a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h
+++ b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h
@@ -148,18 +148,22 @@
#define E0_SLAVE_ADDRESS 0
#endif
#endif
+
//
// Temperature Sensors
//
-#define TEMP_BED_PIN PC2 //TB
-#define TEMP_0_PIN PC1 //TH1
-//#define TEMP_1_PIN PC3 //TH2
-#define TEMP_BOARD_PIN PC3
-#ifndef TEMP_SENSOR_BOARD
- #define TEMP_SENSOR_BOARD 13
-#endif
+#define TEMP_BED_PIN PC2 // TB
+#define TEMP_0_PIN PC1 // TH1
+//#define TEMP_1_PIN PC3 // TH2
#define FIL_RUNOUT_PIN PA10 // MT_DET
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN PC3
+#endif
+#if TEMP_BOARD_PIN == PC3 && TEMP_SENSOR_BOARD != 13
+ #warning "The built-in TEMP_SENSOR_BOARD is 13 for ERYONE Ery32 mini."
+#endif
+
//
// LCD Pins
//
diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
index fdd56b5c9ea3..a6e1e06fac9c 100644
--- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
+++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
@@ -160,10 +160,13 @@
//
#define TEMP_0_PIN PA2 // T0 <-> E0
#define TEMP_1_PIN PA0 // T1 <-> E1
-#define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K
#define TEMP_BED_PIN PA1 // T2 <-> Bed
#define TEMP_PROBE_PIN PC3 // Shares J4 connector with PD1
+#ifndef TEMP_BOARD_PIN
+ #define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K
+#endif
+
//
// Heaters / Fans
//
From 2993d18f898f7e6566dadf8a2f769a7adab4880b Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Thu, 6 Apr 2023 16:36:12 -0500
Subject: [PATCH 05/12] heading cleanup
---
Marlin/Configuration.h | 161 ++++++++++---------
buildroot/share/PlatformIO/scripts/schema.py | 2 +-
2 files changed, 84 insertions(+), 79 deletions(-)
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 305105eca837..87cdc601457a 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -452,24 +452,81 @@
// @section temperature
/**
- * --NORMAL IS 4.7kΩ PULLUP!-- 1kΩ pullup can be used on hotend sensor, using correct resistor and table
+ * Temperature Sensors:
*
- * Temperature sensors available:
+ * NORMAL IS 4.7kΩ PULLUP! Hotend sensors can use 1kΩ pullup with correct resistor and table.
*
- * Board (SoC) Internal Temperature Sensor - IMPORTANT: Only available for TEMP_SENSOR_BOARD
- * -------
- * -100 : Use chip internal temperature sensor
- *
- * NOTE: The use of the chip internal temperature sensor is to measure the silicon temperature.
- * It is in NO WAY meant to be an accurate reading of the ambient temperature.
- * Can only be used with TEMP_SENSOR_BOARD.
+ * ================================================================
+ * Analog Thermistors - 4.7kΩ pullup - Normal
+ * ================================================================
+ * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors
+ * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA
+ * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE
+ * 2 : 200kΩ ATC Semitec 204GT-2
+ * 202 : 200kΩ Copymaster 3D
+ * 3 : ???Ω Mendel-parts thermistor
+ * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !!
+ * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C
+ * 501 : 100kΩ Zonestar - Tronxy X3A
+ * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M
+ * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor
+ * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor
+ * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor
+ * 512 : 100kΩ RPW-Ultra hotend
+ * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple)
+ * 7 : 100kΩ Honeywell 135-104LAG-J01
+ * 71 : 100kΩ Honeywell 135-104LAF-J01
+ * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT
+ * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1
+ * 10 : 100kΩ RS PRO 198-961
+ * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1%
+ * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed
+ * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1%
+ * 15 : 100kΩ Calibrated for JGAurora A5 hotend
+ * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327
+ * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input
+ * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input
+ * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950
+ * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950
+ * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950
+ * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor
+ * 67 : 500kΩ SliceEngineering 450°C Thermistor
+ * 68 : PT100 Smplifier board from Dyze Design
+ * 70 : 100kΩ bq Hephestos 2
+ * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32
+ * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor
+ *
+ * ================================================================
+ * Analog Thermistors - 1kΩ pullup
+ * Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ.
+ * (but gives greater accuracy and more stable PID)
+ * ================================================================
+ * 51 : 100kΩ EPCOS (1kΩ pullup)
+ * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup)
+ * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup)
+ *
+ * ================================================================
+ * Analog Thermistors - 10kΩ pullup - Atypical
+ * ================================================================
+ * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor
*
- * NOTE: Requires TEMP_INTERNAL_SENSOR(RAW) macro to convert the ADC value of the TEMP_BOARD_PIN to the temperature.
- * HAL\STM32\internal_temp.h provides this macro for STM32 HAL using ATEMP pin and the specs of various STM32 chips.
- * Therefore, defining TEMP_SENSOR_BOARD -100 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
+ * ================================================================
+ * Analog RTDs (Pt100/Pt1000)
+ * ================================================================
+ * 110 : Pt100 with 1kΩ pullup (atypical)
+ * 147 : Pt100 with 4.7kΩ pullup
+ * 1010 : Pt1000 with 1kΩ pullup (atypical)
+ * 1022 : Pt1000 with 2.2kΩ pullup
+ * 1047 : Pt1000 with 4.7kΩ pullup (E3D)
+ * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage.
+ * NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21.
+ * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply.
+ * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C.
+ * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
*
- * SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below!
- * -------
+ * ================================================================
+ * SPI RTD/Thermocouple Boards
+ * ================================================================
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1)
* NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below.
* -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1)
@@ -480,82 +537,30 @@
* Software SPI will be used on those ports instead. You can force Hardware SPI on the default bus in the
* Configuration_adv.h file. At this time, separate Hardware SPI buses for sensors are not supported.
*
- * Analog Themocouple Boards
- * -------
+ * ================================================================
+ * Analog Thermocouple Boards
+ * ================================================================
* -4 : AD8495 with Thermocouple
* -1 : AD595 with Thermocouple
*
- * Analog Thermistors - 4.7kΩ pullup - Normal
- * -------
- * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors
- * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA
- * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE
- * 2 : 200kΩ ATC Semitec 204GT-2
- * 202 : 200kΩ Copymaster 3D
- * 3 : ???Ω Mendel-parts thermistor
- * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !!
- * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C
- * 501 : 100kΩ Zonestar - Tronxy X3A
- * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M
- * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor
- * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor
- * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor
- * 512 : 100kΩ RPW-Ultra hotend
- * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple)
- * 7 : 100kΩ Honeywell 135-104LAG-J01
- * 71 : 100kΩ Honeywell 135-104LAF-J01
- * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT
- * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1
- * 10 : 100kΩ RS PRO 198-961
- * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1%
- * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed
- * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1%
- * 15 : 100kΩ Calibrated for JGAurora A5 hotend
- * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327
- * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input
- * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input
- * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950
- * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950
- * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950
- * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor
- * 67 : 500kΩ SliceEngineering 450°C Thermistor
- * 68 : PT100 amplifier board from Dyze Design
- * 70 : 100kΩ bq Hephestos 2
- * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32
- * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor
- *
- * Analog Thermistors - 1kΩ pullup - Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ.
- * ------- (but gives greater accuracy and more stable PID)
- * 51 : 100kΩ EPCOS (1kΩ pullup)
- * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup)
- * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup)
+ * ================================================================
+ * Board Temperature Sensor - Internal (SoC)
+ * ================================================================
+ * -100 : Use chip internal temperature sensor
*
- * Analog Thermistors - 10kΩ pullup - Atypical
- * -------
- * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor
- *
- * Analog RTDs (Pt100/Pt1000)
- * -------
- * 110 : Pt100 with 1kΩ pullup (atypical)
- * 147 : Pt100 with 4.7kΩ pullup
- * 1010 : Pt1000 with 1kΩ pullup (atypical)
- * 1022 : Pt1000 with 2.2kΩ pullup
- * 1047 : Pt1000 with 4.7kΩ pullup (E3D)
- * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage.
- * NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21.
- * 21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply.
- * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C.
- * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
+ * NOTE: This sensor only measures the internal silicon temperature.
+ * It DOES NOT provide an accurate ambient reading!
+ * Use only with TEMP_SENSOR_BOARD (for thermal protection).
*
+ * ================================================================
* Custom/Dummy/Other Thermal Sensors
- * ------
+ * ================================================================
* 0 : not used
* 1000 : Custom - Specify parameters in Configuration_adv.h
*
* !!! Use these for Testing or Development purposes. NEVER for production machine. !!!
* 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below.
* 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below.
- *
*/
#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py
index 103aa1f072dc..afac7b5d2788 100755
--- a/buildroot/share/PlatformIO/scripts/schema.py
+++ b/buildroot/share/PlatformIO/scripts/schema.py
@@ -190,7 +190,7 @@ def use_comment(c, opt, sec, bufref):
elif state == Parse.BLOCK_COMMENT:
# Look for temperature sensors
- if cline == "Temperature sensors available:":
+ if re.match(r'temperature sensors.*:', cline, re.IGNORECASE):
state, cline = Parse.GET_SENSORS, "Temperature Sensors"
options_json, section = use_comment(cline, options_json, section, comment_buff)
From a58153a714a893c513bbcc4d286bd620fa6ca77c Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Fri, 7 Apr 2023 17:08:22 +0200
Subject: [PATCH 06/12] Standalone SoC sensor
---
Marlin/Configuration.h | 9 -----
Marlin/Configuration_adv.h | 11 ++++++
Marlin/src/HAL/STM32/HAL.h | 2 +-
.../HAL/STM32/{internal_temp.h => SoC_temp.h} | 10 ++---
Marlin/src/HAL/STM32/inc/SanityCheck.h | 4 +-
Marlin/src/HAL/STM32F1/HAL.cpp | 3 ++
Marlin/src/core/language.h | 1 +
Marlin/src/feature/controllerfan.cpp | 2 +
Marlin/src/inc/Conditionals_adv.h | 12 +++---
Marlin/src/inc/Conditionals_post.h | 8 +++-
Marlin/src/inc/SanityCheck.h | 21 +++++-----
Marlin/src/module/temperature.cpp | 39 ++++++++++++++++++-
Marlin/src/module/temperature.h | 25 ++++++++++++
Marlin/src/module/thermistor/thermistors.h | 4 ++
14 files changed, 115 insertions(+), 36 deletions(-)
rename Marlin/src/HAL/STM32/{internal_temp.h => SoC_temp.h} (96%)
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 87cdc601457a..fd863093f8db 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -544,15 +544,6 @@
* -1 : AD595 with Thermocouple
*
* ================================================================
- * Board Temperature Sensor - Internal (SoC)
- * ================================================================
- * -100 : Use chip internal temperature sensor
- *
- * NOTE: This sensor only measures the internal silicon temperature.
- * It DOES NOT provide an accurate ambient reading!
- * Use only with TEMP_SENSOR_BOARD (for thermal protection).
- *
- * ================================================================
* Custom/Dummy/Other Thermal Sensors
* ================================================================
* 0 : not used
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 442f638cf6ec..6ee84ec98a75 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -279,6 +279,14 @@
//#define TEMP_BOARD_PIN -1 // Board temp sensor pin override.
#endif
+//
+// SoC Sensor options
+//
+#if TEMP_SENSOR_SOC
+ #define THERMAL_PROTECTION_SOC // Halt the printer if the SoC sensor leaves the temp range below.
+ #define SOC_MAXTEMP 85 // (°C)
+#endif
+
/**
* Thermal Protection provides additional protection to your printer from damage
* and fire. Marlin always includes safe min and max temperature ranges which
@@ -577,6 +585,9 @@
// Use TEMP_SENSOR_BOARD as a trigger for enabling the controller fan
//#define CONTROLLER_FAN_MIN_BOARD_TEMP 40 // (°C) Turn on the fan if the board reaches this temperature
+ // Use TEMP_SENSOR_SOC as a trigger for enabling the controller fan
+ //#define CONTROLLER_FAN_MIN_SOC_TEMP 40 // (°C) Turn on the fan if the SoC reaches this temperature
+
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#if ENABLED(CONTROLLER_FAN_EDITABLE)
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h
index 17411d81b0ba..2c7ae6836b31 100644
--- a/Marlin/src/HAL/STM32/HAL.h
+++ b/Marlin/src/HAL/STM32/HAL.h
@@ -28,7 +28,7 @@
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
-#include "internal_temp.h"
+#include "SoC_temp.h"
#include "fastio.h"
#include "Servo.h"
#include "MarlinSerial.h"
diff --git a/Marlin/src/HAL/STM32/internal_temp.h b/Marlin/src/HAL/STM32/SoC_temp.h
similarity index 96%
rename from Marlin/src/HAL/STM32/internal_temp.h
rename to Marlin/src/HAL/STM32/SoC_temp.h
index a43ca4713659..1acc19b02115 100644
--- a/Marlin/src/HAL/STM32/internal_temp.h
+++ b/Marlin/src/HAL/STM32/SoC_temp.h
@@ -21,9 +21,9 @@
*/
#pragma once
-// Using STM32 internal temp sensor (TEMP_SENSOR_BOARD -100) requires TEMP_BOARD_PIN ATEMP.
-#ifndef TEMP_BOARD_PIN
- #define TEMP_BOARD_PIN ATEMP
+// Using STM32 SoC temp sensor (TEMP_SENSOR_SOC) requires TEMP_SOC_PIN ATEMP.
+#ifndef TEMP_SOC_PIN
+ #define TEMP_SOC_PIN ATEMP
#endif
#ifdef STM32F0xx
@@ -342,10 +342,10 @@
#if defined(TS_CAL1_TEMP) && defined(TS_CAL1_REGOFFSET) && defined(TS_CAL2_TEMP) && defined(TS_CAL2_REGOFFSET)
#define READMEMORY(ADDR) (*((uint16_t const *)(ADDR)))
- #define TEMP_INTERNAL_SENSOR(RAW) (float((TS_CAL2_TEMP) - (TS_CAL1_TEMP)) / (READMEMORY(TS_CAL2_REGOFFSET) - READMEMORY(TS_CAL1_REGOFFSET)) * ((RAW) / float(OVERSAMPLENR) - READMEMORY(TS_CAL1_REGOFFSET)) + (TS_CAL1_TEMP))
+ #define TEMP_SOC_SENSOR(RAW) (float((TS_CAL2_TEMP) - (TS_CAL1_TEMP)) / (READMEMORY(TS_CAL2_REGOFFSET) - READMEMORY(TS_CAL1_REGOFFSET)) * ((RAW) / float(OVERSAMPLENR) - READMEMORY(TS_CAL1_REGOFFSET)) + (TS_CAL1_TEMP))
#elif defined(TS_TYPICAL_V) && defined(TS_TYPICAL_SLOPE) && defined(TS_TYPICAL_TEMP)
- #define TEMP_INTERNAL_SENSOR(RAW) ((TS_TYPICAL_V - (RAW) / float(OVERSAMPLENR) / float(HAL_ADC_RANGE) * float(ADC_VREF)) / (TS_TYPICAL_SLOPE/1000) + TS_TYPICAL_TEMP)
+ #define TEMP_SOC_SENSOR(RAW) ((TS_TYPICAL_V - (RAW) / float(OVERSAMPLENR) / float(HAL_ADC_RANGE) * float(ADC_VREF)) / (TS_TYPICAL_SLOPE/1000) + TS_TYPICAL_TEMP)
#endif
diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h
index 56e24a65a841..adebd288c335 100644
--- a/Marlin/src/HAL/STM32/inc/SanityCheck.h
+++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h
@@ -51,8 +51,8 @@
#error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
#endif
-#if TEMP_SENSOR_BOARD_IS_INTERNAL && defined(ATEMP) && TEMP_BOARD_PIN != ATEMP
- #error "TEMP_SENSOR_BOARD -100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
+#if TEMP_SENSOR_SOC && defined(ATEMP) && TEMP_SOC_PIN != ATEMP
+ #error "TEMP_SENSOR_SOC requires 'TEMP_SOC_PIN ATEMP' on STM32."
#endif
/**
diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp
index 4d3140001e82..cf430c7cca66 100644
--- a/Marlin/src/HAL/STM32F1/HAL.cpp
+++ b/Marlin/src/HAL/STM32F1/HAL.cpp
@@ -307,6 +307,7 @@ enum ADCIndex : uint8_t {
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE)
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER)
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD)
+ OPTITEM(HAS_TEMP_SOC, TEMP_SOC_PIN)
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH)
OPTITEM(HAS_ADC_BUTTONS, ADC_KEY)
OPTITEM(HAS_JOY_ADC_X, JOY_X)
@@ -335,6 +336,7 @@ void MarlinHAL::adc_init() {
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN)
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN)
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN)
+ OPTITEM(HAS_TEMP_SOC, TEMP_SOC_PIN)
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN)
OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN)
OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN)
@@ -373,6 +375,7 @@ void MarlinHAL::adc_start(const pin_t pin) {
_TCASE(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN, TEMP_PROBE)
_TCASE(HAS_TEMP_COOLER, TEMP_COOLER_PIN, TEMP_COOLER)
_TCASE(HAS_TEMP_BOARD, TEMP_BOARD_PIN, TEMP_BOARD)
+ _TCASE(HAS_TEMP_SOC, TEMP_SOC_PIN, TEMP_SOC)
_TCASE(HAS_JOY_ADC_X, JOY_X_PIN, JOY_X)
_TCASE(HAS_JOY_ADC_Y, JOY_Y_PIN, JOY_Y)
_TCASE(HAS_JOY_ADC_Z, JOY_Z_PIN, JOY_Z)
diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h
index bf309293ac6c..a80c12700fe2 100644
--- a/Marlin/src/core/language.h
+++ b/Marlin/src/core/language.h
@@ -242,6 +242,7 @@
#define STR_HEATER_CHAMBER "chamber"
#define STR_COOLER "cooler"
#define STR_MOTHERBOARD "motherboard"
+#define STR_SOC "SoC"
#define STR_PROBE "probe"
#define STR_REDUNDANT "redundant "
#define STR_LASER_TEMP "laser temperature"
diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp
index 6e5278ce7451..e0623f816b9f 100644
--- a/Marlin/src/feature/controllerfan.cpp
+++ b/Marlin/src/feature/controllerfan.cpp
@@ -61,10 +61,12 @@ void ControllerFan::update() {
// - At least one stepper driver is enabled
// - The heated bed is enabled
// - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP
+ // - TEMP_SENSOR_SOC is reporting >= CONTROLLER_FAN_MIN_SOC_TEMP
const ena_mask_t axis_mask = TERN(CONTROLLER_FAN_USE_Z_ONLY, _BV(Z_AXIS), (ena_mask_t)~TERN0(CONTROLLER_FAN_IGNORE_Z, _BV(Z_AXIS)));
if ( (stepper.axis_enabled.bits & axis_mask)
|| TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
|| TERN0(HAS_CONTROLLER_FAN_MIN_BOARD_TEMP, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP)
+ || TERN0(HAS_CONTROLLER_FAN_MIN_SOC_TEMP, thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP)
) lastMotorOn = ms; //... set time to NOW so the fan will turn on
// Fan Settings. Set fan > 0:
diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index 3c917465b96f..0e5fb519bca3 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -262,7 +262,8 @@
*/
// Temperature sensor IDs
-#define HID_REDUNDANT -6
+#define HID_REDUNDANT -7
+#define HID_SOC -6
#define HID_BOARD -5
#define HID_COOLER -4
#define HID_PROBE -3
@@ -280,9 +281,8 @@
#define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I)
#define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I)
#define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N))
-#define ANY_EXT_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) _SENSOR_IS(N,REDUNDANT) \
- _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) _SENSOR_IS(N,COOLER) )
-#define ANY_THERMISTOR_IS(N) ( ANY_EXT_THERMISTOR_IS(N) _SENSOR_IS(N,BOARD) )
+#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) _SENSOR_IS(N,REDUNDANT) \
+ _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) )
#if ANY_THERMISTOR_IS(1000)
#define HAS_USER_THERMISTORS 1
@@ -740,9 +740,7 @@
#endif
#endif
-#if TEMP_SENSOR_BOARD == -100
- #define TEMP_SENSOR_BOARD_IS_INTERNAL 1
-#elif TEMP_SENSOR_BOARD == -4
+#if TEMP_SENSOR_BOARD == -4
#define TEMP_SENSOR_BOARD_IS_AD8495 1
#elif TEMP_SENSOR_BOARD == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BOARD."
diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index 4bbb43a2169d..431cf8a221ed 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -2351,6 +2351,9 @@
#if HAS_ADC_TEST(BOARD)
#define HAS_TEMP_ADC_BOARD 1
#endif
+#if HAS_ADC_TEST(SOC)
+ #define HAS_TEMP_ADC_SOC 1
+#endif
#if HAS_ADC_TEST(REDUNDANT)
#define HAS_TEMP_ADC_REDUNDANT 1
#endif
@@ -2374,6 +2377,9 @@
#if HAS_TEMP(BOARD)
#define HAS_TEMP_BOARD 1
#endif
+#if HAS_TEMP(SOC)
+ #define HAS_TEMP_SOC 1
+#endif
#if HAS_TEMP(REDUNDANT)
#define HAS_TEMP_REDUNDANT 1
#endif
@@ -2447,7 +2453,7 @@
#define BED_OR_CHAMBER 1
#endif
-#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD
+#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD || HAS_TEMP_SOC
#define HAS_TEMP_SENSOR 1
#endif
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index 9ae18439c5e7..3d9f138a0def 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -736,11 +736,6 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#undef _ISMAX_1
#undef _ISSNS_1
-// Internal Temperature Sensor
-#if ANY_EXT_THERMISTOR_IS(-100)
- #error "Board Internal Temperature Sensor (-100) is only supported for TEMP_SENSOR_BOARD."
-#endif
-
/**
* Hephestos 2 Heated Bed Kit requirements
*/
@@ -2579,6 +2574,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be PROBE. TEMP_SENSOR_PROBE is in use."
#elif REDUNDANT_TEMP_MATCH(SOURCE, BOARD) && HAS_TEMP_BOARD
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be BOARD. TEMP_SENSOR_BOARD is in use."
+ #elif REDUNDANT_TEMP_MATCH(SOURCE, SOC)
+ #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be SOC."
#elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER) && HAS_TEMP_CHAMBER
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be CHAMBER. TEMP_SENSOR_CHAMBER is in use."
#elif REDUNDANT_TEMP_MATCH(SOURCE, BED) && HAS_TEMP_BED
@@ -2607,6 +2604,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be CHAMBER without TEMP_CHAMBER_PIN defined."
#elif REDUNDANT_TEMP_MATCH(TARGET, BOARD) && !PIN_EXISTS(TEMP_BOARD)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be BOARD without TEMP_BOARD_PIN defined."
+ #elif REDUNDANT_TEMP_MATCH(TARGET, SOC)
+ #error "TEMP_SENSOR_REDUNDANT_TARGET can't be SOC."
#elif REDUNDANT_TEMP_MATCH(TARGET, PROBE) && !PIN_EXISTS(TEMP_PROBE)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be PROBE without TEMP_PROBE_PIN defined."
#elif REDUNDANT_TEMP_MATCH(TARGET, COOLER) && !PIN_EXISTS(TEMP_COOLER)
@@ -2732,15 +2731,19 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN."
#elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP))
#error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP."
- #elif TEMP_SENSOR_BOARD_IS_INTERNAL && !defined(TEMP_INTERNAL_SENSOR)
- #error "TEMP_SENSOR_BOARD -100 requires TEMP_INTERNAL_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
#endif
#elif CONTROLLER_FAN_MIN_BOARD_TEMP
#error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD."
#endif
-#if TEMP_SENSOR_BOARD && !PIN_EXISTS(TEMP_BOARD)
- #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN."
+#if TEMP_SENSOR_SOC
+ #if !PIN_EXISTS(TEMP_SOC)
+ #error "TEMP_SENSOR_SOC requires TEMP_SOC_PIN."
+ #elif !defined(TEMP_SOC_SENSOR)
+ #error "TEMP_SENSOR_SOC requires TEMP_SOC_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
+ #endif
+#elif CONTROLLER_FAN_MIN_SOC_TEMP
+ #error "CONTROLLER_FAN_MIN_SOC_TEMP requires TEMP_SENSOR_SOC."
#endif
#if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE))
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index ad6c3fdab16d..02dd731ee4fe 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -564,6 +564,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
#endif
#endif
+#if HAS_TEMP_SOC
+ board_info_t Temperature::temp_soc; // = { 0 }
+ raw_adc_t Temperature::maxtemp_raw_SOC = TEMP_SENSOR_SOC_RAW_HI_TEMP;
+#endif
+
#if BOTH(HAS_MARLINUI_MENU, PREVENT_COLD_EXTRUSION) && E_MANUAL > 0
bool Temperature::allow_cold_extrude_override = false;
#else
@@ -1355,6 +1360,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m
OPTCODE(HAS_TEMP_COOLER, case H_COOLER: SERIAL_ECHOPGM(STR_COOLER); break)
OPTCODE(HAS_TEMP_PROBE, case H_PROBE: SERIAL_ECHOPGM(STR_PROBE); break)
OPTCODE(HAS_TEMP_BOARD, case H_BOARD: SERIAL_ECHOPGM(STR_MOTHERBOARD); break)
+ OPTCODE(HAS_TEMP_SOC, case H_SOC: SERIAL_ECHOPGM(STR_SOC); break)
OPTCODE(HAS_TEMP_CHAMBER, case H_CHAMBER: SERIAL_ECHOPGM(STR_HEATER_CHAMBER); break)
OPTCODE(HAS_TEMP_BED, case H_BED: SERIAL_ECHOPGM(STR_HEATER_BED); break)
default:
@@ -2360,8 +2366,6 @@ void Temperature::task() {
return TEMP_AD595(raw);
#elif TEMP_SENSOR_BOARD_IS_AD8495
return TEMP_AD8495(raw);
- #elif TEMP_SENSOR_BOARD_IS_INTERNAL
- return TEMP_INTERNAL_SENSOR(raw);
#else
UNUSED(raw);
return 0;
@@ -2369,6 +2373,13 @@ void Temperature::task() {
}
#endif // HAS_TEMP_BOARD
+#if HAS_TEMP_SOC
+ // For SoC temperature measurement.
+ celsius_float_t Temperature::analog_to_celsius_soc(const raw_adc_t raw) {
+ return TEMP_SOC_SENSOR(raw);
+ }
+#endif // HAS_TEMP_SOC
+
#if HAS_TEMP_REDUNDANT
// For redundant temperature measurement.
celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) {
@@ -2431,6 +2442,7 @@ void Temperature::updateTemperaturesFromRawValues() {
TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw()));
TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw()));
TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw()));
+ TERN_(HAS_TEMP_SOC, temp_soc.celsius = analog_to_celsius_soc(temp_soc.getraw()));
TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw()));
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm());
@@ -2508,6 +2520,10 @@ void Temperature::updateTemperaturesFromRawValues() {
if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) maxtemp_error(H_BOARD);
if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) mintemp_error(H_BOARD);
#endif
+
+ #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC)
+ if (TP_CMP(SOC, temp_soc.getraw(), maxtemp_raw_SOC)) maxtemp_error(H_SOC);
+ #endif
#undef TP_CMP
} // Temperature::updateTemperaturesFromRawValues
@@ -2723,6 +2739,7 @@ void Temperature::init() {
TERN_(HAS_TEMP_ADC_PROBE, hal.adc_enable(TEMP_PROBE_PIN));
TERN_(HAS_TEMP_ADC_COOLER, hal.adc_enable(TEMP_COOLER_PIN));
TERN_(HAS_TEMP_ADC_BOARD, hal.adc_enable(TEMP_BOARD_PIN));
+ TERN_(HAS_TEMP_ADC_SOC, hal.adc_enable(TEMP_SOC_PIN));
TERN_(HAS_TEMP_ADC_REDUNDANT, hal.adc_enable(TEMP_REDUNDANT_PIN));
TERN_(FILAMENT_WIDTH_SENSOR, hal.adc_enable(FILWIDTH_PIN));
TERN_(HAS_ADC_BUTTONS, hal.adc_enable(ADC_KEYPAD_PIN));
@@ -2859,6 +2876,10 @@ void Temperature::init() {
while (analog_to_celsius_board(maxtemp_raw_BOARD) > BOARD_MAXTEMP) maxtemp_raw_BOARD -= TEMPDIR(BOARD) * (OVERSAMPLENR);
#endif
+ #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC)
+ while (analog_to_celsius_soc(maxtemp_raw_SOC) > SOC_MAXTEMP) maxtemp_raw_SOC -= OVERSAMPLENR;
+ #endif
+
#if HAS_TEMP_REDUNDANT
temp_redundant.target = &(
#if REDUNDANT_TEMP_MATCH(TARGET, COOLER) && HAS_TEMP_COOLER
@@ -3371,6 +3392,7 @@ void Temperature::readings_ready() {
TERN_(HAS_TEMP_PROBE, temp_probe.reset());
TERN_(HAS_TEMP_COOLER, temp_cooler.reset());
TERN_(HAS_TEMP_BOARD, temp_board.reset());
+ TERN_(HAS_TEMP_SOC, temp_soc.reset());
TERN_(HAS_TEMP_REDUNDANT, temp_redundant.reset());
TERN_(HAS_JOY_ADC_X, joystick.x.reset());
@@ -3829,6 +3851,11 @@ void Temperature::isr() {
case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break;
#endif
+ #if HAS_TEMP_ADC_SOC
+ case PrepareTemp_SOC: hal.adc_start(TEMP_SOC_PIN); break;
+ case MeasureTemp_SOC: ACCUMULATE_ADC(temp_soc); break;
+ #endif
+
#if HAS_TEMP_ADC_REDUNDANT
case PrepareTemp_REDUNDANT: hal.adc_start(TEMP_REDUNDANT_PIN); break;
case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break;
@@ -3970,6 +3997,8 @@ void Temperature::isr() {
* Chamber: " C:nnn.nn /nnn.nn"
* Probe: " P:nnn.nn /nnn.nn"
* Cooler: " L:nnn.nn /nnn.nn"
+ * Board: " M:nnn.nn /nnn.nn"
+ * SoC: " S:nnn.nn /nnn.nn"
* Redundant: " R:nnn.nn /nnn.nn"
* Extruder: " T0:nnn.nn /nnn.nn"
* With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
@@ -3998,6 +4027,9 @@ void Temperature::isr() {
#if HAS_TEMP_BOARD
case H_BOARD: k = 'M'; break;
#endif
+ #if HAS_TEMP_SOC
+ case H_SOC: k = 'S'; break;
+ #endif
#if HAS_TEMP_REDUNDANT
case H_REDUNDANT: k = 'R'; break;
#endif
@@ -4044,6 +4076,9 @@ void Temperature::isr() {
#if HAS_TEMP_BOARD
print_heater_state(H_BOARD, degBoard(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawBoardTemp()));
#endif
+ #if HAS_TEMP_SOC
+ print_heater_state(H_SOC, degSoc(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawSocTemp()));
+ #endif
#if HAS_TEMP_REDUNDANT
if (include_r) print_heater_state(H_REDUNDANT, degRedundant(), degRedundantTarget() OPTARG(SHOW_TEMP_ADC_VALUES, rawRedundantTemp()));
#endif
diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h
index 4bf76e5d4839..2fdd1f02c8dd 100644
--- a/Marlin/src/module/temperature.h
+++ b/Marlin/src/module/temperature.h
@@ -54,6 +54,7 @@ typedef enum : int_fast8_t {
H_COOLER = HID_COOLER,
H_PROBE = HID_PROBE,
H_BOARD = HID_BOARD,
+ H_SOC = HID_SOC,
H_CHAMBER = HID_CHAMBER,
H_BED = HID_BED,
H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7,
@@ -83,6 +84,9 @@ enum ADCSensorState : char {
#if HAS_TEMP_ADC_BOARD
PrepareTemp_BOARD, MeasureTemp_BOARD,
#endif
+ #if HAS_TEMP_ADC_SOC
+ PrepareTemp_SOC, MeasureTemp_SOC,
+ #endif
#if HAS_TEMP_ADC_REDUNDANT
PrepareTemp_REDUNDANT, MeasureTemp_REDUNDANT,
#endif
@@ -480,6 +484,9 @@ struct PIDHeaterInfo : public HeaterInfo {
#if HAS_TEMP_BOARD
typedef temp_info_t board_info_t;
#endif
+#if HAS_TEMP_SOC
+ typedef temp_info_t soc_info_t;
+#endif
// Heater watch handling
template
@@ -607,6 +614,9 @@ class Temperature {
#if HAS_TEMP_BOARD
static board_info_t temp_board;
#endif
+ #if HAS_TEMP_SOC
+ static soc_info_t temp_soc;
+ #endif
#if HAS_TEMP_REDUNDANT
static redundant_info_t temp_redundant;
#endif
@@ -754,6 +764,10 @@ class Temperature {
static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD;
#endif
+ #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC)
+ static raw_adc_t maxtemp_raw_SOC;
+ #endif
+
#if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1
static uint8_t consecutive_low_temperature_error[HOTENDS];
#endif
@@ -846,6 +860,9 @@ class Temperature {
#if HAS_TEMP_BOARD
static celsius_float_t analog_to_celsius_board(const raw_adc_t raw);
#endif
+ #if HAS_TEMP_SOC
+ static celsius_float_t analog_to_celsius_soc(const raw_adc_t raw);
+ #endif
#if HAS_TEMP_REDUNDANT
static celsius_float_t analog_to_celsius_redundant(const raw_adc_t raw);
#endif
@@ -1119,6 +1136,14 @@ class Temperature {
static celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); }
#endif
+ #if HAS_TEMP_SOC
+ #if ENABLED(SHOW_TEMP_ADC_VALUES)
+ static raw_adc_t rawSocTemp() { return temp_soc.getraw(); }
+ #endif
+ static celsius_float_t degSoc() { return temp_soc.celsius; }
+ static celsius_t wholeDegSoc() { return static_cast(temp_soc.celsius + 0.5f); }
+ #endif
+
#if HAS_TEMP_REDUNDANT
#if ENABLED(SHOW_TEMP_ADC_VALUES)
static raw_adc_t rawRedundantTemp() { return temp_redundant.getraw(); }
diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h
index c596d746f7fd..53ca609f6836 100644
--- a/Marlin/src/module/thermistor/thermistors.h
+++ b/Marlin/src/module/thermistor/thermistors.h
@@ -532,6 +532,10 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_
#define TEMP_SENSOR_BOARD_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
+#ifndef TEMP_SENSOR_SOC_RAW_HI_TEMP
+ #define TEMP_SENSOR_SOC_RAW_LO_TEMP 0
+ #define TEMP_SENSOR_SOC_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
+#endif
#ifndef TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP
#if TT_REVRAW(REDUNDANT)
#define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
From 495cd2ddd91ff767b05fd86435db6ac28d1a8c88 Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Fri, 7 Apr 2023 18:39:46 +0200
Subject: [PATCH 07/12] Add missing update temp
---
Marlin/src/module/temperature.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index 02dd731ee4fe..ea7ee51f18ba 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -565,7 +565,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
#endif
#if HAS_TEMP_SOC
- board_info_t Temperature::temp_soc; // = { 0 }
+ soc_info_t Temperature::temp_soc; // = { 0 }
raw_adc_t Temperature::maxtemp_raw_SOC = TEMP_SENSOR_SOC_RAW_HI_TEMP;
#endif
@@ -3362,6 +3362,7 @@ void Temperature::update_raw_temperatures() {
TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update());
TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update());
TERN_(HAS_TEMP_ADC_BOARD, temp_board.update());
+ TERN_(HAS_TEMP_ADC_SOC, temp_soc.update());
TERN_(HAS_JOY_ADC_X, joystick.x.update());
TERN_(HAS_JOY_ADC_Y, joystick.y.update());
From 989ec9d906bd6e169976fe516960c3ee00b77065 Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Fri, 7 Apr 2023 21:08:01 -0500
Subject: [PATCH 08/12] rename
---
Marlin/src/HAL/STM32/HAL.h | 2 +-
Marlin/src/HAL/STM32/{SoC_temp.h => temp_soc.h} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename Marlin/src/HAL/STM32/{SoC_temp.h => temp_soc.h} (100%)
diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h
index 2c7ae6836b31..26fcc2a2e173 100644
--- a/Marlin/src/HAL/STM32/HAL.h
+++ b/Marlin/src/HAL/STM32/HAL.h
@@ -28,7 +28,7 @@
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
-#include "SoC_temp.h"
+#include "temp_soc.h"
#include "fastio.h"
#include "Servo.h"
#include "MarlinSerial.h"
diff --git a/Marlin/src/HAL/STM32/SoC_temp.h b/Marlin/src/HAL/STM32/temp_soc.h
similarity index 100%
rename from Marlin/src/HAL/STM32/SoC_temp.h
rename to Marlin/src/HAL/STM32/temp_soc.h
From 4bfe64bb193a58b957e6733bd727bdf3d20972a9 Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Fri, 7 Apr 2023 21:11:37 -0500
Subject: [PATCH 09/12] Allow config / pins to set TEMP_SOC_PIN
---
Marlin/src/HAL/STM32/temp_soc.h | 5 -----
Marlin/src/pins/pins_postprocess.h | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Marlin/src/HAL/STM32/temp_soc.h b/Marlin/src/HAL/STM32/temp_soc.h
index 1acc19b02115..05262eab8bdf 100644
--- a/Marlin/src/HAL/STM32/temp_soc.h
+++ b/Marlin/src/HAL/STM32/temp_soc.h
@@ -21,11 +21,6 @@
*/
#pragma once
-// Using STM32 SoC temp sensor (TEMP_SENSOR_SOC) requires TEMP_SOC_PIN ATEMP.
-#ifndef TEMP_SOC_PIN
- #define TEMP_SOC_PIN ATEMP
-#endif
-
#ifdef STM32F0xx
/*
STM32F030x4 STM32F030x6 STM32F030x8 STM32F030xC https://www.st.com/resource/en/datasheet/stm32f030f4.pdf
diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h
index 708eb7f8e6cf..7d2470fdde8a 100644
--- a/Marlin/src/pins/pins_postprocess.h
+++ b/Marlin/src/pins/pins_postprocess.h
@@ -456,6 +456,11 @@
#define TEMP_BED_PIN -1
#endif
+// Use ATEMP if TEMP_SOC_PIN is not defined
+#if !defined(TEMP_SOC_PIN) && defined(ATEMP)
+ #define TEMP_SOC_PIN ATEMP
+#endif
+
#ifndef SD_DETECT_PIN
#define SD_DETECT_PIN -1
#endif
From e18d8d227b3f960ed1deebf68b955c038e7fd5a2 Mon Sep 17 00:00:00 2001
From: Scott Lahteine
Date: Fri, 7 Apr 2023 21:39:15 -0500
Subject: [PATCH 10/12] misc. adjustments, add test
---
Marlin/src/HAL/STM32F1/HAL.cpp | 2 +-
Marlin/src/core/language.h | 2 +-
Marlin/src/feature/controllerfan.cpp | 8 ++++++--
Marlin/src/inc/Conditionals_post.h | 3 ---
Marlin/src/inc/SanityCheck.h | 2 --
Marlin/src/module/temperature.cpp | 30 +++++++++++++++++-----------
buildroot/tests/STM32F103RC_btt_USB | 4 ++--
7 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp
index cf430c7cca66..a0cdda3b4fd7 100644
--- a/Marlin/src/HAL/STM32F1/HAL.cpp
+++ b/Marlin/src/HAL/STM32F1/HAL.cpp
@@ -307,7 +307,7 @@ enum ADCIndex : uint8_t {
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE)
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER)
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD)
- OPTITEM(HAS_TEMP_SOC, TEMP_SOC_PIN)
+ OPTITEM(HAS_TEMP_SOC, TEMP_SOC)
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH)
OPTITEM(HAS_ADC_BUTTONS, ADC_KEY)
OPTITEM(HAS_JOY_ADC_X, JOY_X)
diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h
index a80c12700fe2..0c5bc0af9bd4 100644
--- a/Marlin/src/core/language.h
+++ b/Marlin/src/core/language.h
@@ -242,7 +242,7 @@
#define STR_HEATER_CHAMBER "chamber"
#define STR_COOLER "cooler"
#define STR_MOTHERBOARD "motherboard"
-#define STR_SOC "SoC"
+#define STR_SOC "soc"
#define STR_PROBE "probe"
#define STR_REDUNDANT "redundant "
#define STR_LASER_TEMP "laser temperature"
diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp
index e0623f816b9f..4b3d9f550165 100644
--- a/Marlin/src/feature/controllerfan.cpp
+++ b/Marlin/src/feature/controllerfan.cpp
@@ -65,8 +65,12 @@ void ControllerFan::update() {
const ena_mask_t axis_mask = TERN(CONTROLLER_FAN_USE_Z_ONLY, _BV(Z_AXIS), (ena_mask_t)~TERN0(CONTROLLER_FAN_IGNORE_Z, _BV(Z_AXIS)));
if ( (stepper.axis_enabled.bits & axis_mask)
|| TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
- || TERN0(HAS_CONTROLLER_FAN_MIN_BOARD_TEMP, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP)
- || TERN0(HAS_CONTROLLER_FAN_MIN_SOC_TEMP, thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP)
+ #ifdef CONTROLLER_FAN_MIN_BOARD_TEMP
+ || thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP
+ #endif
+ #ifdef CONTROLLER_FAN_MIN_SOC_TEMP
+ || thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP
+ #endif
) lastMotorOn = ms; //... set time to NOW so the fan will turn on
// Fan Settings. Set fan > 0:
diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h
index 431cf8a221ed..a0b2a45eed7b 100644
--- a/Marlin/src/inc/Conditionals_post.h
+++ b/Marlin/src/inc/Conditionals_post.h
@@ -2718,9 +2718,6 @@
*/
#if PIN_EXISTS(CONTROLLER_FAN)
#define HAS_CONTROLLER_FAN 1
- #if CONTROLLER_FAN_MIN_BOARD_TEMP
- #define HAS_CONTROLLER_FAN_MIN_BOARD_TEMP 1
- #endif
#endif
#if HAS_CONTROLLER_FAN
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index 3d9f138a0def..f02f93a48eae 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -2739,8 +2739,6 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#if TEMP_SENSOR_SOC
#if !PIN_EXISTS(TEMP_SOC)
#error "TEMP_SENSOR_SOC requires TEMP_SOC_PIN."
- #elif !defined(TEMP_SOC_SENSOR)
- #error "TEMP_SENSOR_SOC requires TEMP_SOC_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
#endif
#elif CONTROLLER_FAN_MIN_SOC_TEMP
#error "CONTROLLER_FAN_MIN_SOC_TEMP requires TEMP_SENSOR_SOC."
diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp
index ea7ee51f18ba..7254fdabaa3f 100644
--- a/Marlin/src/module/temperature.cpp
+++ b/Marlin/src/module/temperature.cpp
@@ -2376,9 +2376,16 @@ void Temperature::task() {
#if HAS_TEMP_SOC
// For SoC temperature measurement.
celsius_float_t Temperature::analog_to_celsius_soc(const raw_adc_t raw) {
- return TEMP_SOC_SENSOR(raw);
+ return (
+ #ifdef TEMP_SOC_SENSOR
+ TEMP_SOC_SENSOR(raw)
+ #else
+ 0
+ #error "TEMP_SENSOR_SOC requires the TEMP_SOC_SENSOR(RAW) macro to be defined for your board."
+ #endif
+ );
}
-#endif // HAS_TEMP_SOC
+#endif
#if HAS_TEMP_REDUNDANT
// For redundant temperature measurement.
@@ -3996,10 +4003,10 @@ void Temperature::isr() {
* Print a single heater state in the form:
* Bed: " B:nnn.nn /nnn.nn"
* Chamber: " C:nnn.nn /nnn.nn"
- * Probe: " P:nnn.nn /nnn.nn"
+ * Probe: " P:nnn.nn"
* Cooler: " L:nnn.nn /nnn.nn"
- * Board: " M:nnn.nn /nnn.nn"
- * SoC: " S:nnn.nn /nnn.nn"
+ * Board: " M:nnn.nn"
+ * SoC: " S:nnn.nn"
* Redundant: " R:nnn.nn /nnn.nn"
* Extruder: " T0:nnn.nn /nnn.nn"
* With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
@@ -4008,6 +4015,7 @@ void Temperature::isr() {
OPTARG(SHOW_TEMP_ADC_VALUES, const float r)
) {
char k;
+ bool show_t = true;
switch (e) {
default:
#if HAS_TEMP_HOTEND
@@ -4020,16 +4028,16 @@ void Temperature::isr() {
case H_CHAMBER: k = 'C'; break;
#endif
#if HAS_TEMP_PROBE
- case H_PROBE: k = 'P'; break;
+ case H_PROBE: k = 'P'; show_t = false; break;
#endif
#if HAS_TEMP_COOLER
case H_COOLER: k = 'L'; break;
#endif
#if HAS_TEMP_BOARD
- case H_BOARD: k = 'M'; break;
+ case H_BOARD: k = 'M'; show_t = false; break;
#endif
#if HAS_TEMP_SOC
- case H_SOC: k = 'S'; break;
+ case H_SOC: k = 'S'; show_t = false; break;
#endif
#if HAS_TEMP_REDUNDANT
case H_REDUNDANT: k = 'R'; break;
@@ -4044,10 +4052,8 @@ void Temperature::isr() {
#else
#define SFP 2
#endif
- SERIAL_CHAR(':');
- SERIAL_PRINT(c, SFP);
- SERIAL_ECHOPGM(" /");
- SERIAL_PRINT(t, SFP);
+ SERIAL_CHAR(':'); SERIAL_PRINT(c, SFP);
+ if (show_t) { SERIAL_ECHOPGM(" /"); SERIAL_PRINT(t, SFP); }
#if ENABLED(SHOW_TEMP_ADC_VALUES)
// Temperature MAX SPI boards do not have an OVERSAMPLENR defined
SERIAL_ECHOPGM(" (", TERN(HAS_MAXTC_LIBRARIES, k == 'T', false) ? r : r * RECIPROCAL(OVERSAMPLENR));
diff --git a/buildroot/tests/STM32F103RC_btt_USB b/buildroot/tests/STM32F103RC_btt_USB
index 8381de0ea6e4..3981466c4652 100755
--- a/buildroot/tests/STM32F103RC_btt_USB
+++ b/buildroot/tests/STM32F103RC_btt_USB
@@ -10,8 +10,8 @@ set -e
# Build with the default configurations
#
restore_configs
-opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1
-exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - Basic Configuration" "$3"
+opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 TEMP_SENSOR_SOC 1
+exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - SOC Temperature" "$3"
# clean up
restore_configs
From 081b273c3b98c83d5c0f077344818929343a605c Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Thu, 13 Apr 2023 18:24:37 +0200
Subject: [PATCH 11/12] Add missing sanity check
---
Marlin/src/inc/SanityCheck.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index f02f93a48eae..4d4fb5d6662b 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -2739,6 +2739,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#if TEMP_SENSOR_SOC
#if !PIN_EXISTS(TEMP_SOC)
#error "TEMP_SENSOR_SOC requires TEMP_SOC_PIN."
+ #elif ENABLED(THERMAL_PROTECTION_SOC) && !defined(SOC_MAXTEMP)
+ #error "THERMAL_PROTECTION_SOC requires SOC_MAXTEMP."
#endif
#elif CONTROLLER_FAN_MIN_SOC_TEMP
#error "CONTROLLER_FAN_MIN_SOC_TEMP requires TEMP_SENSOR_SOC."
From f0a6173fc37bba171010d29f62371d1946b3aefd Mon Sep 17 00:00:00 2001
From: GMagician <3684609+GMagician@users.noreply.github.com>
Date: Thu, 13 Apr 2023 18:32:29 +0200
Subject: [PATCH 12/12] Add temp_sensor_soc define
Added define but it's really right way to do it or is it better to use a enabled/disabled option?
---
Marlin/Configuration.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index fd863093f8db..b141dcc64883 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -566,6 +566,7 @@
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
#define TEMP_SENSOR_BOARD 0
+#define TEMP_SENSOR_SOC 0
#define TEMP_SENSOR_REDUNDANT 0
// Dummy thermistor constant temperature readings, for use with 998 and 999