/ * @brief * Convert ADC result to degree celsius. * * @details * * @note * See section 2.3.4 in the reference manual for details on this calculatoin * * @param adcResult * Raw value from ADC to be converted to celsius * * @return * The temperature value (signed integer) in degrees celsius times 100 * ***************************************************************************
| 153 | * |
| 154 | ******************************************************************************/ |
| 155 | rt_int32_t efm32_misc_getCelsius(rt_uint32_t adcResult) |
| 156 | { |
| 157 | /* Factory calibration temperature from device information page. */ |
| 158 | rt_int32_t cal_temp = ((DEVINFO->CAL & _DEVINFO_CAL_TEMP_MASK) \ |
| 159 | >> _DEVINFO_CAL_TEMP_SHIFT) * 100; |
| 160 | |
| 161 | /* Factory calibration value from device information page. */ |
| 162 | rt_int32_t cal_value = ((DEVINFO->ADC0CAL2 & _DEVINFO_ADC0CAL2_TEMP1V25_MASK) \ |
| 163 | >> _DEVINFO_ADC0CAL2_TEMP1V25_SHIFT) * 10000; |
| 164 | |
| 165 | /* Temperature gradient (from datasheet) in (ADC unit / degree celsius * 100) */ |
| 166 | rt_int32_t t_grad = -385; |
| 167 | |
| 168 | return (cal_temp - (cal_value - (rt_int32_t)adcResult * 10000) / t_grad); |
| 169 | } |
| 170 | |
| 171 | /******************************************************************************* |
| 172 | * Export to FINSH |