You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_ll_adc.h
+70Lines changed: 70 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -269,6 +269,18 @@ extern "C" {
269
269
/* ADC registers bits positions */
270
270
#defineADC_CR1_RES_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
271
271
#defineADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
272
+
273
+
/* ADC internal channels related definitions */
274
+
/* Internal voltage reference VrefInt */
275
+
#defineVREFINT_CAL_ADDR ((uint16_t*) (0x1FFF7A2AU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
276
+
#defineVREFINT_CAL_VREF ( 3300U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
277
+
/* Temperature sensor */
278
+
#defineTEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FFF7A2CU)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F4, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
279
+
#defineTEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FFF7A2EU)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F4, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
280
+
#defineTEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
281
+
#defineTEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
282
+
#defineTEMPSENSOR_CAL_VREFANALOG ( 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
283
+
272
284
/**
273
285
* @}
274
286
*/
@@ -1654,6 +1666,64 @@ typedef struct
1654
1666
/ __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
1655
1667
)
1656
1668
1669
+
/**
1670
+
* @brief Helper macro to calculate the temperature (unit: degree Celsius)
1671
+
* from ADC conversion data of internal temperature sensor.
1672
+
* @note Computation is using temperature sensor calibration values
1673
+
* stored in system memory for each device during production.
1674
+
* @note Calculation formula:
1675
+
* Temperature = ((TS_ADC_DATA - TS_CAL1)
1676
+
* * (TS_CAL2_TEMP - TS_CAL1_TEMP))
1677
+
* / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
1678
+
* with TS_ADC_DATA = temperature sensor raw data measured by ADC
1679
+
* Avg_Slope = (TS_CAL2 - TS_CAL1)
1680
+
* / (TS_CAL2_TEMP - TS_CAL1_TEMP)
1681
+
* TS_CAL1 = equivalent TS_ADC_DATA at temperature
1682
+
* TEMP_DEGC_CAL1 (calibrated in factory)
1683
+
* TS_CAL2 = equivalent TS_ADC_DATA at temperature
1684
+
* TEMP_DEGC_CAL2 (calibrated in factory)
1685
+
* Caution: Calculation relevancy under reserve that calibration
1686
+
* parameters are correct (address and data).
1687
+
* To calculate temperature using temperature sensor
0 commit comments