Add defines for safety adc conversions

This commit is contained in:
Mario Hüttel 2020-06-01 20:53:28 +02:00
parent f956968cb4
commit 5819a0736c
2 changed files with 10 additions and 2 deletions

View File

@ -28,4 +28,11 @@
#define TEMP_CHANNEL_NUM (16)
#define INT_REF_CHANNEL_NUM (17)
#define SAFETY_ADC_INT_REF_MV 1210.0f
#define SAFETY_ADC_TEMP_NOM 25.0f
#define SAFETY_ADC_TEMP_NOM_MV 760.0f
#define SAFETY_ADC_TEMP_MV_SLOPE 2.5f
#endif /* __SAFETY_ADC_HWCFG_H__ */

View File

@ -53,11 +53,12 @@ enum safety_adc_check_result safety_adc_check_results(uint16_t vref_result, uint
if (vref_calculated) {
*vref_calculated = (1210.0 * 4095) / (float)vref_result;
*vref_calculated = (SAFETY_ADC_INT_REF_MV * 4095.0f) / (float)vref_result;
}
if (temp_calculated) {
*temp_calculated = (((float)temp_result / 4095.0f * 2500.0f - 760.0f) / 2.5f) + 25.0f;
*temp_calculated = (((float)temp_result / 4095.0f * 2500.0f -
SAFETY_ADC_TEMP_NOM_MV) / SAFETY_ADC_TEMP_MV_SLOPE) + SAFETY_ADC_TEMP_NOM;
}
return res;