Explorar el Código

🧑‍💻 Define isr_float_t to assert a non-FPU float (#23969)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
John Robertson hace 3 años
padre
commit
f7fff4d455
No account linked to committer's email address

+ 1
- 1
Marlin/src/HAL/AVR/HAL.h Ver fichero

@@ -229,7 +229,7 @@ public:
229 229
     SBI(DIDR0, ch);
230 230
   }
231 231
 
232
-  // Begin ADC sampling on the given channel
232
+  // Begin ADC sampling on the given channel. Called from Temperature::isr!
233 233
   static void adc_start(const uint8_t ch) {
234 234
     #ifdef MUX5
235 235
       ADCSRB = ch > 7 ? _BV(MUX5) : 0;

+ 1
- 1
Marlin/src/HAL/DUE/HAL.h Ver fichero

@@ -209,7 +209,7 @@ public:
209 209
   // Called by Temperature::init for each sensor at startup
210 210
   static void adc_enable(const uint8_t ch) {}
211 211
 
212
-  // Begin ADC sampling on the given channel
212
+  // Begin ADC sampling on the given channel. Called from Temperature::isr!
213 213
   static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }
214 214
 
215 215
   // Is the ADC ready for reading?

+ 2
- 1
Marlin/src/HAL/ESP32/HAL.cpp Ver fichero

@@ -244,7 +244,8 @@ void MarlinHAL::adc_start(const pin_t pin) {
244 244
   const adc1_channel_t chan = get_channel(pin);
245 245
   uint32_t mv;
246 246
   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);
248 249
 
249 250
   // Change the attenuation level based on the new reading
250 251
   adc_atten_t atten;

+ 2
- 1
Marlin/src/HAL/ESP32/HAL.h Ver fichero

@@ -74,6 +74,7 @@
74 74
 // Types
75 75
 // ------------------------
76 76
 
77
+typedef double isr_float_t;   // FPU ops are used for single-precision, so use double for ISRs.
77 78
 typedef int16_t pin_t;
78 79
 
79 80
 class Servo;
@@ -205,7 +206,7 @@ public:
205 206
   // Called by Temperature::init for each sensor at startup
206 207
   static void adc_enable(const pin_t pin) {}
207 208
 
208
-  // Begin ADC sampling on the given channel
209
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
209 210
   static void adc_start(const pin_t pin);
210 211
 
211 212
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/LPC1768/HAL.h Ver fichero

@@ -234,7 +234,7 @@ public:
234 234
     FilteredADC::enable_channel(pin);
235 235
   }
236 236
 
237
-  // Begin ADC sampling on the given pin
237
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
238 238
   static uint32_t adc_result;
239 239
   static void adc_start(const pin_t pin) {
240 240
     adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits

+ 1
- 1
Marlin/src/HAL/NATIVE_SIM/HAL.h Ver fichero

@@ -242,7 +242,7 @@ public:
242 242
   // Called by Temperature::init for each sensor at startup
243 243
   static void adc_enable(const uint8_t ch);
244 244
 
245
-  // Begin ADC sampling on the given channel
245
+  // Begin ADC sampling on the given channel. Called from Temperature::isr!
246 246
   static void adc_start(const uint8_t ch);
247 247
 
248 248
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/SAMD51/HAL.h Ver fichero

@@ -190,7 +190,7 @@ public:
190 190
   // Called by Temperature::init for each sensor at startup
191 191
   static void adc_enable(const uint8_t ch) {}
192 192
 
193
-  // Begin ADC sampling on the given channel
193
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
194 194
   static void adc_start(const pin_t pin);
195 195
 
196 196
   // Is the ADC ready for reading?

+ 3
- 1
Marlin/src/HAL/STM32/HAL.h Ver fichero

@@ -127,6 +127,8 @@
127 127
 // Types
128 128
 // ------------------------
129 129
 
130
+typedef double isr_float_t;   // FPU ops are used for single-precision, so use double for ISRs.
131
+
130 132
 #ifdef STM32G0B1xx
131 133
   typedef int32_t pin_t;
132 134
 #else
@@ -241,7 +243,7 @@ public:
241 243
   // Called by Temperature::init for each sensor at startup
242 244
   static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); }
243 245
 
244
-  // Begin ADC sampling on the given channel
246
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
245 247
   static void adc_start(const pin_t pin) { adc_result = analogRead(pin); }
246 248
 
247 249
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/STM32F1/HAL.h Ver fichero

@@ -280,7 +280,7 @@ public:
280 280
   // Called by Temperature::init for each sensor at startup
281 281
   static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); }
282 282
 
283
-  // Begin ADC sampling on the given channel
283
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
284 284
   static void adc_start(const pin_t pin);
285 285
 
286 286
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY31_32/HAL.h Ver fichero

@@ -166,7 +166,7 @@ public:
166 166
   // Called by Temperature::init for each sensor at startup
167 167
   static void adc_enable(const pin_t ch) {}
168 168
 
169
-  // Begin ADC sampling on the given channel
169
+  // Begin ADC sampling on the given channel. Called from Temperature::isr!
170 170
   static void adc_start(const pin_t ch);
171 171
 
172 172
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY35_36/HAL.h Ver fichero

@@ -173,7 +173,7 @@ public:
173 173
   // Called by Temperature::init for each sensor at startup
174 174
   static void adc_enable(const pin_t) {}
175 175
 
176
-  // Begin ADC sampling on the given channel
176
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
177 177
   static void adc_start(const pin_t pin);
178 178
 
179 179
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY40_41/HAL.h Ver fichero

@@ -195,7 +195,7 @@ public:
195 195
   // Called by Temperature::init for each sensor at startup
196 196
   static void adc_enable(const pin_t pin) {}
197 197
 
198
-  // Begin ADC sampling on the given channel
198
+  // Begin ADC sampling on the given pin. Called from Temperature::isr!
199 199
   static void adc_start(const pin_t pin);
200 200
 
201 201
   // Is the ADC ready for reading?

+ 4
- 4
Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp Ver fichero

@@ -196,13 +196,13 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
196 196
     #else
197 197
       #define HOTEND_STATS 1
198 198
     #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 };
202 202
   #endif
203 203
 
204 204
   #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;
206 206
     static bool old_bed_on = false;
207 207
     #if HAS_LEVELING
208 208
       static bool old_leveling_on = false;

Loading…
Cancelar
Guardar