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:
316316public:
317317 static constexpr uint8_t TS_CAL1_TEMP{30};
318318%% if target.family in ["f0"]
319- static constexpr uint8_t TS_CAL2_TEMP{110};
320319 static constexpr uint16_t VDDA_CAL{3300};
321320 static inline volatile uint16_t *const VREFINT_CAL{(volatile uint16_t *)0x1FFF'F7BA};
322321 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};
323327 static inline volatile uint16_t *const TS_CAL2{(volatile uint16_t *)0x1FFF'F7C2};
328+ %% endif
324329%% else
325330 static constexpr uint8_t TS_CAL2_TEMP{130};
326331 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)
245245 // Sample time must be at least 5us!!!
246246 const int32_t TS_DATA = readChannel(Channel::Temperature);
247247
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
248252 const int32_t value = int32_t(TS_CAL2_TEMP - TS_CAL1_TEMP) * (TS_DATA * Vref / VDDA_CAL - *TS_CAL1);
249253 return value / (*TS_CAL2 - *TS_CAL1) + TS_CAL1_TEMP;
254+ %% endif
250255}
251256
252257uint16_t
You can’t perform that action at this time.
0 commit comments