File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/modm/platform/adc/stm32f0 Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -316,11 +316,16 @@ public:
316
316
public:
317
317
static constexpr uint8_t TS_CAL1_TEMP{30};
318
318
%% if target.family in ["f0"]
319
- static constexpr uint8_t TS_CAL2_TEMP{110};
320
319
static constexpr uint16_t VDDA_CAL{3300};
321
320
static inline volatile uint16_t *const VREFINT_CAL{(volatile uint16_t *)0x1FFF'F7BA};
322
321
static inline volatile uint16_t *const TS_CAL1{(volatile uint16_t *)0x1FFF'F7B8};
322
+ %% if target.name in ["30", "70"]
323
+ // defined in F030 reference manual
324
+ static constexpr uint16_t TS_AVG_SLOPE{5336};
325
+ %% else
326
+ static constexpr uint8_t TS_CAL2_TEMP{110};
323
327
static inline volatile uint16_t *const TS_CAL2{(volatile uint16_t *)0x1FFF'F7C2};
328
+ %% endif
324
329
%% else
325
330
static constexpr uint8_t TS_CAL2_TEMP{130};
326
331
static constexpr uint16_t VDDA_CAL{3000};
Original file line number Diff line number Diff line change @@ -245,8 +245,13 @@ modm::platform::Adc{{ id }}::readTemperature(uint16_t Vref)
245
245
// Sample time must be at least 5us!!!
246
246
const int32_t TS_DATA = readChannel(Channel::Temperature);
247
247
248
+ %% if target.family == "f0" and target.name in ["30", "70"]
249
+ const int32_t value = (int32_t(*TS_CAL1) - (TS_DATA * Vref / VDDA_CAL)) * 1000;
250
+ return value / TS_AVG_SLOPE + TS_CAL1_TEMP;
251
+ %% else
248
252
const int32_t value = int32_t(TS_CAL2_TEMP - TS_CAL1_TEMP) * (TS_DATA * Vref / VDDA_CAL - *TS_CAL1);
249
253
return value / (*TS_CAL2 - *TS_CAL1) + TS_CAL1_TEMP;
254
+ %% endif
250
255
}
251
256
252
257
uint16_t
You can’t perform that action at this time.
0 commit comments