FSM thermostat
interr.c
Go to the documentation of this file.
1 
7 // Include headers of different port elements:
8 #include "stm32f4xx.h"
9 #include "port_system.h"
10 #include "port_led.h"
11 #include "port_temp_sensor.h"
12 
13 //------------------------------------------------------
14 // INTERRUPT SERVICE ROUTINES
15 //------------------------------------------------------
26 void SysTick_Handler(void)
27 {
29 }
30 
37 void TIM2_IRQHandler(void)
38 {
39  // Start the ADC conversion
41 
42  TIM2->SR &= ~TIM_SR_UIF; // Clear the update interrupt flag
43 }
44 
51 void ADC_IRQHandler(void)
52 {
53  // Identify if the ADC that generated the interrupt is the same as the temperature sensor
54  if (temp_sensor_thermostat.p_adc->SR & ADC_SR_EOC)
55  {
56  // Read the temperature sensor value
58 
59  // Clear the ADC interrupt flag
60  temp_sensor_thermostat.p_adc->SR &= ~ADC_SR_EOC;
61  }
62 }
port_system_set_millis
void port_system_set_millis(uint32_t ms)
Sets the number of milliseconds since the system started.
Definition: port_system.c:130
port_system_adc_start_conversion
void port_system_adc_start_conversion(ADC_TypeDef *p_adc, uint8_t channel)
Start the conversion of the ADC peripheral.
Definition: port_system.c:374
port_temp_sensor.h
Header file for the temperature sensor port layer.
port_led.h
Header file for the LED port layer.
ADC_IRQHandler
void ADC_IRQHandler(void)
Interrupt service routine for all the ADCs.
Definition: interr.c:51
port_system_get_millis
uint32_t port_system_get_millis(void)
Get the count of the System tick in milliseconds.
Definition: port_system.c:125
port_system.h
Header for port_system.c file.
port_temp_hw_t::p_adc
ADC_TypeDef * p_adc
Definition: port_temp_sensor.h:35
SysTick_Handler
void SysTick_Handler(void)
Interrupt service routine for the System tick timer (SysTick).
Definition: interr.c:26
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.
Definition: port_temp_sensor.c:42
TIM2_IRQHandler
void TIM2_IRQHandler(void)
Interrupt service routine for the TIM2 timer.
Definition: interr.c:37
port_temp_hw_t::pin
uint8_t pin
Definition: port_temp_sensor.h:34
temp_sensor_thermostat
port_temp_hw_t temp_sensor_thermostat
Definition: port_temp_sensor.c:20