Просмотр исходного кода

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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
John Robertson 3 лет назад
Родитель
Сommit
f7fff4d455
Аккаунт пользователя с таким Email не найден

+ 1
- 1
Marlin/src/HAL/AVR/HAL.h Просмотреть файл

229
     SBI(DIDR0, ch);
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
   static void adc_start(const uint8_t ch) {
233
   static void adc_start(const uint8_t ch) {
234
     #ifdef MUX5
234
     #ifdef MUX5
235
       ADCSRB = ch > 7 ? _BV(MUX5) : 0;
235
       ADCSRB = ch > 7 ? _BV(MUX5) : 0;

+ 1
- 1
Marlin/src/HAL/DUE/HAL.h Просмотреть файл

209
   // Called by Temperature::init for each sensor at startup
209
   // Called by Temperature::init for each sensor at startup
210
   static void adc_enable(const uint8_t ch) {}
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
   static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }
213
   static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }
214
 
214
 
215
   // Is the ADC ready for reading?
215
   // Is the ADC ready for reading?

+ 2
- 1
Marlin/src/HAL/ESP32/HAL.cpp Просмотреть файл

244
   const adc1_channel_t chan = get_channel(pin);
244
   const adc1_channel_t chan = get_channel(pin);
245
   uint32_t mv;
245
   uint32_t mv;
246
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
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
   // Change the attenuation level based on the new reading
250
   // Change the attenuation level based on the new reading
250
   adc_atten_t atten;
251
   adc_atten_t atten;

+ 2
- 1
Marlin/src/HAL/ESP32/HAL.h Просмотреть файл

74
 // Types
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
 typedef int16_t pin_t;
78
 typedef int16_t pin_t;
78
 
79
 
79
 class Servo;
80
 class Servo;
205
   // Called by Temperature::init for each sensor at startup
206
   // Called by Temperature::init for each sensor at startup
206
   static void adc_enable(const pin_t pin) {}
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
   static void adc_start(const pin_t pin);
210
   static void adc_start(const pin_t pin);
210
 
211
 
211
   // Is the ADC ready for reading?
212
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/LPC1768/HAL.h Просмотреть файл

234
     FilteredADC::enable_channel(pin);
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
   static uint32_t adc_result;
238
   static uint32_t adc_result;
239
   static void adc_start(const pin_t pin) {
239
   static void adc_start(const pin_t pin) {
240
     adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
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 Просмотреть файл

242
   // Called by Temperature::init for each sensor at startup
242
   // Called by Temperature::init for each sensor at startup
243
   static void adc_enable(const uint8_t ch);
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
   static void adc_start(const uint8_t ch);
246
   static void adc_start(const uint8_t ch);
247
 
247
 
248
   // Is the ADC ready for reading?
248
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/SAMD51/HAL.h Просмотреть файл

190
   // Called by Temperature::init for each sensor at startup
190
   // Called by Temperature::init for each sensor at startup
191
   static void adc_enable(const uint8_t ch) {}
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
   static void adc_start(const pin_t pin);
194
   static void adc_start(const pin_t pin);
195
 
195
 
196
   // Is the ADC ready for reading?
196
   // Is the ADC ready for reading?

+ 3
- 1
Marlin/src/HAL/STM32/HAL.h Просмотреть файл

127
 // Types
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
 #ifdef STM32G0B1xx
132
 #ifdef STM32G0B1xx
131
   typedef int32_t pin_t;
133
   typedef int32_t pin_t;
132
 #else
134
 #else
241
   // Called by Temperature::init for each sensor at startup
243
   // Called by Temperature::init for each sensor at startup
242
   static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); }
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
   static void adc_start(const pin_t pin) { adc_result = analogRead(pin); }
247
   static void adc_start(const pin_t pin) { adc_result = analogRead(pin); }
246
 
248
 
247
   // Is the ADC ready for reading?
249
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/STM32F1/HAL.h Просмотреть файл

280
   // Called by Temperature::init for each sensor at startup
280
   // Called by Temperature::init for each sensor at startup
281
   static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); }
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
   static void adc_start(const pin_t pin);
284
   static void adc_start(const pin_t pin);
285
 
285
 
286
   // Is the ADC ready for reading?
286
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY31_32/HAL.h Просмотреть файл

166
   // Called by Temperature::init for each sensor at startup
166
   // Called by Temperature::init for each sensor at startup
167
   static void adc_enable(const pin_t ch) {}
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
   static void adc_start(const pin_t ch);
170
   static void adc_start(const pin_t ch);
171
 
171
 
172
   // Is the ADC ready for reading?
172
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY35_36/HAL.h Просмотреть файл

173
   // Called by Temperature::init for each sensor at startup
173
   // Called by Temperature::init for each sensor at startup
174
   static void adc_enable(const pin_t) {}
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
   static void adc_start(const pin_t pin);
177
   static void adc_start(const pin_t pin);
178
 
178
 
179
   // Is the ADC ready for reading?
179
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/TEENSY40_41/HAL.h Просмотреть файл

195
   // Called by Temperature::init for each sensor at startup
195
   // Called by Temperature::init for each sensor at startup
196
   static void adc_enable(const pin_t pin) {}
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
   static void adc_start(const pin_t pin);
199
   static void adc_start(const pin_t pin);
200
 
200
 
201
   // Is the ADC ready for reading?
201
   // Is the ADC ready for reading?

+ 4
- 4
Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp Просмотреть файл

196
     #else
196
     #else
197
       #define HOTEND_STATS 1
197
       #define HOTEND_STATS 1
198
     #endif
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
   #endif
202
   #endif
203
 
203
 
204
   #if HAS_HEATED_BED
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
     static bool old_bed_on = false;
206
     static bool old_bed_on = false;
207
     #if HAS_LEVELING
207
     #if HAS_LEVELING
208
       static bool old_leveling_on = false;
208
       static bool old_leveling_on = false;

Загрузка…
Отмена
Сохранить