Go to the documentation of this file.
16 #include "stm32f4xx.h"
33 uint32_t mvolts = (
ADC_VREF_MV * adcValue) / ((1 << adc_res_bits) - 1);
double port_temp_sensor_get_temperature(port_temp_hw_t *p_temp)
Gets the temperature in Celsius of the temperature sensor.
#define TEMP_SENSOR_THERMOSTAT_PIN
double temperature_celsius
#define GPIO_PUPDR_NOPULL
void port_system_adc_enable(ADC_TypeDef *p_adc)
Enable the ADC peripheral to work.
port_temp_hw_t temp_sensor_thermostat
#define TEMP_SENSOR_THERMOSTAT_ADC
void port_system_adc_interrupt_enable(uint8_t priority, uint8_t subpriority)
Enable the ADC global interrupts in NVIC. ADC1, ADC2, and ADC3 share the same interrupt.
Header file for the temperature sensor port layer.
#define ADC_RESOLUTION_12B
void port_system_adc_single_ch_init(ADC_TypeDef *p_adc, uint8_t channel, uint32_t cr_mode)
Configure the ADC peripheral for a single channel.
void port_temp_sensor_save_adc_value(port_temp_hw_t *p_temp, double adc_value)
Saves the ADC value of the temperature sensor and converts it to Celsius.
uint32_t _adc_to_mvolts(uint32_t adcValue, uint8_t adc_res_bits)
Converts an ADC value to millivolts.
Header for port_system.c file.
Structure to define the HW dependencies of a temperature sensor.
void port_system_gpio_config(GPIO_TypeDef *p_port, uint8_t pin, uint8_t mode, uint8_t pupd)
Configure the mode and pull of a GPIO.
#define TEMP_SENSOR_THERMOSTAT_GPIO
void port_temp_sensor_init(port_temp_hw_t *p_temp)
Initializes the temperature sensor.
#define ADC_EOC_INTERRUPT_ENABLE
#define TEMP_SENSOR_THERMOSTAT_ADC_CHANNEL