aboutsummaryrefslogtreecommitdiffstats
path: root/src/temperature/temperature.c
blob: b9e95e24e754971024738b517618f0c7e4aea236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "stm32f4xx_conf.h"

#include "temperature.h"

float temperature_value = 0;

void temperature_update() {
    ADC_SoftwareStartConv(ADC1); //Start the conversion

    while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);

    temperature_value = ((ADC_GetConversionValue(ADC1) * TEMP_V_BOARD / 0xFFF) - TEMP_V25) / TEMP_AVG_SLOPE + 25.0;
}

float temperature_get() {
    return temperature_value;
}