Skip to content

Commit f7fff4d

Browse files
πŸ§‘β€πŸ’» Define isr_float_t to assert a non-FPU float (MarlinFirmware#23969)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent 283aca5 commit f7fff4d

File tree

13 files changed

+20
-16
lines changed

13 files changed

+20
-16
lines changed

β€ŽMarlin/src/HAL/AVR/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class MarlinHAL {
229229
SBI(DIDR0, ch);
230230
}
231231

232-
// Begin ADC sampling on the given channel
232+
// Begin ADC sampling on the given channel. Called from Temperature::isr!
233233
static void adc_start(const uint8_t ch) {
234234
#ifdef MUX5
235235
ADCSRB = ch > 7 ? _BV(MUX5) : 0;

β€ŽMarlin/src/HAL/DUE/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class MarlinHAL {
209209
// Called by Temperature::init for each sensor at startup
210210
static void adc_enable(const uint8_t ch) {}
211211

212-
// Begin ADC sampling on the given channel
212+
// Begin ADC sampling on the given channel. Called from Temperature::isr!
213213
static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }
214214

215215
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/ESP32/HAL.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ void MarlinHAL::adc_start(const pin_t pin) {
244244
const adc1_channel_t chan = get_channel(pin);
245245
uint32_t mv;
246246
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
247-
adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f;
247+
248+
adc_result = mv * isr_float_t(1023) / isr_float_t(ADC_REFERENCE_VOLTAGE) / isr_float_t(1000);
248249

249250
// Change the attenuation level based on the new reading
250251
adc_atten_t atten;

β€ŽMarlin/src/HAL/ESP32/HAL.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
// Types
7575
// ------------------------
7676

77+
typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs.
7778
typedef int16_t pin_t;
7879

7980
class Servo;
@@ -205,7 +206,7 @@ class MarlinHAL {
205206
// Called by Temperature::init for each sensor at startup
206207
static void adc_enable(const pin_t pin) {}
207208

208-
// Begin ADC sampling on the given channel
209+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
209210
static void adc_start(const pin_t pin);
210211

211212
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/LPC1768/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class MarlinHAL {
234234
FilteredADC::enable_channel(pin);
235235
}
236236

237-
// Begin ADC sampling on the given pin
237+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
238238
static uint32_t adc_result;
239239
static void adc_start(const pin_t pin) {
240240
adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits

β€ŽMarlin/src/HAL/NATIVE_SIM/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class MarlinHAL {
242242
// Called by Temperature::init for each sensor at startup
243243
static void adc_enable(const uint8_t ch);
244244

245-
// Begin ADC sampling on the given channel
245+
// Begin ADC sampling on the given channel. Called from Temperature::isr!
246246
static void adc_start(const uint8_t ch);
247247

248248
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/SAMD51/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class MarlinHAL {
190190
// Called by Temperature::init for each sensor at startup
191191
static void adc_enable(const uint8_t ch) {}
192192

193-
// Begin ADC sampling on the given channel
193+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
194194
static void adc_start(const pin_t pin);
195195

196196
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/STM32/HAL.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
// Types
128128
// ------------------------
129129

130+
typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs.
131+
130132
#ifdef STM32G0B1xx
131133
typedef int32_t pin_t;
132134
#else
@@ -241,7 +243,7 @@ class MarlinHAL {
241243
// Called by Temperature::init for each sensor at startup
242244
static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); }
243245

244-
// Begin ADC sampling on the given channel
246+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
245247
static void adc_start(const pin_t pin) { adc_result = analogRead(pin); }
246248

247249
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/STM32F1/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class MarlinHAL {
280280
// Called by Temperature::init for each sensor at startup
281281
static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); }
282282

283-
// Begin ADC sampling on the given channel
283+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
284284
static void adc_start(const pin_t pin);
285285

286286
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/TEENSY31_32/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class MarlinHAL {
166166
// Called by Temperature::init for each sensor at startup
167167
static void adc_enable(const pin_t ch) {}
168168

169-
// Begin ADC sampling on the given channel
169+
// Begin ADC sampling on the given channel. Called from Temperature::isr!
170170
static void adc_start(const pin_t ch);
171171

172172
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/TEENSY35_36/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MarlinHAL {
173173
// Called by Temperature::init for each sensor at startup
174174
static void adc_enable(const pin_t) {}
175175

176-
// Begin ADC sampling on the given channel
176+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
177177
static void adc_start(const pin_t pin);
178178

179179
// Is the ADC ready for reading?

β€ŽMarlin/src/HAL/TEENSY40_41/HAL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class MarlinHAL {
195195
// Called by Temperature::init for each sensor at startup
196196
static void adc_enable(const pin_t pin) {}
197197

198-
// Begin ADC sampling on the given channel
198+
// Begin ADC sampling on the given pin. Called from Temperature::isr!
199199
static void adc_start(const pin_t pin);
200200

201201
// Is the ADC ready for reading?

β€ŽMarlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
196196
#else
197197
#define HOTEND_STATS 1
198198
#endif
199-
static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500),
200-
old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500);
201-
static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false);
199+
static celsius_t old_temp[HOTEND_STATS] = { 0 },
200+
old_target[HOTEND_STATS] = { 0 };
201+
static bool old_on[HOTEND_STATS] = { false };
202202
#endif
203203

204204
#if HAS_HEATED_BED
205-
static celsius_t old_bed_temp = 500, old_bed_target = 500;
205+
static celsius_t old_bed_temp = 0, old_bed_target = 0;
206206
static bool old_bed_on = false;
207207
#if HAS_LEVELING
208208
static bool old_leveling_on = false;

0 commit comments

Comments
Β (0)