Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 4 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* USER CODE BEGIN Header */ |
1 | /* USER CODE BEGIN Header */ |
2 | /** |
2 | /** |
3 | ****************************************************************************** |
3 | ****************************************************************************** |
4 | * @file : main.c |
4 | * @file : main.c |
5 | * @brief : Main program body |
5 | * @brief : Main program body |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * Copyright (c) 2023 STMicroelectronics. |
9 | * Copyright (c) 2023 STMicroelectronics. |
10 | * All rights reserved. |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software is licensed under terms that can be found in the LICENSE file |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * in the root directory of this software component. |
13 | * in the root directory of this software component. |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * |
15 | * |
16 | ****************************************************************************** |
16 | ****************************************************************************** |
17 | */ |
17 | */ |
18 | /* USER CODE END Header */ |
18 | /* USER CODE END Header */ |
19 | /* Includes ------------------------------------------------------------------*/ |
19 | /* Includes ------------------------------------------------------------------*/ |
20 | #include "main.h" |
20 | #include "main.h" |
21 | 21 | ||
22 | /* Private includes ----------------------------------------------------------*/ |
22 | /* Private includes ----------------------------------------------------------*/ |
Line 43... | Line 43... | ||
43 | /* USER CODE BEGIN PM */ |
43 | /* USER CODE BEGIN PM */ |
44 | 44 | ||
45 | /* USER CODE END PM */ |
45 | /* USER CODE END PM */ |
46 | 46 | ||
47 | /* Private variables ---------------------------------------------------------*/ |
47 | /* Private variables ---------------------------------------------------------*/ |
48 | CAN_HandleTypeDef hcan; |
48 | CAN_HandleTypeDef hcan; |
49 | 49 | ||
50 | I2C_HandleTypeDef hi2c1; |
50 | I2C_HandleTypeDef hi2c1; |
51 | 51 | ||
52 | IWDG_HandleTypeDef hiwdg; |
52 | IWDG_HandleTypeDef hiwdg; |
53 | 53 | ||
Line 89... | Line 89... | ||
89 | PLX_SensorInfo info; |
89 | PLX_SensorInfo info; |
90 | ConvToPLXInstance(ourMAPindex, &info); |
90 | ConvToPLXInstance(ourMAPindex, &info); |
91 | ConvToPLXAddr(PLX_MAP, &info); |
91 | ConvToPLXAddr(PLX_MAP, &info); |
92 | ConvToPLXReading(ConveriMFDData2Raw(PLX_MAP, PRESSURE_kPa, comp_pres / 1000.0), &info); |
92 | ConvToPLXReading(ConveriMFDData2Raw(PLX_MAP, PRESSURE_kPa, comp_pres / 1000.0), &info); |
93 | int i; |
93 | int i; |
94 | for (i = 0; i < sizeof(PLX_SensorInfo);++i) |
94 | for (i = 0; i < sizeof(PLX_SensorInfo); ++i) |
95 | PutCharSerial(&uc2, info.bytes[i]); |
95 | PutCharSerial(&uc2, info.bytes[i]); |
96 | } |
96 | } |
97 | 97 | ||
98 | void triggerSAW() |
98 | void triggerSAW() |
99 | { |
99 | { |
100 | ///@todo trigger the PIP signal on Timer 2 |
100 | // trigger SAW timer, timer 1 |
- | 101 | __HAL_TIM_ENABLE(&htim1); |
|
101 | } |
102 | } |
102 | 103 | ||
103 | /* USER CODE END PFP */ |
104 | /* USER CODE END PFP */ |
104 | 105 | ||
105 | /* Private user code ---------------------------------------------------------*/ |
106 | /* Private user code ---------------------------------------------------------*/ |
106 | /* USER CODE BEGIN 0 */ |
107 | /* USER CODE BEGIN 0 */ |
107 | 108 | ||
108 | /* USER CODE END 0 */ |
109 | /* USER CODE END 0 */ |
109 | 110 | ||
110 | /** |
111 | /** |
111 | * @brief The application entry point. |
112 | * @brief The application entry point. |
112 | * @retval int |
113 | * @retval int |
113 | */ |
114 | */ |
114 | int main(void) |
115 | int main(void) |
115 | { |
116 | { |
116 | /* USER CODE BEGIN 1 */ |
117 | /* USER CODE BEGIN 1 */ |
117 | 118 | ||
118 | /* USER CODE END 1 */ |
119 | /* USER CODE END 1 */ |
Line 144... | Line 145... | ||
144 | MX_TIM3_Init(); |
145 | MX_TIM3_Init(); |
145 | MX_IWDG_Init(); |
146 | MX_IWDG_Init(); |
146 | /* USER CODE BEGIN 2 */ |
147 | /* USER CODE BEGIN 2 */ |
147 | cc_init(); |
148 | cc_init(); |
148 | 149 | ||
- | 150 | HAL_TIM_Base_Start(&htim1); |
|
- | 151 | ||
- | 152 | __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, 5); // delay of 5 uS |
|
- | 153 | ||
149 | HAL_I2C_ClearBusyFlagErrata_2_14_7(&hi2c1); |
154 | HAL_I2C_ClearBusyFlagErrata_2_14_7(&hi2c1); |
150 | MX_I2C1_Init(); |
155 | MX_I2C1_Init(); |
151 | init_bmp(&hi2c1); |
156 | init_bmp(&hi2c1); |
152 | uint32_t lastTick = HAL_GetTick(); |
157 | uint32_t lastTick = HAL_GetTick(); |
153 | 158 | ||
154 | uint32_t displayOff = lastTick + 10000; |
159 | uint32_t displayOff = lastTick + 10000; |
155 | uint8_t intensity = 2; |
160 | uint8_t intensity = 2; |
156 | uint32_t timeout = 0; |
161 | uint32_t timeout = 0; |
157 | uint8_t send = 0; // enable sending our PLX data when non zero |
162 | uint8_t send = 0; // enable sending our PLX data when non zero |
158 | ResetRxBuffer(&uc2); |
163 | ResetRxBuffer(&uc2); |
159 | 164 | ||
160 | // used to store data |
165 | // used to store data |
161 | PLX_SensorInfo info; |
166 | PLX_SensorInfo info; |
Line 208... | Line 213... | ||
208 | if (rslt == 0) |
213 | if (rslt == 0) |
209 | { |
214 | { |
210 | uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp); |
215 | uint8_t rslt2 = bmp280_get_comp_pres_32bit(&comp_pres, ucomp_data.uncomp_press, &bmp); |
211 | 216 | ||
212 | uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp); |
217 | uint8_t rslt3 = bmp280_get_comp_temp_32bit(&comp_temp, ucomp_data.uncomp_temp, &bmp); |
213 | if(rslt2==0 && rslt3 == 0) |
218 | if (rslt2 == 0 && rslt3 == 0) |
214 | cc_feed_env(comp_pres, comp_temp); |
219 | cc_feed_env(comp_pres, comp_temp); |
215 | } |
220 | } |
216 | } |
221 | } |
217 | 222 | ||
218 | // compute RPM value, feed to display |
223 | // compute RPM value, feed to display |
219 | 224 | ||
- | 225 | int rpm = CalculateRPM(); |
|
220 | int rpm = 1000; |
226 | if (rpm > 0) |
- | 227 | { |
|
221 | cc_feed_rpm(rpm); |
228 | cc_feed_rpm(rpm); |
222 | // compute timing value, feed to display |
229 | // compute timing value, feed to display |
223 | int timing = mapTiming(rpm, 1000 - comp_pres / 100); |
230 | int timing = mapTiming(rpm, 1000 - comp_pres / 100); |
224 | cc_feed_timing(timing); |
231 | cc_feed_timing(timing); |
225 | int microsecs = mapTimingToMicroseconds(timing,0); |
232 | int microsecs = mapTimingToMicroseconds(timing, 0); |
226 | __HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_1,microsecs); |
233 | __HAL_TIM_SET_AUTORELOAD(&htim1, microsecs + SAW_DELAY); |
227 | 234 | } |
|
228 | __HAL_TIM_ENABLE(&htim2); |
- | |
229 | - | ||
230 | /// @todo setup pulse width for EDIS control |
- | |
231 | // Handle PLX |
235 | // Handle PLX |
232 | // poll the input for a stop bit or timeout |
236 | // poll the input for a stop bit or timeout |
233 | if (PollSerial(&uc2)) |
237 | if (PollSerial(&uc2)) |
234 | { |
238 | { |
235 | timeout = HAL_GetTick() + T100MS * 2; |
239 | timeout = HAL_GetTick() + T100MS * 2; |
Line 289... | Line 293... | ||
289 | } |
293 | } |
290 | /* USER CODE END 3 */ |
294 | /* USER CODE END 3 */ |
291 | } |
295 | } |
292 | 296 | ||
293 | /** |
297 | /** |
294 | * @brief System Clock Configuration |
298 | * @brief System Clock Configuration |
295 | * @retval None |
299 | * @retval None |
296 | */ |
300 | */ |
297 | void SystemClock_Config(void) |
301 | void SystemClock_Config(void) |
298 | { |
302 | { |
299 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
303 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
300 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
304 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
301 | 305 | ||
302 | /** Initializes the RCC Oscillators according to the specified parameters |
306 | /** Initializes the RCC Oscillators according to the specified parameters |
303 | * in the RCC_OscInitTypeDef structure. |
307 | * in the RCC_OscInitTypeDef structure. |
304 | */ |
308 | */ |
305 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; |
309 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE; |
306 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
310 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
307 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
311 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
308 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
312 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
309 | RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
313 | RCC_OscInitStruct.LSIState = RCC_LSI_ON; |
310 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
314 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
Line 314... | Line 318... | ||
314 | { |
318 | { |
315 | Error_Handler(); |
319 | Error_Handler(); |
316 | } |
320 | } |
317 | 321 | ||
318 | /** Initializes the CPU, AHB and APB buses clocks |
322 | /** Initializes the CPU, AHB and APB buses clocks |
319 | */ |
323 | */ |
320 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
324 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
321 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
- | |
322 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
325 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
323 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
326 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
324 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
327 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
325 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
328 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
326 | 329 | ||
Line 329... | Line 332... | ||
329 | Error_Handler(); |
332 | Error_Handler(); |
330 | } |
333 | } |
331 | } |
334 | } |
332 | 335 | ||
333 | /** |
336 | /** |
334 | * @brief CAN Initialization Function |
337 | * @brief CAN Initialization Function |
335 | * @param None |
338 | * @param None |
336 | * @retval None |
339 | * @retval None |
337 | */ |
340 | */ |
338 | static void MX_CAN_Init(void) |
341 | static void MX_CAN_Init(void) |
339 | { |
342 | { |
340 | 343 | ||
341 | /* USER CODE BEGIN CAN_Init 0 */ |
344 | /* USER CODE BEGIN CAN_Init 0 */ |
342 | 345 | ||
Line 362... | Line 365... | ||
362 | Error_Handler(); |
365 | Error_Handler(); |
363 | } |
366 | } |
364 | /* USER CODE BEGIN CAN_Init 2 */ |
367 | /* USER CODE BEGIN CAN_Init 2 */ |
365 | 368 | ||
366 | /* USER CODE END CAN_Init 2 */ |
369 | /* USER CODE END CAN_Init 2 */ |
367 | - | ||
368 | } |
370 | } |
369 | 371 | ||
370 | /** |
372 | /** |
371 | * @brief I2C1 Initialization Function |
373 | * @brief I2C1 Initialization Function |
372 | * @param None |
374 | * @param None |
373 | * @retval None |
375 | * @retval None |
374 | */ |
376 | */ |
375 | static void MX_I2C1_Init(void) |
377 | static void MX_I2C1_Init(void) |
376 | { |
378 | { |
377 | 379 | ||
378 | /* USER CODE BEGIN I2C1_Init 0 */ |
380 | /* USER CODE BEGIN I2C1_Init 0 */ |
379 | 381 | ||
Line 396... | Line 398... | ||
396 | Error_Handler(); |
398 | Error_Handler(); |
397 | } |
399 | } |
398 | /* USER CODE BEGIN I2C1_Init 2 */ |
400 | /* USER CODE BEGIN I2C1_Init 2 */ |
399 | 401 | ||
400 | /* USER CODE END I2C1_Init 2 */ |
402 | /* USER CODE END I2C1_Init 2 */ |
401 | - | ||
402 | } |
403 | } |
403 | 404 | ||
404 | /** |
405 | /** |
405 | * @brief IWDG Initialization Function |
406 | * @brief IWDG Initialization Function |
406 | * @param None |
407 | * @param None |
407 | * @retval None |
408 | * @retval None |
408 | */ |
409 | */ |
409 | static void MX_IWDG_Init(void) |
410 | static void MX_IWDG_Init(void) |
410 | { |
411 | { |
411 | 412 | ||
412 | /* USER CODE BEGIN IWDG_Init 0 */ |
413 | /* USER CODE BEGIN IWDG_Init 0 */ |
413 | 414 | ||
Line 424... | Line 425... | ||
424 | Error_Handler(); |
425 | Error_Handler(); |
425 | } |
426 | } |
426 | /* USER CODE BEGIN IWDG_Init 2 */ |
427 | /* USER CODE BEGIN IWDG_Init 2 */ |
427 | 428 | ||
428 | /* USER CODE END IWDG_Init 2 */ |
429 | /* USER CODE END IWDG_Init 2 */ |
429 | - | ||
430 | } |
430 | } |
431 | 431 | ||
432 | /** |
432 | /** |
433 | * @brief SPI1 Initialization Function |
433 | * @brief SPI1 Initialization Function |
434 | * @param None |
434 | * @param None |
435 | * @retval None |
435 | * @retval None |
436 | */ |
436 | */ |
437 | static void MX_SPI1_Init(void) |
437 | static void MX_SPI1_Init(void) |
438 | { |
438 | { |
439 | 439 | ||
440 | /* USER CODE BEGIN SPI1_Init 0 */ |
440 | /* USER CODE BEGIN SPI1_Init 0 */ |
441 | 441 | ||
Line 462... | Line 462... | ||
462 | Error_Handler(); |
462 | Error_Handler(); |
463 | } |
463 | } |
464 | /* USER CODE BEGIN SPI1_Init 2 */ |
464 | /* USER CODE BEGIN SPI1_Init 2 */ |
465 | 465 | ||
466 | /* USER CODE END SPI1_Init 2 */ |
466 | /* USER CODE END SPI1_Init 2 */ |
467 | - | ||
468 | } |
467 | } |
469 | 468 | ||
470 | /** |
469 | /** |
471 | * @brief TIM1 Initialization Function |
470 | * @brief TIM1 Initialization Function |
472 | * @param None |
471 | * @param None |
473 | * @retval None |
472 | * @retval None |
474 | */ |
473 | */ |
475 | static void MX_TIM1_Init(void) |
474 | static void MX_TIM1_Init(void) |
476 | { |
475 | { |
477 | 476 | ||
478 | /* USER CODE BEGIN TIM1_Init 0 */ |
477 | /* USER CODE BEGIN TIM1_Init 0 */ |
479 | 478 | ||
Line 515... | Line 514... | ||
515 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
514 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; |
516 | if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) |
515 | if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) |
517 | { |
516 | { |
518 | Error_Handler(); |
517 | Error_Handler(); |
519 | } |
518 | } |
520 | sConfigOC.OCMode = TIM_OCMODE_INACTIVE; |
519 | sConfigOC.OCMode = TIM_OCMODE_ACTIVE; |
521 | sConfigOC.Pulse = 1; |
520 | sConfigOC.Pulse = SAW_DELAY; |
522 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
521 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; |
523 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; |
522 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; |
524 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
523 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; |
525 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |
524 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; |
526 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |
525 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; |
Line 542... | Line 541... | ||
542 | } |
541 | } |
543 | /* USER CODE BEGIN TIM1_Init 2 */ |
542 | /* USER CODE BEGIN TIM1_Init 2 */ |
544 | 543 | ||
545 | /* USER CODE END TIM1_Init 2 */ |
544 | /* USER CODE END TIM1_Init 2 */ |
546 | HAL_TIM_MspPostInit(&htim1); |
545 | HAL_TIM_MspPostInit(&htim1); |
547 | - | ||
548 | } |
546 | } |
549 | 547 | ||
550 | /** |
548 | /** |
551 | * @brief TIM2 Initialization Function |
549 | * @brief TIM2 Initialization Function |
552 | * @param None |
550 | * @param None |
553 | * @retval None |
551 | * @retval None |
554 | */ |
552 | */ |
555 | static void MX_TIM2_Init(void) |
553 | static void MX_TIM2_Init(void) |
556 | { |
554 | { |
557 | 555 | ||
558 | /* USER CODE BEGIN TIM2_Init 0 */ |
556 | /* USER CODE BEGIN TIM2_Init 0 */ |
559 | 557 | ||
Line 601... | Line 599... | ||
601 | Error_Handler(); |
599 | Error_Handler(); |
602 | } |
600 | } |
603 | /* USER CODE BEGIN TIM2_Init 2 */ |
601 | /* USER CODE BEGIN TIM2_Init 2 */ |
604 | 602 | ||
605 | /* USER CODE END TIM2_Init 2 */ |
603 | /* USER CODE END TIM2_Init 2 */ |
606 | - | ||
607 | } |
604 | } |
608 | 605 | ||
609 | /** |
606 | /** |
610 | * @brief TIM3 Initialization Function |
607 | * @brief TIM3 Initialization Function |
611 | * @param None |
608 | * @param None |
612 | * @retval None |
609 | * @retval None |
613 | */ |
610 | */ |
614 | static void MX_TIM3_Init(void) |
611 | static void MX_TIM3_Init(void) |
615 | { |
612 | { |
616 | 613 | ||
617 | /* USER CODE BEGIN TIM3_Init 0 */ |
614 | /* USER CODE BEGIN TIM3_Init 0 */ |
618 | 615 | ||
Line 646... | Line 643... | ||
646 | Error_Handler(); |
643 | Error_Handler(); |
647 | } |
644 | } |
648 | /* USER CODE BEGIN TIM3_Init 2 */ |
645 | /* USER CODE BEGIN TIM3_Init 2 */ |
649 | 646 | ||
650 | /* USER CODE END TIM3_Init 2 */ |
647 | /* USER CODE END TIM3_Init 2 */ |
651 | - | ||
652 | } |
648 | } |
653 | 649 | ||
654 | /** |
650 | /** |
655 | * @brief USART2 Initialization Function |
651 | * @brief USART2 Initialization Function |
656 | * @param None |
652 | * @param None |
657 | * @retval None |
653 | * @retval None |
658 | */ |
654 | */ |
659 | static void MX_USART2_UART_Init(void) |
655 | static void MX_USART2_UART_Init(void) |
660 | { |
656 | { |
661 | 657 | ||
662 | /* USER CODE BEGIN USART2_Init 0 */ |
658 | /* USER CODE BEGIN USART2_Init 0 */ |
663 | 659 | ||
Line 679... | Line 675... | ||
679 | Error_Handler(); |
675 | Error_Handler(); |
680 | } |
676 | } |
681 | /* USER CODE BEGIN USART2_Init 2 */ |
677 | /* USER CODE BEGIN USART2_Init 2 */ |
682 | 678 | ||
683 | /* USER CODE END USART2_Init 2 */ |
679 | /* USER CODE END USART2_Init 2 */ |
684 | - | ||
685 | } |
680 | } |
686 | 681 | ||
687 | /** |
682 | /** |
688 | * @brief GPIO Initialization Function |
683 | * @brief GPIO Initialization Function |
689 | * @param None |
684 | * @param None |
690 | * @retval None |
685 | * @retval None |
691 | */ |
686 | */ |
692 | static void MX_GPIO_Init(void) |
687 | static void MX_GPIO_Init(void) |
693 | { |
688 | { |
694 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
689 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
695 | 690 | ||
696 | /* GPIO Ports Clock Enable */ |
691 | /* GPIO Ports Clock Enable */ |
697 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
692 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
698 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
693 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
699 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
694 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
700 | 695 | ||
701 | /*Configure GPIO pin Output Level */ |
696 | /*Configure GPIO pin Output Level */ |
702 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4|GPIO_PIN_6, GPIO_PIN_RESET); |
697 | HAL_GPIO_WritePin(GPIOA, SPI1_NSS_Pin | SPI1_RESET_Pin, GPIO_PIN_RESET); |
703 | 698 | ||
704 | /*Configure GPIO pin Output Level */ |
699 | /*Configure GPIO pin Output Level */ |
705 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET); |
700 | HAL_GPIO_WritePin(SPI1_CD_GPIO_Port, SPI1_CD_Pin, GPIO_PIN_RESET); |
706 | 701 | ||
707 | /*Configure GPIO pins : PA4 PA6 */ |
702 | /*Configure GPIO pins : SPI1_NSS_Pin SPI1_RESET_Pin */ |
708 | GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6; |
703 | GPIO_InitStruct.Pin = SPI1_NSS_Pin | SPI1_RESET_Pin; |
709 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
704 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
710 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
705 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
711 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
706 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
712 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
707 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
713 | 708 | ||
714 | /*Configure GPIO pin : PB0 */ |
709 | /*Configure GPIO pin : SPI1_CD_Pin */ |
715 | GPIO_InitStruct.Pin = GPIO_PIN_0; |
710 | GPIO_InitStruct.Pin = SPI1_CD_Pin; |
716 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
711 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
717 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
712 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
718 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
713 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
719 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
714 | HAL_GPIO_Init(SPI1_CD_GPIO_Port, &GPIO_InitStruct); |
720 | 715 | ||
721 | /*Configure GPIO pin : PB12 */ |
716 | /*Configure GPIO pin : PUSHBUTTON_Pin */ |
722 | GPIO_InitStruct.Pin = GPIO_PIN_12; |
717 | GPIO_InitStruct.Pin = PUSHBUTTON_Pin; |
723 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
718 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
724 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
719 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
725 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
720 | HAL_GPIO_Init(PUSHBUTTON_GPIO_Port, &GPIO_InitStruct); |
726 | 721 | ||
727 | /*Configure GPIO pin : PA9 */ |
722 | /*Configure GPIO pin : dualSpark_Pin */ |
728 | GPIO_InitStruct.Pin = GPIO_PIN_9; |
723 | GPIO_InitStruct.Pin = dualSpark_Pin; |
729 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
724 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
730 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
725 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
731 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
726 | HAL_GPIO_Init(dualSpark_GPIO_Port, &GPIO_InitStruct); |
732 | - | ||
733 | } |
727 | } |
734 | 728 | ||
735 | /* USER CODE BEGIN 4 */ |
729 | /* USER CODE BEGIN 4 */ |
736 | 730 | ||
737 | /* USER CODE END 4 */ |
731 | /* USER CODE END 4 */ |
738 | 732 | ||
739 | /** |
733 | /** |
740 | * @brief This function is executed in case of error occurrence. |
734 | * @brief This function is executed in case of error occurrence. |
741 | * @retval None |
735 | * @retval None |
742 | */ |
736 | */ |
743 | void Error_Handler(void) |
737 | void Error_Handler(void) |
744 | { |
738 | { |
745 | /* USER CODE BEGIN Error_Handler_Debug */ |
739 | /* USER CODE BEGIN Error_Handler_Debug */ |
746 | /* User can add his own implementation to report the HAL error return state */ |
740 | /* User can add his own implementation to report the HAL error return state */ |
747 | __disable_irq(); |
741 | __disable_irq(); |
Line 749... | Line 743... | ||
749 | { |
743 | { |
750 | } |
744 | } |
751 | /* USER CODE END Error_Handler_Debug */ |
745 | /* USER CODE END Error_Handler_Debug */ |
752 | } |
746 | } |
753 | 747 | ||
754 | #ifdef USE_FULL_ASSERT |
748 | #ifdef USE_FULL_ASSERT |
755 | /** |
749 | /** |
756 | * @brief Reports the name of the source file and the source line number |
750 | * @brief Reports the name of the source file and the source line number |
757 | * where the assert_param error has occurred. |
751 | * where the assert_param error has occurred. |
758 | * @param file: pointer to the source file name |
752 | * @param file: pointer to the source file name |
759 | * @param line: assert_param error line source number |
753 | * @param line: assert_param error line source number |
760 | * @retval None |
754 | * @retval None |
761 | */ |
755 | */ |
762 | void assert_failed(uint8_t *file, uint32_t line) |
756 | void assert_failed(uint8_t *file, uint32_t line) |
763 | { |
757 | { |
764 | /* USER CODE BEGIN 6 */ |
758 | /* USER CODE BEGIN 6 */ |
765 | /* User can add his own implementation to report the file name and line number, |
759 | /* User can add his own implementation to report the file name and line number, |
766 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
760 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |