FSM thermostat
port_temp_sensor.c File Reference

Port layer for a temperature sensor. More...

#include <stdint.h>
#include <stdio.h>
#include "port_temp_sensor.h"
#include "stm32f4xx.h"
#include "port_system.h"

Go to the source code of this file.

Functions

uint32_t _adc_to_mvolts (uint32_t adcValue, uint8_t adc_res_bits)
 Converts an ADC value to millivolts. More...
 
double port_temp_sensor_get_temperature (port_temp_hw_t *p_temp)
 Gets the temperature in Celsius of the temperature sensor. More...
 
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. More...
 
void port_temp_sensor_init (port_temp_hw_t *p_temp)
 Initializes the temperature sensor. More...
 

Variables

port_temp_hw_t temp_sensor_thermostat = {.p_port = TEMP_SENSOR_THERMOSTAT_GPIO, .pin = TEMP_SENSOR_THERMOSTAT_PIN, .p_adc = TEMP_SENSOR_THERMOSTAT_ADC, .adc_channel = TEMP_SENSOR_THERMOSTAT_ADC_CHANNEL, .temperature_celsius = 0}
 

Detailed Description

Port layer for a temperature sensor.

Author
Josué Pagán (j.pag.nosp@m.an@u.nosp@m.pm.es)
Version
0.1
Date
2024-05-01

Definition in file port_temp_sensor.c.

Function Documentation

◆ _adc_to_mvolts()

uint32_t _adc_to_mvolts ( uint32_t  adcValue,
uint8_t  adc_res_bits 
)

Converts an ADC value to millivolts.

Parameters
adcValueCounts of the ADC
adc_res_bitsResolution of the ADC in bits
Returns
uint32_t Millivolts

Definition at line 31 of file port_temp_sensor.c.

◆ port_temp_sensor_get_temperature()

double port_temp_sensor_get_temperature ( port_temp_hw_t pir_sensor)

Gets the temperature in Celsius of the temperature sensor.

Returns
double Temperature in Celsius.

Definition at line 37 of file port_temp_sensor.c.

◆ port_temp_sensor_init()

void port_temp_sensor_init ( port_temp_hw_t pir_sensor)

Initializes the temperature sensor.

Parameters
pir_sensorPointer to the temperature sensor structure.

Definition at line 52 of file port_temp_sensor.c.

◆ port_temp_sensor_save_adc_value()

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.

Parameters
p_tempPointer to the temperature sensor structure.
adc_valueADC value of the temperature sensor.

Definition at line 42 of file port_temp_sensor.c.

Variable Documentation

◆ temp_sensor_thermostat

port_temp_hw_t temp_sensor_thermostat = {.p_port = TEMP_SENSOR_THERMOSTAT_GPIO, .pin = TEMP_SENSOR_THERMOSTAT_PIN, .p_adc = TEMP_SENSOR_THERMOSTAT_ADC, .adc_channel = TEMP_SENSOR_THERMOSTAT_ADC_CHANNEL, .temperature_celsius = 0}

Temperature sensor of the thermostat system. Public for access to interrupt handlers.

Definition at line 20 of file port_temp_sensor.c.