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

Last change on this file since 26 was 26, checked in by f.jahn, 7 weeks ago
  • Bug in ADC Kalibrierung (STM32 ADC Strom) behoben
  • DMA Buffer für ADC 1 und ADC wird vor Überschreibung während bearbeitung geschützt, indem Datenübertragung nur einmalig erfolgt und erst nach Auswertung wieder gestartet wird
  • RS485Modbus: Timeout Zeit wird für Baudraten >19200 korrekt berechnet
  • Hardware ID geändert
  • Separates Register für "Batterie Empty detection mode" auf Adresse 92 angelegt
File size: 6.2 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  static volatile uint32_t cont=0;
93
94  /* USER CODE END HardFault_IRQn 0 */
95  while (cont == 0)
96  {
97    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
98    /* USER CODE END W1_HardFault_IRQn 0 */
99  }
100}
101
102/**
103  * @brief This function handles System service call via SWI instruction.
104  */
105void SVC_Handler(void)
106{
107  /* USER CODE BEGIN SVC_IRQn 0 */
108
109  /* USER CODE END SVC_IRQn 0 */
110  /* USER CODE BEGIN SVC_IRQn 1 */
111
112  /* USER CODE END SVC_IRQn 1 */
113}
114
115/**
116  * @brief This function handles Pendable request for system service.
117  */
118void PendSV_Handler(void)
119{
120  /* USER CODE BEGIN PendSV_IRQn 0 */
121
122  /* USER CODE END PendSV_IRQn 0 */
123  /* USER CODE BEGIN PendSV_IRQn 1 */
124
125  /* USER CODE END PendSV_IRQn 1 */
126}
127
128/**
129  * @brief This function handles System tick timer.
130  */
131void SysTick_Handler(void)
132{
133  /* USER CODE BEGIN SysTick_IRQn 0 */
134  static uint32_t ms;
135  /* USER CODE END SysTick_IRQn 0 */
136  HAL_IncTick();
137  /* USER CODE BEGIN SysTick_IRQn 1 */
138  ++ms;
139
140  const uint32_t startupDelay = 20000UL;
141  if (ms >= 1000UL && HAL_GetTick() > startupDelay)
142  {
143          ++sys_data.s.values.lastTimeVbatEmpty;
144          ++sys_data.s.values.lastTimeVbatFull;
145          ms = 0UL;
146  }
147
148  //mbMasterCheckResponseTimeout(&modbus_master_data);
149  /* USER CODE END SysTick_IRQn 1 */
150}
151
152/******************************************************************************/
153/* STM32G0xx Peripheral Interrupt Handlers                                    */
154/* Add here the Interrupt Handlers for the used peripherals.                  */
155/* For the available peripheral interrupt handler names,                      */
156/* please refer to the startup file (startup_stm32g0xx.s).                    */
157/******************************************************************************/
158
159/**
160  * @brief This function handles DMA1 channel 1 interrupt.
161  */
162void DMA_Channel1_IRQHandler(void)
163{
164  /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
165
166  /* USER CODE END DMA1_Channel1_IRQn 0 */
167  HAL_DMA_IRQHandler(&hdma_adc1);
168  /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
169
170  /* USER CODE END DMA1_Channel1_IRQn 1 */
171}
172
173/**
174  * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
175  */
176void USART1_IRQHandler(void)
177{
178  /* USER CODE BEGIN USART1_IRQn 0 */
179
180  /* USER CODE END USART1_IRQn 0 */
181  //HAL_UART_IRQHandler(&huart1);
182  /* USER CODE BEGIN USART1_IRQn 1 */
183  MODBUS_UART_IRQHandler(&huart1);
184  /* USER CODE END USART1_IRQn 1 */
185}
186
187/* USER CODE BEGIN 1 */
188/**
189  * @brief  This function handles external line 4_15 interrupt request.
190  * @param  None
191  * @retval None
192  */
193void EXTI4_15_IRQHandler(void)
194{
195  HAL_GPIO_EXTI_IRQHandler(ADC_DATA_READY_Pin);
196}
197
198/**
199  * @brief  This function handles TIM21 interrupt request.
200  * @param  None
201  * @retval None
202  */
203void TIM16_IRQHandler(void)
204{
205  HAL_TIM_IRQHandler(&TimHandle);
206}
207
208/**
209  * @brief This function handles ADC1 interrupt.
210  */
211void ADC1_IRQHandler(void)
212{
213  /* USER CODE BEGIN ADC1_IRQn 0 */
214
215  /* USER CODE END ADC1_IRQn 0 */
216  HAL_ADC_IRQHandler(&hadc1);
217  /* USER CODE BEGIN ADC1_IRQn 1 */
218
219  /* USER CODE END ADC1_IRQn 1 */
220}
221
222/* USER CODE END 1 */
223/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.