DIY Logging Volt/Ampmeter
stm32f1xx_it.c
Go to the documentation of this file.
1 /* USER CODE BEGIN Header */
2 /**
3  ******************************************************************************
4  * @file stm32f1xx_it.c
5  * @brief Interrupt Service Routines.
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
10  * All rights reserved.</center></h2>
11  *
12  * This software component is licensed by ST under BSD 3-Clause license,
13  * the "License"; You may not use this file except in compliance with the
14  * License. You may obtain a copy of the License at:
15  * opensource.org/licenses/BSD-3-Clause
16  *
17  ******************************************************************************
18  */
19 /* USER CODE END Header */
20 
21 /* Includes ------------------------------------------------------------------*/
22 #include "main.h"
23 #include "stm32f1xx_it.h"
24 /* Private includes ----------------------------------------------------------*/
25 /* USER CODE BEGIN Includes */
26 
27 #include "usart.h"
28 #include "adc.h"
29 #include "gpio.h"
30 #include "conversion.h"
31 #include "rtc.h"
32 
33 /* USER CODE END Includes */
34 
35 /* Private typedef -----------------------------------------------------------*/
36 /* USER CODE BEGIN TD */
37 
38 /* USER CODE END TD */
39 
40 /* Private define ------------------------------------------------------------*/
41 /* USER CODE BEGIN PD */
42 
43 /* USER CODE END PD */
44 
45 /* Private macro -------------------------------------------------------------*/
46 /* USER CODE BEGIN PM */
47 
48 /* USER CODE END PM */
49 
50 /* Private variables ---------------------------------------------------------*/
51 /* USER CODE BEGIN PV */
52 
53 /* USER CODE END PV */
54 
55 /* Private function prototypes -----------------------------------------------*/
56 /* USER CODE BEGIN PFP */
57 
58 /* USER CODE END PFP */
59 
60 /* Private user code ---------------------------------------------------------*/
61 /* USER CODE BEGIN 0 */
62 
63 /* USER CODE END 0 */
64 
65 /* External variables --------------------------------------------------------*/
66 
67 /* USER CODE BEGIN EV */
68 
69 /* USER CODE END EV */
70 
71 /******************************************************************************/
72 /* Cortex-M3 Processor Interruption and Exception Handlers */
73 /******************************************************************************/
74 /**
75  * @brief This function handles Non maskable interrupt.
76  */
77 void NMI_Handler(void)
78 {
79  /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
80 
81  /* USER CODE END NonMaskableInt_IRQn 0 */
82  /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
83  while (1)
84  {
85  }
86  /* USER CODE END NonMaskableInt_IRQn 1 */
87 }
88 
89 /**
90  * @brief This function handles Hard fault interrupt.
91  */
93 {
94  /* USER CODE BEGIN HardFault_IRQn 0 */
95 
96  /* USER CODE END HardFault_IRQn 0 */
97  while (1)
98  {
99  /* USER CODE BEGIN W1_HardFault_IRQn 0 */
100  /* USER CODE END W1_HardFault_IRQn 0 */
101  }
102 }
103 
104 /**
105  * @brief This function handles Memory management fault.
106  */
108 {
109  /* USER CODE BEGIN MemoryManagement_IRQn 0 */
110 
111  /* USER CODE END MemoryManagement_IRQn 0 */
112  while (1)
113  {
114  /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
115  /* USER CODE END W1_MemoryManagement_IRQn 0 */
116  }
117 }
118 
119 /**
120  * @brief This function handles Prefetch fault, memory access fault.
121  */
123 {
124  /* USER CODE BEGIN BusFault_IRQn 0 */
125 
126  /* USER CODE END BusFault_IRQn 0 */
127  while (1)
128  {
129  /* USER CODE BEGIN W1_BusFault_IRQn 0 */
130  /* USER CODE END W1_BusFault_IRQn 0 */
131  }
132 }
133 
134 /**
135  * @brief This function handles Undefined instruction or illegal state.
136  */
138 {
139  /* USER CODE BEGIN UsageFault_IRQn 0 */
140 
141  /* USER CODE END UsageFault_IRQn 0 */
142  while (1)
143  {
144  /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
145  /* USER CODE END W1_UsageFault_IRQn 0 */
146  }
147 }
148 
149 /**
150  * @brief This function handles System service call via SWI instruction.
151  */
152 void SVC_Handler(void)
153 {
154  /* USER CODE BEGIN SVCall_IRQn 0 */
155 
156  /* USER CODE END SVCall_IRQn 0 */
157  /* USER CODE BEGIN SVCall_IRQn 1 */
158 
159  /* USER CODE END SVCall_IRQn 1 */
160 }
161 
162 /**
163  * @brief This function handles Debug monitor.
164  */
166 {
167  /* USER CODE BEGIN DebugMonitor_IRQn 0 */
168 
169  /* USER CODE END DebugMonitor_IRQn 0 */
170  /* USER CODE BEGIN DebugMonitor_IRQn 1 */
171 
172  /* USER CODE END DebugMonitor_IRQn 1 */
173 }
174 
175 /**
176  * @brief This function handles Pendable request for system service.
177  */
178 void PendSV_Handler(void)
179 {
180  /* USER CODE BEGIN PendSV_IRQn 0 */
181 
182  /* USER CODE END PendSV_IRQn 0 */
183  /* USER CODE BEGIN PendSV_IRQn 1 */
184 
185  /* USER CODE END PendSV_IRQn 1 */
186 }
187 
188 /**
189  * @brief This function handles System tick timer.
190  */
191 void SysTick_Handler(void)
192 {
193  /* USER CODE BEGIN SysTick_IRQn 0 */
194 
195  /* USER CODE END SysTick_IRQn 0 */
196  HAL_IncTick();
197  /* USER CODE BEGIN SysTick_IRQn 1 */
198 
199  /* USER CODE END SysTick_IRQn 1 */
200 }
201 
202 /******************************************************************************/
203 /* STM32F1xx Peripheral Interrupt Handlers */
204 /* Add here the Interrupt Handlers for the used peripherals. */
205 /* For the available peripheral interrupt handler names, */
206 /* please refer to the startup file (startup_stm32f1xx.s). */
207 /******************************************************************************/
208 
209 /**
210  * @brief This function handles RTC global interrupt.
211  */
212 void RTC_IRQHandler(void)
213 {
214  /* USER CODE BEGIN RTC_IRQn 0 */
215 
216  if (LL_RTC_IsEnabledIT_SEC(RTC) != 0)
217  {
218  /* Clear the RTC Second interrupt */
219  LL_RTC_ClearFlag_SEC(RTC);
220 
221  /* Signal interrupt */
222  incSecondPassed();
223 
224  /* Wait until last write operation on RTC registers has finished */
225  LL_RTC_WaitForSynchro(RTC);
226  }
227 
228  /* Clear the EXTI's Flag for RTC Alarm */
229  LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_17);
230 
231  /* USER CODE END RTC_IRQn 0 */
232  /* USER CODE BEGIN RTC_IRQn 1 */
233 
234  /* USER CODE END RTC_IRQn 1 */
235 }
236 
237 /**
238  * @brief This function handles EXTI line0 interrupt.
239  */
241 {
242  /* USER CODE BEGIN EXTI0_IRQn 0 */
243 
244  /* USER CODE END EXTI0_IRQn 0 */
245  if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_0) != RESET)
246  {
247  LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_0);
248  /* USER CODE BEGIN LL_EXTI_LINE_0 */
249 
250  setSW0(1); /* Indicate interrupt trigger */
251 
252  /* USER CODE END LL_EXTI_LINE_0 */
253  }
254  /* USER CODE BEGIN EXTI0_IRQn 1 */
255 
256  /* USER CODE END EXTI0_IRQn 1 */
257 }
258 
259 /**
260  * @brief This function handles EXTI line1 interrupt.
261  */
263 {
264  /* USER CODE BEGIN EXTI1_IRQn 0 */
265 
266  /* USER CODE END EXTI1_IRQn 0 */
267  if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_1) != RESET)
268  {
269  LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_1);
270  /* USER CODE BEGIN LL_EXTI_LINE_1 */
271 
272  setSW1(1); /* Indicate interrupt trigger */
273 
274  /* USER CODE END LL_EXTI_LINE_1 */
275  }
276  /* USER CODE BEGIN EXTI1_IRQn 1 */
277 
278  /* USER CODE END EXTI1_IRQn 1 */
279 }
280 
281 /**
282  * @brief This function handles ADC1 and ADC2 global interrupts.
283  */
285 {
286  /* USER CODE BEGIN ADC1_2_IRQn 0 */
287 
288  /* Check whether ADC group regular end of unitary conversion caused */
289  /* the ADC interruption. */
290  /* Note: On this STM32 serie, there is no flag of group regular */
291  /* end of unitary conversion. Therefore, flag of group regular */
292  /* end of sequence conversions is used (equivalent when there is */
293  /* only 1 rank in group regular sequencer). */
294  if(LL_ADC_IsActiveFlag_EOS(ADC2) != 0)
295  {
296  /* Clear flag ADC group regular end of sequence conversions */
297  LL_ADC_ClearFlag_EOS(ADC2);
298 
299  /* Call interruption treatment function */
301  }
302 
303  /* USER CODE END ADC1_2_IRQn 0 */
304 
305  /* USER CODE BEGIN ADC1_2_IRQn 1 */
306 
307  /* USER CODE END ADC1_2_IRQn 1 */
308 }
309 
310 /**
311  * @brief This function handles EXTI line[9:5] interrupts.
312  */
314 {
315  /* USER CODE BEGIN EXTI9_5_IRQn 0 */
316 
317  /* USER CODE END EXTI9_5_IRQn 0 */
318  if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_5) != RESET)
319  {
320  LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_5);
321  /* USER CODE BEGIN LL_EXTI_LINE_5 */
322 
323  setENCkey(1); /* Indicate interrupt trigger */
324 
325  /* USER CODE END LL_EXTI_LINE_5 */
326  }
327  /* USER CODE BEGIN EXTI9_5_IRQn 1 */
328 
329  /* USER CODE END EXTI9_5_IRQn 1 */
330 }
331 
332 /**
333  * @brief This function handles TIM2 global interrupt.
334  */
335 void TIM2_IRQHandler(void)
336 {
337  /* USER CODE BEGIN TIM2_IRQn 0 */
338 
339  /* Check whether update interrupt is pending */
340  if(LL_TIM_IsActiveFlag_UPDATE(TIM2) == 1)
341  {
342  /* Clear the update interrupt flag*/
343  LL_TIM_ClearFlag_UPDATE(TIM2);
344  }
345 
346  /* TIM2 update interrupt processing */
347  // TODO change to buzzer timing
348 
349  /* USER CODE END TIM2_IRQn 0 */
350  /* USER CODE BEGIN TIM2_IRQn 1 */
351 
352  /* USER CODE END TIM2_IRQn 1 */
353 }
354 
355 /**
356  * @brief This function handles USART1 global interrupt.
357  */
359 {
360  /* USER CODE BEGIN USART1_IRQn 0 */
361 
362  /* Check RXNE flag value in SR register */
363  if(LL_USART_IsActiveFlag_RXNE(USART1) && LL_USART_IsEnabledIT_RXNE(USART1))
364  {
365  /* RXNE flag will be cleared by reading of DR register (done in call) */
366  /* Call function in charge of handling Character reception */
368  }
369  else
370  {
371  /* Call Error function */
373  }
374 
375  /* USER CODE END USART1_IRQn 0 */
376  /* USER CODE BEGIN USART1_IRQn 1 */
377 
378  /* USER CODE END USART1_IRQn 1 */
379 }
380 
381 /**
382  * @brief This function handles USART2 global interrupt.
383  */
385 {
386  /* USER CODE BEGIN USART2_IRQn 0 */
387 
388  /* Check RXNE flag value in SR register */
389  if(LL_USART_IsActiveFlag_RXNE(USART2) && LL_USART_IsEnabledIT_RXNE(USART2))
390  {
391  /* RXNE flag will be cleared by reading of DR register (done in call) */
392  /* Call function in charge of handling Character reception */
394  }
395  else
396  {
397  /* Call Error function */
399  }
400 
401  /* USER CODE END USART2_IRQn 0 */
402  /* USER CODE BEGIN USART2_IRQn 1 */
403 
404  /* USER CODE END USART2_IRQn 1 */
405 }
406 
407 /**
408  * @brief This function handles USART3 global interrupt.
409  */
411 {
412  /* USER CODE BEGIN USART3_IRQn 0 */
413 
414  /* Check RXNE flag value in SR register */
415  if(LL_USART_IsActiveFlag_RXNE(USART3) && LL_USART_IsEnabledIT_RXNE(USART3))
416  {
417  /* RXNE flag will be cleared by reading of DR register (done in call) */
418  /* Call function in charge of handling Character reception */
420  }
421  else
422  {
423  /* Call Error function */
425  }
426 
427  /* USER CODE END USART3_IRQn 0 */
428  /* USER CODE BEGIN USART3_IRQn 1 */
429 
430  /* USER CODE END USART3_IRQn 1 */
431 }
432 
433 /* USER CODE BEGIN 1 */
434 
435 /* USER CODE END 1 */
436 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
MemManage_Handler
void MemManage_Handler(void)
This function handles Memory management fault.
Definition: stm32f1xx_it.c:107
AdcGrpRegularUnitaryConvComplete_Callback
void AdcGrpRegularUnitaryConvComplete_Callback(void)
ADC group regular end of unitary conversion interruption callback.
Definition: adc.c:313
SVC_Handler
void SVC_Handler(void)
This function handles System service call via SWI instruction.
Definition: stm32f1xx_it.c:152
USART2_CharReception_Callback
void USART2_CharReception_Callback(void)
Function called from USART2 IRQ Handler when RXNE flag is set. Function is in charge of reading cha...
Definition: usart.c:697
USART1_IRQHandler
void USART1_IRQHandler(void)
This function handles USART1 global interrupt.
Definition: stm32f1xx_it.c:358
HardFault_Handler
void HardFault_Handler(void)
This function handles Hard fault interrupt.
Definition: stm32f1xx_it.c:92
USART2
#define USART2
Definition: stm32f103xb.h:655
RTC
#define RTC
Definition: stm32f103xb.h:651
SysTick_Handler
void SysTick_Handler(void)
This function handles System tick timer.
Definition: stm32f1xx_it.c:191
USART1_CharReception_Callback
void USART1_CharReception_Callback(void)
Print a string (char array) to USART1.
Definition: usart.c:670
USART3
#define USART3
Definition: stm32f103xb.h:656
EXTI0_IRQHandler
void EXTI0_IRQHandler(void)
This function handles EXTI line0 interrupt.
Definition: stm32f1xx_it.c:240
adc.h
This file contains all the function prototypes for the adc.c file.
EXTI9_5_IRQHandler
void EXTI9_5_IRQHandler(void)
This function handles EXTI line[9:5] interrupts.
Definition: stm32f1xx_it.c:313
setSW1
void setSW1(uint8_t value)
Definition: gpio.c:56
setSW0
void setSW0(uint8_t value)
Definition: gpio.c:46
TIM2
#define TIM2
Definition: stm32f103xb.h:648
NMI_Handler
void NMI_Handler(void)
This function handles Non maskable interrupt.
Definition: stm32f1xx_it.c:77
HAL_IncTick
void HAL_IncTick(void)
usart.h
U(S)ART functionality for high-precision logging voltage/current meter.
RESET
@ RESET
Definition: stm32f1xx.h:153
incSecondPassed
void incSecondPassed(void)
Function to increase the value of secondPassed.
Definition: conversion.c:433
TIM2_IRQHandler
void TIM2_IRQHandler(void)
This function handles TIM2 global interrupt.
Definition: stm32f1xx_it.c:335
DebugMon_Handler
void DebugMon_Handler(void)
This function handles Debug monitor.
Definition: stm32f1xx_it.c:165
UsageFault_Handler
void UsageFault_Handler(void)
This function handles Undefined instruction or illegal state.
Definition: stm32f1xx_it.c:137
conversion.h
Conversion and settings-related methods and structs for high-precision logging voltage/current meter.
stm32f1xx_it.h
This file contains the headers of the interrupt handlers.
USART2_Error_Callback
void USART2_Error_Callback(void)
Function called in case of error detected in USART2 IT Handler.
Definition: usart.c:779
RTC_IRQHandler
void RTC_IRQHandler(void)
This function handles RTC global interrupt.
Definition: stm32f1xx_it.c:212
BusFault_Handler
void BusFault_Handler(void)
This function handles Prefetch fault, memory access fault.
Definition: stm32f1xx_it.c:122
USART1
#define USART1
Definition: stm32f103xb.h:675
main.h
Main header-file for the high-precision logging voltage/current meter project.
gpio.h
This file contains all the function prototypes for the gpio.c file.
PendSV_Handler
void PendSV_Handler(void)
This function handles Pendable request for system service.
Definition: stm32f1xx_it.c:178
ADC1_2_IRQHandler
void ADC1_2_IRQHandler(void)
This function handles ADC1 and ADC2 global interrupts.
Definition: stm32f1xx_it.c:284
ADC2
#define ADC2
Definition: stm32f103xb.h:671
rtc.h
RTC functionality for high-precision logging voltage/current meter.
USART2_IRQHandler
void USART2_IRQHandler(void)
This function handles USART2 global interrupt.
Definition: stm32f1xx_it.c:384
USART3_IRQHandler
void USART3_IRQHandler(void)
This function handles USART3 global interrupt.
Definition: stm32f1xx_it.c:410
USART3_Error_Callback
void USART3_Error_Callback(void)
Function called in case of error detected in USART3 IT Handler.
Definition: usart.c:808
setENCkey
void setENCkey(uint8_t value)
Definition: gpio.c:66
USART3_CharReception_Callback
void USART3_CharReception_Callback(void)
Function called from USART3 IRQ Handler when RXNE flag is set. Function is in charge of reading cha...
Definition: usart.c:724
USART1_Error_Callback
void USART1_Error_Callback(void)
Function called in case of error detected in USART1 IT Handler.
Definition: usart.c:750
EXTI1_IRQHandler
void EXTI1_IRQHandler(void)
This function handles EXTI line1 interrupt.
Definition: stm32f1xx_it.c:262