source: trunk/firmware/Src/stm32g0xx_it.c @ 6

Last change on this file since 6 was 6, checked in by f.jahn, 3 months ago
File size: 6.1 KB
Line 
1/* USER CODE BEGIN Header */
2/**
3  ******************************************************************************
4  * @file    stm32g0xx_it.c
5  * @brief   Interrupt Service Routines.
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; Copyright (c) 2019 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 "stm32g0xx_it.h"
24/* Private includes ----------------------------------------------------------*/
25/* USER CODE BEGIN Includes */
26#include "modbus.h"
27#include "hsi16_calibration.h"
28extern void MODBUS_UART_IRQHandler(UART_HandleTypeDef *huart);
29extern ADC_HandleTypeDef hadc1;
30/* USER CODE END Includes */
31
32/* Private typedef -----------------------------------------------------------*/
33/* USER CODE BEGIN TD */
34
35/* USER CODE END TD */
36
37/* Private define ------------------------------------------------------------*/
38/* USER CODE BEGIN PD */
39
40/* USER CODE END PD */
41
42/* Private macro -------------------------------------------------------------*/
43/* USER CODE BEGIN PM */
44
45/* USER CODE END PM */
46
47/* Private variables ---------------------------------------------------------*/
48/* USER CODE BEGIN PV */
49
50/* USER CODE END PV */
51
52/* Private function prototypes -----------------------------------------------*/
53/* USER CODE BEGIN PFP */
54
55/* USER CODE END PFP */
56
57/* Private user code ---------------------------------------------------------*/
58/* USER CODE BEGIN 0 */
59
60/* USER CODE END 0 */
61
62/* External variables --------------------------------------------------------*/
63extern DMA_HandleTypeDef hdma_adc1;
64extern UART_HandleTypeDef huart1;
65/* USER CODE BEGIN EV */
66extern TIM_HandleTypeDef  TimHandle; /* Timer handler declaration */
67extern modbus_t modbusData;
68/* USER CODE END EV */
69
70/******************************************************************************/
71/*           Cortex-M0+ Processor Interruption and Exception Handlers          */
72/******************************************************************************/
73/**
74  * @brief This function handles Non maskable interrupt.
75  */
76void NMI_Handler(void)
77{
78  /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
79
80  /* USER CODE END NonMaskableInt_IRQn 0 */
81  /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
82
83  /* USER CODE END NonMaskableInt_IRQn 1 */
84}
85
86/**
87  * @brief This function handles Hard fault interrupt.
88  */
89void HardFault_Handler(void)
90{
91  /* USER CODE BEGIN HardFault_IRQn 0 */
92
93  /* USER CODE END HardFault_IRQn 0 */
94  while (1)
95  {
96    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
97    /* USER CODE END W1_HardFault_IRQn 0 */
98  }
99}
100
101/**
102  * @brief This function handles System service call via SWI instruction.
103  */
104void SVC_Handler(void)
105{
106  /* USER CODE BEGIN SVC_IRQn 0 */
107
108  /* USER CODE END SVC_IRQn 0 */
109  /* USER CODE BEGIN SVC_IRQn 1 */
110
111  /* USER CODE END SVC_IRQn 1 */
112}
113
114/**
115  * @brief This function handles Pendable request for system service.
116  */
117void PendSV_Handler(void)
118{
119  /* USER CODE BEGIN PendSV_IRQn 0 */
120
121  /* USER CODE END PendSV_IRQn 0 */
122  /* USER CODE BEGIN PendSV_IRQn 1 */
123
124  /* USER CODE END PendSV_IRQn 1 */
125}
126
127/**
128  * @brief This function handles System tick timer.
129  */
130void SysTick_Handler(void)
131{
132  /* USER CODE BEGIN SysTick_IRQn 0 */
133  static uint32_t ms;
134  /* USER CODE END SysTick_IRQn 0 */
135  HAL_IncTick();
136  /* USER CODE BEGIN SysTick_IRQn 1 */
137  ++ms;
138
139  const uint32_t startupDelay = 20000UL;
140  if (ms >= 1000UL && HAL_GetTick() > startupDelay)
141  {
142          ++sys_data.s.values.lastTimeVbatEmpty;
143          ++sys_data.s.values.lastTimeVbatFull;
144          ms = 0UL;
145  }
146
147  //mbMasterCheckResponseTimeout(&modbus_master_data);
148  /* USER CODE END SysTick_IRQn 1 */
149}
150
151/******************************************************************************/
152/* STM32G0xx Peripheral Interrupt Handlers                                    */
153/* Add here the Interrupt Handlers for the used peripherals.                  */
154/* For the available peripheral interrupt handler names,                      */
155/* please refer to the startup file (startup_stm32g0xx.s).                    */
156/******************************************************************************/
157
158/**
159  * @brief This function handles DMA1 channel 1 interrupt.
160  */
161void DMA_Channel1_IRQHandler(void)
162{
163  /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
164
165  /* USER CODE END DMA1_Channel1_IRQn 0 */
166  HAL_DMA_IRQHandler(&hdma_adc1);
167  /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
168
169  /* USER CODE END DMA1_Channel1_IRQn 1 */
170}
171
172/**
173  * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
174  */
175void USART1_IRQHandler(void)
176{
177  /* USER CODE BEGIN USART1_IRQn 0 */
178
179  /* USER CODE END USART1_IRQn 0 */
180  //HAL_UART_IRQHandler(&huart1);
181  /* USER CODE BEGIN USART1_IRQn 1 */
182  MODBUS_UART_IRQHandler(&huart1);
183  /* USER CODE END USART1_IRQn 1 */
184}
185
186/* USER CODE BEGIN 1 */
187/**
188  * @brief  This function handles external line 4_15 interrupt request.
189  * @param  None
190  * @retval None
191  */
192void EXTI4_15_IRQHandler(void)
193{
194  HAL_GPIO_EXTI_IRQHandler(ADC_DATA_READY_Pin);
195}
196
197/**
198  * @brief  This function handles TIM21 interrupt request.
199  * @param  None
200  * @retval None
201  */
202void TIM16_IRQHandler(void)
203{
204  HAL_TIM_IRQHandler(&TimHandle);
205}
206
207/**
208  * @brief This function handles ADC1 interrupt.
209  */
210void ADC1_IRQHandler(void)
211{
212  /* USER CODE BEGIN ADC1_IRQn 0 */
213
214  /* USER CODE END ADC1_IRQn 0 */
215  HAL_ADC_IRQHandler(&hadc1);
216  /* USER CODE BEGIN ADC1_IRQn 1 */
217
218  /* USER CODE END ADC1_IRQn 1 */
219}
220
221/* USER CODE END 1 */
222/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.