Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
stm32f7xx_it.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
18/* USER CODE END Header */
19
20/* Includes ------------------------------------------------------------------*/
21#include "main.h"
22#include "stm32f7xx_it.h"
23/* Private includes ----------------------------------------------------------*/
24/* USER CODE BEGIN Includes */
25
26/* USER CODE END Includes */
27
28/* Private typedef -----------------------------------------------------------*/
29/* USER CODE BEGIN TD */
30
31/* USER CODE END TD */
32
33/* Private define ------------------------------------------------------------*/
34/* USER CODE BEGIN PD */
35
36/* USER CODE END PD */
37
38/* Private macro -------------------------------------------------------------*/
39/* USER CODE BEGIN PM */
40
41/* USER CODE END PM */
42
43/* Private variables ---------------------------------------------------------*/
44/* USER CODE BEGIN PV */
45// Receive message buffers
46CAN_RxHeaderTypeDef RxHeader1;
47CAN_RxHeaderTypeDef RxHeader2;
48uint8_t RxData1[8];
49uint8_t RxData2[8];
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 DMA_HandleTypeDef hdma_adc2;
65extern DMA_HandleTypeDef hdma_adc3;
66extern CAN_HandleTypeDef hcan1;
67extern CAN_HandleTypeDef hcan2;
68/* USER CODE BEGIN EV */
69
70/* USER CODE END EV */
71
72/******************************************************************************/
73/* Cortex-M7 Processor Interruption and Exception Handlers */
74/******************************************************************************/
78void NMI_Handler(void)
79{
80 /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
81
82 /* USER CODE END NonMaskableInt_IRQn 0 */
83 /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
84 while (1)
85 {
86 }
87 /* USER CODE END NonMaskableInt_IRQn 1 */
88}
89
94{
95 /* USER CODE BEGIN HardFault_IRQn 0 */
96
97 /* USER CODE END HardFault_IRQn 0 */
98 while (1)
99 {
100 /* USER CODE BEGIN W1_HardFault_IRQn 0 */
101 /* USER CODE END W1_HardFault_IRQn 0 */
102 }
103}
104
109{
110 /* USER CODE BEGIN MemoryManagement_IRQn 0 */
111
112 /* USER CODE END MemoryManagement_IRQn 0 */
113 while (1)
114 {
115 /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
116 /* USER CODE END W1_MemoryManagement_IRQn 0 */
117 }
118}
119
124{
125 /* USER CODE BEGIN BusFault_IRQn 0 */
126
127 /* USER CODE END BusFault_IRQn 0 */
128 while (1)
129 {
130 /* USER CODE BEGIN W1_BusFault_IRQn 0 */
131 /* USER CODE END W1_BusFault_IRQn 0 */
132 }
133}
134
139{
140 /* USER CODE BEGIN UsageFault_IRQn 0 */
141
142 /* USER CODE END UsageFault_IRQn 0 */
143 while (1)
144 {
145 /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
146 /* USER CODE END W1_UsageFault_IRQn 0 */
147 }
148}
149
153void SVC_Handler(void)
154{
155 /* USER CODE BEGIN SVCall_IRQn 0 */
156
157 /* USER CODE END SVCall_IRQn 0 */
158 /* USER CODE BEGIN SVCall_IRQn 1 */
159
160 /* USER CODE END SVCall_IRQn 1 */
161}
162
167{
168 /* USER CODE BEGIN DebugMonitor_IRQn 0 */
169
170 /* USER CODE END DebugMonitor_IRQn 0 */
171 /* USER CODE BEGIN DebugMonitor_IRQn 1 */
172
173 /* USER CODE END DebugMonitor_IRQn 1 */
174}
175
180{
181 /* USER CODE BEGIN PendSV_IRQn 0 */
182
183 /* USER CODE END PendSV_IRQn 0 */
184 /* USER CODE BEGIN PendSV_IRQn 1 */
185
186 /* USER CODE END PendSV_IRQn 1 */
187}
188
193{
194 /* USER CODE BEGIN SysTick_IRQn 0 */
195
196 /* USER CODE END SysTick_IRQn 0 */
197 HAL_IncTick();
198 /* USER CODE BEGIN SysTick_IRQn 1 */
199
200 /* USER CODE END SysTick_IRQn 1 */
201}
202
203/******************************************************************************/
204/* STM32F7xx Peripheral Interrupt Handlers */
205/* Add here the Interrupt Handlers for the used peripherals. */
206/* For the available peripheral interrupt handler names, */
207/* please refer to the startup file (startup_stm32f7xx.s). */
208/******************************************************************************/
209
214{
215 /* USER CODE BEGIN CAN1_RX0_IRQn 0 */
216
217 /* USER CODE END CAN1_RX0_IRQn 0 */
218 HAL_CAN_IRQHandler(&hcan1);
219 /* USER CODE BEGIN CAN1_RX0_IRQn 1 */
220
221 /* USER CODE END CAN1_RX0_IRQn 1 */
222}
223
228{
229 /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */
230
231 /* USER CODE END DMA2_Stream0_IRQn 0 */
232 HAL_DMA_IRQHandler(&hdma_adc1);
233 /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */
234
235 /* USER CODE END DMA2_Stream0_IRQn 1 */
236}
237
242{
243 /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */
244
245 /* USER CODE END DMA2_Stream1_IRQn 0 */
246 HAL_DMA_IRQHandler(&hdma_adc3);
247 /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */
248
249 /* USER CODE END DMA2_Stream1_IRQn 1 */
250}
251
256{
257 /* USER CODE BEGIN DMA2_Stream2_IRQn 0 */
258
259 /* USER CODE END DMA2_Stream2_IRQn 0 */
260 HAL_DMA_IRQHandler(&hdma_adc2);
261 /* USER CODE BEGIN DMA2_Stream2_IRQn 1 */
262
263 /* USER CODE END DMA2_Stream2_IRQn 1 */
264}
265
270{
271 /* USER CODE BEGIN CAN2_RX0_IRQn 0 */
272
273 /* USER CODE END CAN2_RX0_IRQn 0 */
274 HAL_CAN_IRQHandler(&hcan2);
275 /* USER CODE BEGIN CAN2_RX0_IRQn 1 */
276
277 /* USER CODE END CAN2_RX0_IRQn 1 */
278}
279
280/* USER CODE BEGIN 1 */
281volatile uint32_t timer_flag = 0;
282
283void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
284{
285 if (htim->Instance == TIM1)
286 {
287 timer_flag++;
288 }
289}
290
291// Polling for sending CAN messages
292int send_CAN_message_helper(CANBus bus, CAN_TxHeaderTypeDef *TxHeader, uint8_t *data)
293{
294 uint32_t mailbox;
295 if (bus == CAN_1) {
296 if (HAL_CAN_AddTxMessage(&hcan1, TxHeader, data, &mailbox) != HAL_OK) {
297 uint32_t error = HAL_CAN_GetError(&hcan1);
298 printf("CAN Transmission Error: %lx\n", error);
299 return -1;
300 }
301 } else if (bus == CAN_2) {
302 if (HAL_CAN_AddTxMessage(&hcan2, TxHeader, data, &mailbox) != HAL_OK) {
303 uint32_t error = HAL_CAN_GetError(&hcan2);
304 printf("CAN Transmission Error: %lx\n", error);
305 return -1;
306 }
307 } else {
308 return -1;
309 }
310 return 0;
311}
312
313// Callback for receiving CAN messages
314void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
315{
316 if (hcan == &hcan1) {
317 HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader1, RxData1);
319 } else if (hcan == &hcan2) {
320 HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader2, RxData2);
322 }
323}
324/* USER CODE END 1 */
CANBus
Definition: Can.h:98
@ CAN_1
Definition: Can.h:99
@ CAN_2
Definition: Can.h:100
void receive_CAN_message(CAN_RxHeaderTypeDef *header, uint8_t *data, CANBus bus)
Receives a CAN message.
Definition: Can.c:112
: Header for main.c file. This file contains the common defines of the application.
uint8_t RxData1[8]
Definition: stm32f7xx_it.c:48
CAN_HandleTypeDef hcan1
Definition: main.c:51
volatile uint32_t timer_flag
Definition: stm32f7xx_it.c:281
DMA_HandleTypeDef hdma_adc1
Definition: main.c:47
void UsageFault_Handler(void)
This function handles Undefined instruction or illegal state.
Definition: stm32f7xx_it.c:138
int send_CAN_message_helper(CANBus bus, CAN_TxHeaderTypeDef *TxHeader, uint8_t *data)
Definition: stm32f7xx_it.c:292
void HardFault_Handler(void)
This function handles Hard fault interrupt.
Definition: stm32f7xx_it.c:93
uint8_t RxData2[8]
Definition: stm32f7xx_it.c:49
void MemManage_Handler(void)
This function handles Memory management fault.
Definition: stm32f7xx_it.c:108
DMA_HandleTypeDef hdma_adc3
Definition: AnalogSensor.h:46
void SVC_Handler(void)
This function handles System service call via SWI instruction.
Definition: stm32f7xx_it.c:153
void CAN1_RX0_IRQHandler(void)
This function handles CAN1 RX0 interrupts.
Definition: stm32f7xx_it.c:213
void PendSV_Handler(void)
This function handles Pendable request for system service.
Definition: stm32f7xx_it.c:179
void NMI_Handler(void)
This function handles Non maskable interrupt.
Definition: stm32f7xx_it.c:78
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
Definition: stm32f7xx_it.c:314
CAN_RxHeaderTypeDef RxHeader1
Definition: stm32f7xx_it.c:46
void DMA2_Stream2_IRQHandler(void)
This function handles DMA2 stream2 global interrupt.
Definition: stm32f7xx_it.c:255
void BusFault_Handler(void)
This function handles Pre-fetch fault, memory access fault.
Definition: stm32f7xx_it.c:123
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
Definition: stm32f7xx_it.c:283
CAN_RxHeaderTypeDef RxHeader2
Definition: stm32f7xx_it.c:47
void DMA2_Stream0_IRQHandler(void)
This function handles DMA2 stream0 global interrupt.
Definition: stm32f7xx_it.c:227
void SysTick_Handler(void)
This function handles System tick timer.
Definition: stm32f7xx_it.c:192
CAN_HandleTypeDef hcan2
Definition: main.c:52
void CAN2_RX0_IRQHandler(void)
This function handles CAN2 RX0 interrupts.
Definition: stm32f7xx_it.c:269
DMA_HandleTypeDef hdma_adc2
Definition: AnalogSensor.h:46
void DMA2_Stream1_IRQHandler(void)
This function handles DMA2 stream1 global interrupt.
Definition: stm32f7xx_it.c:241
void DebugMon_Handler(void)
This function handles Debug monitor.
Definition: stm32f7xx_it.c:166
This file contains the headers of the interrupt handlers.