Rev 13 | Rev 15 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 13 | Rev 14 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | /* Includes ------------------------------------------------------------------*/ |
19 | /* Includes ------------------------------------------------------------------*/ |
20 | #include "main.h" |
20 | #include "main.h" |
21 | 21 | ||
22 | /* Private includes ----------------------------------------------------------*/ |
22 | /* Private includes ----------------------------------------------------------*/ |
23 | /* USER CODE BEGIN Includes */ |
23 | /* USER CODE BEGIN Includes */ |
- | 24 | #include "memory.h" |
|
24 | #include "display.h" |
25 | #include "display.h" |
25 | #include "bmp280driver.h" |
26 | #include "bmp280driver.h" |
26 | #include "libMisc/fixI2C.h" |
27 | #include "libMisc/fixI2C.h" |
27 | #include "libPlx/plx.h" |
28 | #include "libPlx/plx.h" |
28 | #include "libSerial/serial.h" |
29 | #include "libSerial/serial.h" |
Line 44... | Line 45... | ||
44 | /* USER CODE BEGIN PM */ |
45 | /* USER CODE BEGIN PM */ |
45 | 46 | ||
46 | /* USER CODE END PM */ |
47 | /* USER CODE END PM */ |
47 | 48 | ||
48 | /* Private variables ---------------------------------------------------------*/ |
49 | /* Private variables ---------------------------------------------------------*/ |
49 | CAN_HandleTypeDef hcan; |
50 | CAN_HandleTypeDef hcan; |
50 | 51 | ||
51 | I2C_HandleTypeDef hi2c1; |
52 | I2C_HandleTypeDef hi2c1; |
52 | 53 | ||
53 | IWDG_HandleTypeDef hiwdg; |
54 | IWDG_HandleTypeDef hiwdg; |
54 | 55 | ||
Line 60... | Line 61... | ||
60 | 61 | ||
61 | UART_HandleTypeDef huart2; |
62 | UART_HandleTypeDef huart2; |
62 | 63 | ||
63 | /* USER CODE BEGIN PV */ |
64 | /* USER CODE BEGIN PV */ |
64 | int const T100MS = 100; |
65 | int const T100MS = 100; |
65 | // index for our MAP value (there is maybe another in the system) |
66 | // index for all observations |
66 | char ourMAPindex = 0; |
67 | char obsIndex[PLX_MAX_OBS]; |
67 | 68 | ||
- | 69 | int const DISPLAY_REINITIALISE = 60 * 1000; |
|
68 | // compensated pressure in mb * 100 |
70 | // compensated pressure in mb * 100 |
69 | uint32_t comp_pres = 0; |
71 | uint32_t comp_pres = 0; |
70 | // compensated temperature |
72 | // compensated temperature |
71 | int32_t comp_temp = -10000; |
73 | int32_t comp_temp = -10000; |
72 | 74 | ||
Line 95... | Line 97... | ||
95 | 97 | ||
96 | void processObservations() |
98 | void processObservations() |
97 | { |
99 | { |
98 | // send MAP |
100 | // send MAP |
99 | PLX_SensorInfo info; |
101 | PLX_SensorInfo info; |
100 | ConvToPLXInstance(ourMAPindex, &info); |
102 | ConvToPLXInstance(obsIndex[PLX_MAP]++, &info); |
101 | ConvToPLXAddr(PLX_MAP, &info); |
103 | ConvToPLXAddr(PLX_MAP, &info); |
102 | ConvToPLXReading(ConveriMFDData2Raw(PLX_MAP, PRESSURE_kPa, comp_pres / 1000.0), &info); |
104 | ConvToPLXReading(ConveriMFDData2Raw(PLX_MAP, PRESSURE_kPa, (float)(comp_pres) / 100.0), &info); |
103 | sendInfo(&uc2, &info); |
105 | sendInfo(&uc2, &info); |
104 | 106 | ||
105 | ConvToPLXInstance(0, &info); |
107 | ConvToPLXInstance(obsIndex[PLX_Timing]++, &info); |
106 | ConvToPLXAddr(PLX_Timing, &info); |
108 | ConvToPLXAddr(PLX_Timing, &info); |
107 | ConvToPLXReading(ConveriMFDData2Raw(PLX_Timing, 0, timing / TIMING_SCALE), &info); |
109 | ConvToPLXReading(ConveriMFDData2Raw(PLX_Timing, 0, (float)(timing) / TIMING_SCALE), &info); |
108 | sendInfo(&uc2, &info); |
110 | sendInfo(&uc2, &info); |
109 | } |
111 | } |
110 | 112 | ||
111 | void triggerSAW() |
113 | void triggerSAW() |
112 | { |
114 | { |
Line 125... | Line 127... | ||
125 | } |
127 | } |
126 | 128 | ||
127 | /* USER CODE END 0 */ |
129 | /* USER CODE END 0 */ |
128 | 130 | ||
129 | /** |
131 | /** |
130 | * @brief The application entry point. |
132 | * @brief The application entry point. |
131 | * @retval int |
133 | * @retval int |
132 | */ |
134 | */ |
133 | int main(void) |
135 | int main(void) |
134 | { |
136 | { |
135 | /* USER CODE BEGIN 1 */ |
137 | /* USER CODE BEGIN 1 */ |
136 | 138 | ||
137 | /* USER CODE END 1 */ |
139 | /* USER CODE END 1 */ |
Line 188... | Line 190... | ||
188 | MX_I2C1_Init(); |
190 | MX_I2C1_Init(); |
189 | init_bmp(&hi2c1); |
191 | init_bmp(&hi2c1); |
190 | uint32_t lastTick = HAL_GetTick(); |
192 | uint32_t lastTick = HAL_GetTick(); |
191 | 193 | ||
192 | uint32_t displayOff = lastTick + 10000; |
194 | uint32_t displayOff = lastTick + 10000; |
- | 195 | uint32_t displayReinitialise = lastTick + DISPLAY_REINITIALISE; // every minute, reinitialise display because of risk of noise |
|
- | 196 | ||
193 | uint8_t intensity = 2; |
197 | uint8_t intensity = 2; |
194 | uint32_t timeout = 0; |
198 | uint32_t timeout = 0; |
195 | uint8_t send = 0; // enable sending our PLX data when non zero |
199 | uint8_t send = 0; // enable sending our PLX data when non zero |
196 | ResetRxBuffer(&uc2); |
200 | ResetRxBuffer(&uc2); |
197 | 201 | ||
198 | // used to store data |
202 | // used to store data |
199 | PLX_SensorInfo info; |
203 | PLX_SensorInfo info; |
- | 204 | // counter of information |
|
200 | int infoCount = -1; |
205 | int infoCount = -1; |
- | 206 | memset(obsIndex, 0, PLX_MAX_OBS); // zero incoming obsevation index |
|
201 | 207 | ||
202 | // dont do this loadTimingInfoFromNvram(); |
208 | // dont do this loadTimingInfoFromNvram(); |
203 | 209 | ||
204 | // HAL_IWDG_Init(&hiwdg); |
210 | // HAL_IWDG_Init(&hiwdg); |
205 | /* USER CODE END 2 */ |
211 | /* USER CODE END 2 */ |
206 | 212 | ||
207 | /* Infinite loop */ |
213 | /* Infinite loop */ |
208 | /* USER CODE BEGIN WHILE */ |
214 | /* USER CODE BEGIN WHILE */ |
209 | while (1) |
215 | while (1) |
210 | { |
216 | { |
- | 217 | ||
211 | int button = HAL_GPIO_ReadPin(PUSHBUTTON_GPIO_Port, PUSHBUTTON_Pin) == GPIO_PIN_RESET; |
218 | int button = HAL_GPIO_ReadPin(PUSHBUTTON_GPIO_Port, PUSHBUTTON_Pin) == GPIO_PIN_RESET; |
212 | 219 | ||
213 | if (button) |
220 | if (button) |
214 | { |
221 | { |
215 | intensity = 2; |
222 | intensity = 2; |
Line 232... | Line 239... | ||
232 | intensity = 1; // was 0 |
239 | intensity = 1; // was 0 |
233 | } |
240 | } |
234 | default: |
241 | default: |
235 | break; |
242 | break; |
236 | } |
243 | } |
- | 244 | // periodically write to the display and clear it |
|
- | 245 | if (HAL_GetTick() > displayReinitialise) |
|
- | 246 | { |
|
- | 247 | displayReinitialise += DISPLAY_REINITIALISE; |
|
- | 248 | cc_display(0, intensity, 1); |
|
- | 249 | } |
|
- | 250 | else |
|
237 | cc_display(0, intensity, 0); |
251 | cc_display(0, intensity, 0); |
238 | 252 | ||
239 | if (HAL_GetTick() - lastTick > T100MS) |
253 | if (HAL_GetTick() - lastTick > T100MS) |
240 | { |
254 | { |
241 | lastTick = HAL_GetTick(); |
255 | lastTick = HAL_GetTick(); |
242 | /* Reading the raw data from sensor */ |
256 | /* Reading the raw data from sensor */ |
Line 248... | Line 262... | ||
248 | uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp); |
262 | uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp); |
249 | 263 | ||
250 | uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp); |
264 | uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp); |
251 | 265 | ||
252 | #if defined TEST_CODE |
266 | #if defined TEST_CODE |
253 | comp_pres = 100000; |
267 | comp_pres = 100000; |
254 | comp_temp = 4000; |
268 | comp_temp = 4000; |
255 | #endif |
269 | #endif |
256 | if (rslt2 == 0 && rslt3 == 0) |
270 | if (rslt2 == 0 && rslt3 == 0) |
257 | cc_feed_env(comp_pres, comp_temp); |
271 | cc_feed_env(comp_pres, comp_temp); |
258 | } |
272 | } |
259 | 273 | ||
260 | // compute RPM value, feed to display |
274 | // compute RPM value, feed to display |
261 | #if defined TEST_CODE |
275 | #if defined TEST_CODE |
262 | int rpm = 1000; |
276 | int rpm = 1000; |
263 | #else |
277 | #else |
264 | int rpm = CalculateRPM(); |
278 | int rpm = CalculateRPM(); |
265 | #endif |
279 | #endif |
266 | if (rpm > 0) |
280 | if (rpm > 0) |
267 | { |
281 | { |
268 | cc_feed_rpm(rpm); |
282 | cc_feed_rpm(rpm); |
269 | // compute timing value, feed to display |
283 | // compute timing value, feed to display |
270 | timing = mapTiming(rpm, 1000 - comp_pres / 100); |
284 | timing = mapTiming(rpm, 1000 - comp_pres / 100); |
Line 285... | Line 299... | ||
285 | { |
299 | { |
286 | PutCharSerial(&uc2, c); // echo all but the stop bit |
300 | PutCharSerial(&uc2, c); // echo all but the stop bit |
287 | } |
301 | } |
288 | else |
302 | else |
289 | { // must be a stop character |
303 | { // must be a stop character |
290 | send = 1; // start our sending process. |
304 | send = 1; // start our sending process |
291 | } |
305 | } |
292 | // look up the i |
306 | // look up the i |
293 | if (c == PLX_Start) |
307 | if (c == PLX_Start) |
294 | { |
308 | { |
295 | ourMAPindex = 0; |
- | |
296 | infoCount = 0; |
309 | infoCount = 0; |
297 | } |
310 | } |
298 | else |
311 | else |
299 | { |
312 | { |
300 | info.bytes[infoCount++] = c; |
313 | info.bytes[infoCount++] = c; |
301 | // process the sensor info field |
314 | // process the sensor info field : discover maximum observation index |
302 | if (infoCount == sizeof(PLX_SensorInfo)) |
315 | if (infoCount == sizeof(PLX_SensorInfo)) |
303 | { |
316 | { |
304 | infoCount = 0; |
317 | infoCount = 0; |
305 | int addr = ConvPLXAddr(&info); |
318 | int addr = ConvPLXAddr(&info); |
306 | if (addr == PLX_MAP) |
319 | if (addr < PLX_MAX_OBS && (obsIndex[addr] <= info.Instance)) |
307 | ourMAPindex = info.Instance + 1; |
320 | obsIndex[addr] = info.Instance + 1; |
308 | } |
321 | } |
309 | } |
322 | } |
310 | 323 | ||
311 | if (c == PLX_Stop) |
324 | if (c == PLX_Stop) |
312 | infoCount = -1; |
325 | infoCount = -1; |
Line 324... | Line 337... | ||
324 | { |
337 | { |
325 | send = 0; |
338 | send = 0; |
326 | 339 | ||
327 | // send the observations |
340 | // send the observations |
328 | processObservations(); |
341 | processObservations(); |
- | 342 | memset(obsIndex, 0, PLX_MAX_OBS); // zero incoming obsevation index |
|
329 | // |
343 | // |
330 | PutCharSerial(&uc2, PLX_Stop); |
344 | PutCharSerial(&uc2, PLX_Stop); |
331 | } |
345 | } |
332 | 346 | ||
333 | /* USER CODE END WHILE */ |
347 | /* USER CODE END WHILE */ |
Line 339... | Line 353... | ||
339 | } |
353 | } |
340 | /* USER CODE END 3 */ |
354 | /* USER CODE END 3 */ |
341 | } |
355 | } |
342 | 356 | ||
343 | /** |
357 | /** |
344 | * @brief System Clock Configuration |
358 | * @brief System Clock Configuration |
345 | * @retval None |
359 | * @retval None |
346 | */ |
360 | */ |
347 | void SystemClock_Config(void) |
361 | void SystemClock_Config(void) |
348 | { |
362 | { |
349 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
363 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
350 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
364 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
351 | 365 | ||
352 | /** Initializes the RCC Oscillators according to the specified parameters |
366 | /** Initializes the RCC Oscillators according to the specified parameters |
353 | * in the RCC_OscInitTypeDef structure. |
367 | * in the RCC_OscInitTypeDef structure. |
354 | */ |
368 | */ |
355 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; |
369 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE; |
356 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
370 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
357 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
371 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
358 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
372 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
359 | RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
373 | RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
360 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
374 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
Line 364... | Line 378... | ||
364 | { |
378 | { |
365 | Error_Handler(); |
379 | Error_Handler(); |
366 | } |
380 | } |
367 | 381 | ||
368 | /** Initializes the CPU, AHB and APB buses clocks |
382 | /** Initializes the CPU, AHB and APB buses clocks |
369 | */ |
383 | */ |
370 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
384 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
371 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
- | |
372 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
385 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
373 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
386 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
374 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
387 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
375 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
388 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
376 | 389 | ||
Line 379... | Line 392... | ||
379 | Error_Handler(); |
392 | Error_Handler(); |
380 | } |
393 | } |
381 | } |
394 | } |
382 | 395 | ||
383 | /** |
396 | /** |
384 | * @brief CAN Initialization Function |
397 | * @brief CAN Initialization Function |
385 | * @param None |
398 | * @param None |
386 | * @retval None |
399 | * @retval None |
387 | */ |
400 | */ |
388 | static void MX_CAN_Init(void) |
401 | static void MX_CAN_Init(void) |
389 | { |
402 | { |
390 | 403 | ||
391 | /* USER CODE BEGIN CAN_Init 0 */ |
404 | /* USER CODE BEGIN CAN_Init 0 */ |
392 | 405 | ||
Line 412... | Line 425... | ||
412 | Error_Handler(); |
425 | Error_Handler(); |
413 | } |
426 | } |
414 | /* USER CODE BEGIN CAN_Init 2 */ |
427 | /* USER CODE BEGIN CAN_Init 2 */ |
415 | 428 | ||
416 | /* USER CODE END CAN_Init 2 */ |
429 | /* USER CODE END CAN_Init 2 */ |
417 | - | ||
418 | } |
430 | } |
419 | 431 | ||
420 | /** |
432 | /** |
421 | * @brief I2C1 Initialization Function |
433 | * @brief I2C1 Initialization Function |
422 | * @param None |
434 | * @param None |
423 | * @retval None |
435 | * @retval None |
424 | */ |
436 | */ |
425 | static void MX_I2C1_Init(void) |
437 | static void MX_I2C1_Init(void) |
426 | { |
438 | { |
427 | 439 | ||
428 | /* USER CODE BEGIN I2C1_Init 0 */ |
440 | /* USER CODE BEGIN I2C1_Init 0 */ |
429 | 441 | ||
Line 446... | Line 458... | ||
446 | Error_Handler(); |
458 | Error_Handler(); |
447 | } |
459 | } |
448 | /* USER CODE BEGIN I2C1_Init 2 */ |
460 | /* USER CODE BEGIN I2C1_Init 2 */ |
449 | 461 | ||
450 | /* USER CODE END I2C1_Init 2 */ |
462 | /* USER CODE END I2C1_Init 2 */ |
451 | - | ||
452 | } |
463 | } |
453 | 464 | ||
454 | /** |
465 | /** |
455 | * @brief IWDG Initialization Function |
466 | * @brief IWDG Initialization Function |
456 | * @param None |
467 | * @param None |
457 | * @retval None |
468 | * @retval None |
458 | */ |
469 | */ |
459 | static void MX_IWDG_Init(void) |
470 | static void MX_IWDG_Init(void) |
460 | { |
471 | { |
461 | 472 | ||
462 | /* USER CODE BEGIN IWDG_Init 0 */ |
473 | /* USER CODE BEGIN IWDG_Init 0 */ |
463 | 474 | ||
Line 474... | Line 485... | ||
474 | Error_Handler(); |
485 | Error_Handler(); |
475 | } |
486 | } |
476 | /* USER CODE BEGIN IWDG_Init 2 */ |
487 | /* USER CODE BEGIN IWDG_Init 2 */ |
477 | 488 | ||
478 | /* USER CODE END IWDG_Init 2 */ |
489 | /* USER CODE END IWDG_Init 2 */ |
479 | - | ||
480 | } |
490 | } |
481 | 491 | ||
482 | /** |
492 | /** |
483 | * @brief SPI1 Initialization Function |
493 | * @brief SPI1 Initialization Function |
484 | * @param None |
494 | * @param None |
485 | * @retval None |
495 | * @retval None |
486 | */ |
496 | */ |
487 | static void MX_SPI1_Init(void) |
497 | static void MX_SPI1_Init(void) |
488 | { |
498 | { |
489 | 499 | ||
490 | /* USER CODE BEGIN SPI1_Init 0 */ |
500 | /* USER CODE BEGIN SPI1_Init 0 */ |
491 | 501 | ||
Line 512... | Line 522... | ||
512 | Error_Handler(); |
522 | Error_Handler(); |
513 | } |
523 | } |
514 | /* USER CODE BEGIN SPI1_Init 2 */ |
524 | /* USER CODE BEGIN SPI1_Init 2 */ |
515 | 525 | ||
516 | /* USER CODE END SPI1_Init 2 */ |
526 | /* USER CODE END SPI1_Init 2 */ |
517 | - | ||
518 | } |
527 | } |
519 | 528 | ||
520 | /** |
529 | /** |
521 | * @brief TIM1 Initialization Function |
530 | * @brief TIM1 Initialization Function |
522 | * @param None |
531 | * @param None |
523 | * @retval None |
532 | * @retval None |
524 | */ |
533 | */ |
525 | static void MX_TIM1_Init(void) |
534 | static void MX_TIM1_Init(void) |
526 | { |
535 | { |
527 | 536 | ||
528 | /* USER CODE BEGIN TIM1_Init 0 */ |
537 | /* USER CODE BEGIN TIM1_Init 0 */ |
529 | 538 | ||
Line 591... | Line 600... | ||
591 | } |
600 | } |
592 | /* USER CODE BEGIN TIM1_Init 2 */ |
601 | /* USER CODE BEGIN TIM1_Init 2 */ |
593 | 602 | ||
594 | /* USER CODE END TIM1_Init 2 */ |
603 | /* USER CODE END TIM1_Init 2 */ |
595 | HAL_TIM_MspPostInit(&htim1); |
604 | HAL_TIM_MspPostInit(&htim1); |
596 | - | ||
597 | } |
605 | } |
598 | 606 | ||
599 | /** |
607 | /** |
600 | * @brief TIM2 Initialization Function |
608 | * @brief TIM2 Initialization Function |
601 | * @param None |
609 | * @param None |
602 | * @retval None |
610 | * @retval None |
603 | */ |
611 | */ |
604 | static void MX_TIM2_Init(void) |
612 | static void MX_TIM2_Init(void) |
605 | { |
613 | { |
606 | 614 | ||
607 | /* USER CODE BEGIN TIM2_Init 0 */ |
615 | /* USER CODE BEGIN TIM2_Init 0 */ |
608 | 616 | ||
Line 655... | Line 663... | ||
655 | Error_Handler(); |
663 | Error_Handler(); |
656 | } |
664 | } |
657 | /* USER CODE BEGIN TIM2_Init 2 */ |
665 | /* USER CODE BEGIN TIM2_Init 2 */ |
658 | 666 | ||
659 | /* USER CODE END TIM2_Init 2 */ |
667 | /* USER CODE END TIM2_Init 2 */ |
660 | - | ||
661 | } |
668 | } |
662 | 669 | ||
663 | /** |
670 | /** |
664 | * @brief TIM3 Initialization Function |
671 | * @brief TIM3 Initialization Function |
665 | * @param None |
672 | * @param None |
666 | * @retval None |
673 | * @retval None |
667 | */ |
674 | */ |
668 | static void MX_TIM3_Init(void) |
675 | static void MX_TIM3_Init(void) |
669 | { |
676 | { |
670 | 677 | ||
671 | /* USER CODE BEGIN TIM3_Init 0 */ |
678 | /* USER CODE BEGIN TIM3_Init 0 */ |
672 | 679 | ||
Line 700... | Line 707... | ||
700 | Error_Handler(); |
707 | Error_Handler(); |
701 | } |
708 | } |
702 | /* USER CODE BEGIN TIM3_Init 2 */ |
709 | /* USER CODE BEGIN TIM3_Init 2 */ |
703 | 710 | ||
704 | /* USER CODE END TIM3_Init 2 */ |
711 | /* USER CODE END TIM3_Init 2 */ |
705 | - | ||
706 | } |
712 | } |
707 | 713 | ||
708 | /** |
714 | /** |
709 | * @brief USART2 Initialization Function |
715 | * @brief USART2 Initialization Function |
710 | * @param None |
716 | * @param None |
711 | * @retval None |
717 | * @retval None |
712 | */ |
718 | */ |
713 | static void MX_USART2_UART_Init(void) |
719 | static void MX_USART2_UART_Init(void) |
714 | { |
720 | { |
715 | 721 | ||
716 | /* USER CODE BEGIN USART2_Init 0 */ |
722 | /* USER CODE BEGIN USART2_Init 0 */ |
717 | 723 | ||
Line 733... | Line 739... | ||
733 | Error_Handler(); |
739 | Error_Handler(); |
734 | } |
740 | } |
735 | /* USER CODE BEGIN USART2_Init 2 */ |
741 | /* USER CODE BEGIN USART2_Init 2 */ |
736 | 742 | ||
737 | /* USER CODE END USART2_Init 2 */ |
743 | /* USER CODE END USART2_Init 2 */ |
738 | - | ||
739 | } |
744 | } |
740 | 745 | ||
741 | /** |
746 | /** |
742 | * @brief GPIO Initialization Function |
747 | * @brief GPIO Initialization Function |
743 | * @param None |
748 | * @param None |
744 | * @retval None |
749 | * @retval None |
745 | */ |
750 | */ |
746 | static void MX_GPIO_Init(void) |
751 | static void MX_GPIO_Init(void) |
747 | { |
752 | { |
748 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
753 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
749 | 754 | ||
750 | /* GPIO Ports Clock Enable */ |
755 | /* GPIO Ports Clock Enable */ |
751 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
756 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
752 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
757 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
753 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
758 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
754 | 759 | ||
755 | /*Configure GPIO pin Output Level */ |
760 | /*Configure GPIO pin Output Level */ |
756 | HAL_GPIO_WritePin(GPIOA, SPI1_NSS_Pin|SPI1_RESET_Pin, GPIO_PIN_RESET); |
761 | HAL_GPIO_WritePin(GPIOA, SPI1_NSS_Pin | SPI1_RESET_Pin, GPIO_PIN_RESET); |
757 | 762 | ||
758 | /*Configure GPIO pin Output Level */ |
763 | /*Configure GPIO pin Output Level */ |
759 | HAL_GPIO_WritePin(SPI1_CD_GPIO_Port, SPI1_CD_Pin, GPIO_PIN_RESET); |
764 | HAL_GPIO_WritePin(SPI1_CD_GPIO_Port, SPI1_CD_Pin, GPIO_PIN_RESET); |
760 | 765 | ||
761 | /*Configure GPIO pins : SPI1_NSS_Pin SPI1_RESET_Pin */ |
766 | /*Configure GPIO pins : SPI1_NSS_Pin SPI1_RESET_Pin */ |
762 | GPIO_InitStruct.Pin = SPI1_NSS_Pin|SPI1_RESET_Pin; |
767 | GPIO_InitStruct.Pin = SPI1_NSS_Pin | SPI1_RESET_Pin; |
763 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
768 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
764 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
769 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
765 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
770 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
766 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
771 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
767 | 772 | ||
Line 781... | Line 786... | ||
781 | /*Configure GPIO pin : dualSpark_Pin */ |
786 | /*Configure GPIO pin : dualSpark_Pin */ |
782 | GPIO_InitStruct.Pin = dualSpark_Pin; |
787 | GPIO_InitStruct.Pin = dualSpark_Pin; |
783 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
788 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
784 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
789 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
785 | HAL_GPIO_Init(dualSpark_GPIO_Port, &GPIO_InitStruct); |
790 | HAL_GPIO_Init(dualSpark_GPIO_Port, &GPIO_InitStruct); |
786 | - | ||
787 | } |
791 | } |
788 | 792 | ||
789 | /* USER CODE BEGIN 4 */ |
793 | /* USER CODE BEGIN 4 */ |
790 | 794 | ||
791 | /* USER CODE END 4 */ |
795 | /* USER CODE END 4 */ |
792 | 796 | ||
793 | /** |
797 | /** |
794 | * @brief This function is executed in case of error occurrence. |
798 | * @brief This function is executed in case of error occurrence. |
795 | * @retval None |
799 | * @retval None |
796 | */ |
800 | */ |
797 | void Error_Handler(void) |
801 | void Error_Handler(void) |
798 | { |
802 | { |
799 | /* USER CODE BEGIN Error_Handler_Debug */ |
803 | /* USER CODE BEGIN Error_Handler_Debug */ |
800 | /* User can add his own implementation to report the HAL error return state */ |
804 | /* User can add his own implementation to report the HAL error return state */ |
801 | __disable_irq(); |
805 | __disable_irq(); |
Line 803... | Line 807... | ||
803 | { |
807 | { |
804 | } |
808 | } |
805 | /* USER CODE END Error_Handler_Debug */ |
809 | /* USER CODE END Error_Handler_Debug */ |
806 | } |
810 | } |
807 | 811 | ||
808 | #ifdef USE_FULL_ASSERT |
812 | #ifdef USE_FULL_ASSERT |
809 | /** |
813 | /** |
810 | * @brief Reports the name of the source file and the source line number |
814 | * @brief Reports the name of the source file and the source line number |
811 | * where the assert_param error has occurred. |
815 | * where the assert_param error has occurred. |
812 | * @param file: pointer to the source file name |
816 | * @param file: pointer to the source file name |
813 | * @param line: assert_param error line source number |
817 | * @param line: assert_param error line source number |
814 | * @retval None |
818 | * @retval None |
815 | */ |
819 | */ |
816 | void assert_failed(uint8_t *file, uint32_t line) |
820 | void assert_failed(uint8_t *file, uint32_t line) |
817 | { |
821 | { |
818 | /* USER CODE BEGIN 6 */ |
822 | /* USER CODE BEGIN 6 */ |
819 | /* User can add his own implementation to report the file name and line number, |
823 | /* User can add his own implementation to report the file name and line number, |
820 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
824 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |