Rev 60 | Rev 62 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 60 | Rev 61 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | /* USER CODE BEGIN PM */ |
44 | /* USER CODE BEGIN PM */ |
45 | 45 | ||
46 | /* USER CODE END PM */ |
46 | /* USER CODE END PM */ |
47 | 47 | ||
48 | /* Private variables ---------------------------------------------------------*/ |
48 | /* Private variables ---------------------------------------------------------*/ |
49 | SPI_HandleTypeDef hspi1; |
49 | SPI_HandleTypeDef hspi1; |
50 | 50 | ||
51 | TIM_HandleTypeDef htim2; |
51 | TIM_HandleTypeDef htim2; |
52 | TIM_HandleTypeDef htim3; |
52 | TIM_HandleTypeDef htim3; |
53 | TIM_HandleTypeDef htim9; |
53 | TIM_HandleTypeDef htim9; |
54 | 54 | ||
Line 105... | Line 105... | ||
105 | if (contexts[dial].knobPos < 0) |
105 | if (contexts[dial].knobPos < 0) |
106 | return -1; |
106 | return -1; |
107 | return cc_display(dial, suppress); |
107 | return cc_display(dial, suppress); |
108 | } |
108 | } |
109 | 109 | ||
110 | void sendString(usart_ctl *ctl, char *string, int length) |
- | |
111 | { |
- | |
112 | int i; |
- | |
113 | for (i = 0; i < length; i++) |
- | |
114 | PutCharSerial(ctl, string[i]); |
- | |
115 | } |
- | |
116 | - | ||
117 | /// \note this code doesnt work so it leaves speed as 9600. |
110 | /// \note this code doesnt work so it leaves speed as 9600. |
118 | /// \brief Setup Bluetooth module |
111 | /// \brief Setup Bluetooth module |
119 | void initModule(usart_ctl *ctl, uint32_t baudRate) |
112 | void initModule(usart_ctl *ctl, uint32_t baudRate) |
120 | { |
113 | { |
121 | char initBuf[30]; |
114 | char initBuf[30]; |
Line 137... | Line 130... | ||
137 | uint8_t rmc_buff[80]; |
130 | uint8_t rmc_buff[80]; |
138 | uint16_t rmc_length; |
131 | uint16_t rmc_length; |
139 | 132 | ||
140 | uint8_t rmc_callback(uint8_t *data, uint16_t length) |
133 | uint8_t rmc_callback(uint8_t *data, uint16_t length) |
141 | { |
134 | { |
142 | rmc_length = length; |
135 | rmc_length = length<sizeof(rmc_buff)?length : sizeof(rmc_buff); |
143 | memcpy(rmc_buff, data, length); |
136 | memcpy(rmc_buff, data, length); |
- | 137 | return 0; |
|
- | 138 | ||
144 | } |
139 | } |
145 | 140 | ||
146 | /* USER CODE END PFP */ |
141 | /* USER CODE END PFP */ |
147 | 142 | ||
148 | /* Private user code ---------------------------------------------------------*/ |
143 | /* Private user code ---------------------------------------------------------*/ |
149 | /* USER CODE BEGIN 0 */ |
144 | /* USER CODE BEGIN 0 */ |
150 | 145 | ||
151 | /* USER CODE END 0 */ |
146 | /* USER CODE END 0 */ |
152 | 147 | ||
153 | /** |
148 | /** |
154 | * @brief The application entry point. |
149 | * @brief The application entry point. |
155 | * @retval int |
150 | * @retval int |
156 | */ |
151 | */ |
157 | int main(void) |
152 | int main(void) |
158 | { |
153 | { |
159 | /* USER CODE BEGIN 1 */ |
154 | /* USER CODE BEGIN 1 */ |
160 | __HAL_RCC_SPI1_CLK_ENABLE(); |
155 | __HAL_RCC_SPI1_CLK_ENABLE(); |
161 | __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port |
156 | __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port |
162 | __HAL_RCC_USART2_CLK_ENABLE(); // debug port |
157 | __HAL_RCC_USART2_CLK_ENABLE(); // debug port |
163 | __HAL_RCC_USART3_CLK_ENABLE(); // Bluetooth port |
158 | __HAL_RCC_USART3_CLK_ENABLE(); // Bluetooth port |
164 | __HAL_RCC_UART4_CLK_ENABLE(); // NMEA0183 port |
159 | __HAL_RCC_UART4_CLK_ENABLE(); // NMEA0183 port |
165 | 160 | ||
166 | __HAL_RCC_TIM3_CLK_ENABLE(); |
161 | __HAL_RCC_TIM3_CLK_ENABLE(); |
167 | 162 | ||
168 | __HAL_RCC_TIM9_CLK_ENABLE(); |
163 | __HAL_RCC_TIM9_CLK_ENABLE(); |
169 | 164 | ||
Line 291... | Line 286... | ||
291 | 286 | ||
292 | while (1) |
287 | while (1) |
293 | { |
288 | { |
294 | 289 | ||
295 | // poll GPS Position/time on UART4 |
290 | // poll GPS Position/time on UART4 |
296 | bool stat = updateLocation(&loc, &uc4); |
291 | (void) updateLocation(&loc, &uc4); |
297 | if (loc.good) |
292 | if (loc.good) |
298 | { |
293 | { |
299 | 294 | ||
300 | loc.good = false; |
295 | loc.good = false; |
301 | } |
296 | } |
Line 371... | Line 366... | ||
371 | if (Info[i].data < Info[i].Min) |
366 | if (Info[i].data < Info[i].Min) |
372 | { |
367 | { |
373 | Info[i].Min = Info[i].data; |
368 | Info[i].Min = Info[i].data; |
374 | } |
369 | } |
375 | 370 | ||
376 | // Send item to BT |
371 | // Send items to BT if it is in connected state |
377 | if (rmc_length) |
372 | if (HAL_GPIO_ReadPin(BT_STATE_GPIO_Port, BT_STATE_Pin) == GPIO_PIN_SET) |
378 | { |
373 | { |
- | 374 | if (rmc_length) |
|
- | 375 | { |
|
379 | sendString(&uc3, rmc_buff, rmc_length); |
376 | sendString(&uc3, rmc_buff, rmc_length); |
380 | rmc_length = 0; |
377 | rmc_length = 0; |
381 | } |
378 | } |
382 | 379 | ||
383 | if (log) |
380 | if (log) |
384 | { |
381 | { |
385 | 382 | ||
386 | char outbuff[100]; |
383 | char outbuff[100]; |
387 | 384 | ||
388 | int cnt = small_sprintf(outbuff, |
385 | int cnt = small_sprintf(outbuff, |
389 | "$PLLOG,%d,%d,%d", |
386 | "$PLLOG,%d,%d,%d", |
390 | Info[i].observation, |
387 | Info[i].observation, |
391 | Info[i].instance, |
388 | Info[i].instance, |
392 | Info[i].data); |
389 | Info[i].data); |
393 | 390 | ||
394 | // NMEA style checksum |
391 | // NMEA style checksum |
395 | int ck; |
392 | int ck; |
396 | int sum = 0; |
393 | int sum = 0; |
397 | for (ck = 1; ck < cnt; ck++) |
394 | for (ck = 1; ck < cnt; ck++) |
398 | sum += outbuff[ck]; |
395 | sum += outbuff[ck]; |
399 | cnt += small_sprintf(outbuff + cnt, "*%02X\n", |
396 | cnt += small_sprintf(outbuff + cnt, "*%02X\n", |
400 | sum & 0xFF); |
397 | sum & 0xFF); |
401 | sendString(&uc3, outbuff, cnt); |
398 | sendString(&uc3, outbuff, cnt); |
- | 399 | } |
|
402 | } |
400 | } |
403 | } |
401 | } |
404 | 402 | ||
405 | // now to display the information |
403 | // now to display the information |
406 | int suppress = DisplayCurrent(0, -1); |
404 | int suppress = DisplayCurrent(0, -1); |
Line 447... | Line 445... | ||
447 | } |
445 | } |
448 | /* USER CODE END 3 */ |
446 | /* USER CODE END 3 */ |
449 | } |
447 | } |
450 | 448 | ||
451 | /** |
449 | /** |
452 | * @brief System Clock Configuration |
450 | * @brief System Clock Configuration |
453 | * @retval None |
451 | * @retval None |
454 | */ |
452 | */ |
455 | void SystemClock_Config(void) |
453 | void SystemClock_Config(void) |
456 | { |
454 | { |
457 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
455 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
458 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
456 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
459 | 457 | ||
460 | /** Configure the main internal regulator output voltage |
458 | /** Configure the main internal regulator output voltage |
461 | */ |
459 | */ |
462 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
460 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
- | 461 | ||
463 | /** Initializes the RCC Oscillators according to the specified parameters |
462 | /** Initializes the RCC Oscillators according to the specified parameters |
464 | * in the RCC_OscInitTypeDef structure. |
463 | * in the RCC_OscInitTypeDef structure. |
465 | */ |
464 | */ |
466 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
465 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
467 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
466 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
468 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
467 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
469 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
468 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
470 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
469 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
471 | RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; |
470 | RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; |
472 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
471 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
473 | { |
472 | { |
474 | Error_Handler(); |
473 | Error_Handler(); |
475 | } |
474 | } |
- | 475 | ||
476 | /** Initializes the CPU, AHB and APB buses clocks |
476 | /** Initializes the CPU, AHB and APB buses clocks |
477 | */ |
477 | */ |
478 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
478 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
- | 479 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
|
479 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
480 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
480 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
481 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
481 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
482 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
482 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
483 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
483 | 484 | ||
Line 486... | Line 487... | ||
486 | Error_Handler(); |
487 | Error_Handler(); |
487 | } |
488 | } |
488 | } |
489 | } |
489 | 490 | ||
490 | /** |
491 | /** |
491 | * @brief SPI1 Initialization Function |
492 | * @brief SPI1 Initialization Function |
492 | * @param None |
493 | * @param None |
493 | * @retval None |
494 | * @retval None |
494 | */ |
495 | */ |
495 | static void MX_SPI1_Init(void) |
496 | static void MX_SPI1_Init(void) |
496 | { |
497 | { |
497 | 498 | ||
498 | /* USER CODE BEGIN SPI1_Init 0 */ |
499 | /* USER CODE BEGIN SPI1_Init 0 */ |
499 | 500 | ||
Line 520... | Line 521... | ||
520 | Error_Handler(); |
521 | Error_Handler(); |
521 | } |
522 | } |
522 | /* USER CODE BEGIN SPI1_Init 2 */ |
523 | /* USER CODE BEGIN SPI1_Init 2 */ |
523 | 524 | ||
524 | /* USER CODE END SPI1_Init 2 */ |
525 | /* USER CODE END SPI1_Init 2 */ |
- | 526 | ||
525 | } |
527 | } |
526 | 528 | ||
527 | /** |
529 | /** |
528 | * @brief TIM2 Initialization Function |
530 | * @brief TIM2 Initialization Function |
529 | * @param None |
531 | * @param None |
530 | * @retval None |
532 | * @retval None |
531 | */ |
533 | */ |
532 | static void MX_TIM2_Init(void) |
534 | static void MX_TIM2_Init(void) |
533 | { |
535 | { |
534 | 536 | ||
535 | /* USER CODE BEGIN TIM2_Init 0 */ |
537 | /* USER CODE BEGIN TIM2_Init 0 */ |
536 | 538 | ||
Line 564... | Line 566... | ||
564 | Error_Handler(); |
566 | Error_Handler(); |
565 | } |
567 | } |
566 | /* USER CODE BEGIN TIM2_Init 2 */ |
568 | /* USER CODE BEGIN TIM2_Init 2 */ |
567 | 569 | ||
568 | /* USER CODE END TIM2_Init 2 */ |
570 | /* USER CODE END TIM2_Init 2 */ |
- | 571 | ||
569 | } |
572 | } |
570 | 573 | ||
571 | /** |
574 | /** |
572 | * @brief TIM3 Initialization Function |
575 | * @brief TIM3 Initialization Function |
573 | * @param None |
576 | * @param None |
574 | * @retval None |
577 | * @retval None |
575 | */ |
578 | */ |
576 | static void MX_TIM3_Init(void) |
579 | static void MX_TIM3_Init(void) |
577 | { |
580 | { |
578 | 581 | ||
579 | /* USER CODE BEGIN TIM3_Init 0 */ |
582 | /* USER CODE BEGIN TIM3_Init 0 */ |
580 | 583 | ||
Line 612... | Line 615... | ||
612 | Error_Handler(); |
615 | Error_Handler(); |
613 | } |
616 | } |
614 | /* USER CODE BEGIN TIM3_Init 2 */ |
617 | /* USER CODE BEGIN TIM3_Init 2 */ |
615 | 618 | ||
616 | /* USER CODE END TIM3_Init 2 */ |
619 | /* USER CODE END TIM3_Init 2 */ |
- | 620 | ||
617 | } |
621 | } |
618 | 622 | ||
619 | /** |
623 | /** |
620 | * @brief TIM9 Initialization Function |
624 | * @brief TIM9 Initialization Function |
621 | * @param None |
625 | * @param None |
622 | * @retval None |
626 | * @retval None |
623 | */ |
627 | */ |
624 | static void MX_TIM9_Init(void) |
628 | static void MX_TIM9_Init(void) |
625 | { |
629 | { |
626 | 630 | ||
627 | /* USER CODE BEGIN TIM9_Init 0 */ |
631 | /* USER CODE BEGIN TIM9_Init 0 */ |
628 | 632 | ||
Line 660... | Line 664... | ||
660 | Error_Handler(); |
664 | Error_Handler(); |
661 | } |
665 | } |
662 | /* USER CODE BEGIN TIM9_Init 2 */ |
666 | /* USER CODE BEGIN TIM9_Init 2 */ |
663 | 667 | ||
664 | /* USER CODE END TIM9_Init 2 */ |
668 | /* USER CODE END TIM9_Init 2 */ |
- | 669 | ||
665 | } |
670 | } |
666 | 671 | ||
667 | /** |
672 | /** |
668 | * @brief UART4 Initialization Function |
673 | * @brief UART4 Initialization Function |
669 | * @param None |
674 | * @param None |
670 | * @retval None |
675 | * @retval None |
671 | */ |
676 | */ |
672 | static void MX_UART4_Init(void) |
677 | static void MX_UART4_Init(void) |
673 | { |
678 | { |
674 | 679 | ||
675 | /* USER CODE BEGIN UART4_Init 0 */ |
680 | /* USER CODE BEGIN UART4_Init 0 */ |
676 | 681 | ||
Line 692... | Line 697... | ||
692 | Error_Handler(); |
697 | Error_Handler(); |
693 | } |
698 | } |
694 | /* USER CODE BEGIN UART4_Init 2 */ |
699 | /* USER CODE BEGIN UART4_Init 2 */ |
695 | 700 | ||
696 | /* USER CODE END UART4_Init 2 */ |
701 | /* USER CODE END UART4_Init 2 */ |
- | 702 | ||
697 | } |
703 | } |
698 | 704 | ||
699 | /** |
705 | /** |
700 | * @brief USART1 Initialization Function |
706 | * @brief USART1 Initialization Function |
701 | * @param None |
707 | * @param None |
702 | * @retval None |
708 | * @retval None |
703 | */ |
709 | */ |
704 | static void MX_USART1_UART_Init(void) |
710 | static void MX_USART1_UART_Init(void) |
705 | { |
711 | { |
706 | 712 | ||
707 | /* USER CODE BEGIN USART1_Init 0 */ |
713 | /* USER CODE BEGIN USART1_Init 0 */ |
708 | 714 | ||
Line 724... | Line 730... | ||
724 | Error_Handler(); |
730 | Error_Handler(); |
725 | } |
731 | } |
726 | /* USER CODE BEGIN USART1_Init 2 */ |
732 | /* USER CODE BEGIN USART1_Init 2 */ |
727 | 733 | ||
728 | /* USER CODE END USART1_Init 2 */ |
734 | /* USER CODE END USART1_Init 2 */ |
- | 735 | ||
729 | } |
736 | } |
730 | 737 | ||
731 | /** |
738 | /** |
732 | * @brief USART2 Initialization Function |
739 | * @brief USART2 Initialization Function |
733 | * @param None |
740 | * @param None |
734 | * @retval None |
741 | * @retval None |
735 | */ |
742 | */ |
736 | static void MX_USART2_UART_Init(void) |
743 | static void MX_USART2_UART_Init(void) |
737 | { |
744 | { |
738 | 745 | ||
739 | /* USER CODE BEGIN USART2_Init 0 */ |
746 | /* USER CODE BEGIN USART2_Init 0 */ |
740 | 747 | ||
Line 756... | Line 763... | ||
756 | Error_Handler(); |
763 | Error_Handler(); |
757 | } |
764 | } |
758 | /* USER CODE BEGIN USART2_Init 2 */ |
765 | /* USER CODE BEGIN USART2_Init 2 */ |
759 | 766 | ||
760 | /* USER CODE END USART2_Init 2 */ |
767 | /* USER CODE END USART2_Init 2 */ |
- | 768 | ||
761 | } |
769 | } |
762 | 770 | ||
763 | /** |
771 | /** |
764 | * @brief USART3 Initialization Function |
772 | * @brief USART3 Initialization Function |
765 | * @param None |
773 | * @param None |
766 | * @retval None |
774 | * @retval None |
767 | */ |
775 | */ |
768 | static void MX_USART3_UART_Init(void) |
776 | static void MX_USART3_UART_Init(void) |
769 | { |
777 | { |
770 | 778 | ||
771 | /* USER CODE BEGIN USART3_Init 0 */ |
779 | /* USER CODE BEGIN USART3_Init 0 */ |
772 | 780 | ||
Line 788... | Line 796... | ||
788 | Error_Handler(); |
796 | Error_Handler(); |
789 | } |
797 | } |
790 | /* USER CODE BEGIN USART3_Init 2 */ |
798 | /* USER CODE BEGIN USART3_Init 2 */ |
791 | 799 | ||
792 | /* USER CODE END USART3_Init 2 */ |
800 | /* USER CODE END USART3_Init 2 */ |
- | 801 | ||
793 | } |
802 | } |
794 | 803 | ||
795 | /** |
804 | /** |
796 | * @brief GPIO Initialization Function |
805 | * @brief GPIO Initialization Function |
797 | * @param None |
806 | * @param None |
798 | * @retval None |
807 | * @retval None |
799 | */ |
808 | */ |
800 | static void MX_GPIO_Init(void) |
809 | static void MX_GPIO_Init(void) |
801 | { |
810 | { |
802 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
811 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
803 | 812 | ||
804 | /* GPIO Ports Clock Enable */ |
813 | /* GPIO Ports Clock Enable */ |
Line 809... | Line 818... | ||
809 | 818 | ||
810 | /*Configure GPIO pin Output Level */ |
819 | /*Configure GPIO pin Output Level */ |
811 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
820 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
812 | 821 | ||
813 | /*Configure GPIO pin Output Level */ |
822 | /*Configure GPIO pin Output Level */ |
814 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin | BT_BUTTON_Pin, GPIO_PIN_RESET); |
823 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin|BT_BUTTON_Pin, GPIO_PIN_RESET); |
815 | 824 | ||
816 | /*Configure GPIO pin Output Level */ |
825 | /*Configure GPIO pin Output Level */ |
817 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin | POWER_LATCH_Pin | USB_PWR_Pin, GPIO_PIN_RESET); |
826 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|POWER_LATCH_Pin|USB_PWR_Pin, GPIO_PIN_RESET); |
818 | 827 | ||
819 | /*Configure GPIO pin Output Level */ |
828 | /*Configure GPIO pin Output Level */ |
820 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
829 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
821 | 830 | ||
822 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
831 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
823 | GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_CD_Pin; |
832 | GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI_CD_Pin; |
824 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
833 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
825 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
834 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
826 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
835 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
827 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
836 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
828 | 837 | ||
829 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
838 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
830 | GPIO_InitStruct.Pin = SPI_RESET_Pin | SPI_NSS2_Pin | POWER_LATCH_Pin | USB_PWR_Pin; |
839 | GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|POWER_LATCH_Pin|USB_PWR_Pin; |
831 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
840 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
832 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
841 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
833 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
842 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
834 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
843 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
835 | 844 | ||
836 | /*Configure GPIO pins : SW1_PUSH_Pin SW2_PUSH_Pin */ |
845 | /*Configure GPIO pins : BT_STATE_Pin SW1_PUSH_Pin SW2_PUSH_Pin */ |
837 | GPIO_InitStruct.Pin = SW1_PUSH_Pin | SW2_PUSH_Pin; |
846 | GPIO_InitStruct.Pin = BT_STATE_Pin|SW1_PUSH_Pin|SW2_PUSH_Pin; |
838 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
847 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
839 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
848 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
840 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
849 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
841 | 850 | ||
842 | /*Configure GPIO pin : IGNITION_Pin */ |
851 | /*Configure GPIO pin : IGNITION_Pin */ |
Line 849... | Line 858... | ||
849 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
858 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
850 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
859 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
851 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
860 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
852 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
861 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
853 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
862 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
- | 863 | ||
854 | } |
864 | } |
855 | 865 | ||
856 | /* USER CODE BEGIN 4 */ |
866 | /* USER CODE BEGIN 4 */ |
857 | 867 | ||
858 | /* USER CODE END 4 */ |
868 | /* USER CODE END 4 */ |
859 | 869 | ||
860 | /** |
870 | /** |
861 | * @brief This function is executed in case of error occurrence. |
871 | * @brief This function is executed in case of error occurrence. |
862 | * @retval None |
872 | * @retval None |
863 | */ |
873 | */ |
864 | void Error_Handler(void) |
874 | void Error_Handler(void) |
865 | { |
875 | { |
866 | /* USER CODE BEGIN Error_Handler_Debug */ |
876 | /* USER CODE BEGIN Error_Handler_Debug */ |
867 | /* User can add his own implementation to report the HAL error return state */ |
877 | /* User can add his own implementation to report the HAL error return state */ |
868 | 878 | ||
869 | /* USER CODE END Error_Handler_Debug */ |
879 | /* USER CODE END Error_Handler_Debug */ |
870 | } |
880 | } |
871 | 881 | ||
872 | #ifdef USE_FULL_ASSERT |
882 | #ifdef USE_FULL_ASSERT |
873 | /** |
883 | /** |
874 | * @brief Reports the name of the source file and the source line number |
884 | * @brief Reports the name of the source file and the source line number |
875 | * where the assert_param error has occurred. |
885 | * where the assert_param error has occurred. |
876 | * @param file: pointer to the source file name |
886 | * @param file: pointer to the source file name |
877 | * @param line: assert_param error line source number |
887 | * @param line: assert_param error line source number |
878 | * @retval None |
888 | * @retval None |
879 | */ |
889 | */ |
880 | void assert_failed(uint8_t *file, uint32_t line) |
890 | void assert_failed(uint8_t *file, uint32_t line) |
881 | { |
891 | { |
882 | /* USER CODE BEGIN 6 */ |
892 | /* USER CODE BEGIN 6 */ |
883 | /* User can add his own implementation to report the file name and line number, |
893 | /* User can add his own implementation to report the file name and line number, |
884 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
894 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
885 | /* USER CODE END 6 */ |
895 | /* USER CODE END 6 */ |
886 | } |
896 | } |
887 | #endif /* USE_FULL_ASSERT */ |
897 | #endif /* USE_FULL_ASSERT */ |
888 | - | ||
889 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |