Subversion Repositories EngineBay2

Rev

Rev 54 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 54 Rev 55
Line 21... Line 21...
21
#include "main.h"
21
#include "main.h"
22
 
22
 
23
/* Private includes ----------------------------------------------------------*/
23
/* Private includes ----------------------------------------------------------*/
24
/* USER CODE BEGIN Includes */
24
/* USER CODE BEGIN Includes */
25
#include <string.h>
25
#include <string.h>
-
 
26
#include <math.h>
26
#include "libSerial/serial.h"
27
#include "libSerial/serial.h"
27
#include "libPLX/plx.h"
28
#include "libPLX/plx.h"
28
#include "libPLX/commsLib.h"
29
#include "libPLX/commsLib.h"
29
#include "misc.h"
30
#include "misc.h"
30
 
31
 
31
#include "libIgnTiming/rpm.h"
32
#include "libIgnTiming/rpm.h"
32
 
33
 
-
 
34
 
-
 
35
 
33
/* USER CODE END Includes */
36
/* USER CODE END Includes */
34
 
37
 
35
/* Private typedef -----------------------------------------------------------*/
38
/* Private typedef -----------------------------------------------------------*/
36
/* USER CODE BEGIN PTD */
39
/* USER CODE BEGIN PTD */
37
 
40
 
Line 175... Line 178...
175
 
178
 
176
FunctionalState CHT_Enable = ENABLE;
179
FunctionalState CHT_Enable = ENABLE;
177
 
180
 
178
#define CORR 3
181
#define CORR 3
179
 
182
 
-
 
183
 
-
 
184
typedef struct  
-
 
185
{
-
 
186
  uint16_t store[TEMP_CORR];
-
 
187
  uint16_t result;
-
 
188
} tempObservation_t;
-
 
189
 
180
uint16_t Temp_Observations[NUM_SPI_TEMP_SENS] = {[0 ... NUM_SPI_TEMP_SENS - 1] = 0};
190
tempObservation_t Temp_Observations[NUM_SPI_TEMP_SENS];
-
 
191
 
-
 
192
void ResetTemp()
-
 
193
{
-
 
194
  int i,j;
-
 
195
  for (i=0;i<NUM_SPI_TEMP_SENS;i++)
-
 
196
  {
-
 
197
    Temp_Observations[i].result = 0;
-
 
198
    for (j=0;j<TEMP_CORR;j++)
-
 
199
      Temp_Observations[i].store[j]=0;
-
 
200
  }
-
 
201
}
-
 
202
 
-
 
203
void AddTempReading(uint16_t reading, int channel)
-
 
204
{
-
 
205
  int j;
-
 
206
  for (j=TEMP_CORR-1; j>=1 ; j--)
-
 
207
  {
-
 
208
    Temp_Observations[channel].store[j] = Temp_Observations[channel].store[j-1];
-
 
209
  }
-
 
210
  Temp_Observations[channel].store[0] = reading;
-
 
211
 
-
 
212
  // are all the stored values close to the current reading, if so allow it through
-
 
213
  // the check here is for 5 degrees C 
-
 
214
  char good = 1;
-
 
215
  for (j=1; j<TEMP_CORR; j++)
-
 
216
    if (abs((int)Temp_Observations[channel].store[j]- (int)reading)>5)
-
 
217
      good = 0;
-
 
218
 
-
 
219
  if (good)
-
 
220
    Temp_Observations[channel].result = reading;
-
 
221
}
-
 
222
 
181
 
223
 
182
/// \param item The array index to send
224
/// \param item The array index to send
183
/// \param type the code to use for this observation
225
/// \param type the code to use for this observation
184
void ProcessTemp(struct usart_ctl * handle,char item, enum PLX_Observations type)
226
void ProcessTemp(struct usart_ctl * handle,char item, enum PLX_Observations type)
185
{
227
{
186
  if (item > NUM_SPI_TEMP_SENS)
228
  if (item > NUM_SPI_TEMP_SENS)
187
    return;
229
    return;
188
 
230
 
189
  sendPlxInfo(handle, type , Temp_Observations[(int)item]);
231
  sendPlxInfo(handle, type , Temp_Observations[(int)item].result);
190
 
232
 
191
}
233
}
192
 
234
 
193
/// \brief Reset the temperature chip select system
235
/// \brief Reset the temperature chip select system
194
void resetTempCS(void)
236
void resetTempCS(void)
Line 344... Line 386...
344
  ProcessOilPress(handle);
386
  ProcessOilPress(handle);
345
}
387
}
346
/* USER CODE END 0 */
388
/* USER CODE END 0 */
347
 
389
 
348
/**
390
/**
349
 * @brief  The application entry point.
391
  * @brief  The application entry point.
350
 * @retval int
392
  * @retval int
351
 */
393
  */
352
int main(void)
394
int main(void)
353
{
395
{
-
 
396
 
354
  /* USER CODE BEGIN 1 */
397
  /* USER CODE BEGIN 1 */
355
 
398
 
356
  /* USER CODE END 1 */
399
  /* USER CODE END 1 */
357
 
400
 
358
  /* MCU Configuration--------------------------------------------------------*/
401
  /* MCU Configuration--------------------------------------------------------*/
Line 402... Line 445...
402
 
445
 
403
  HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Samples, ADC_CHANNELS);
446
  HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_Samples, ADC_CHANNELS);
404
 
447
 
405
  HAL_ADC_Start_IT(&hadc1);
448
  HAL_ADC_Start_IT(&hadc1);
406
 
449
 
-
 
450
    ResetTemp(); // reset temperature store 
-
 
451
 
407
  HAL_TIM_Base_MspInit(&htim4);
452
  HAL_TIM_Base_MspInit(&htim4);
408
  HAL_TIM_Base_Start_IT(&htim4);
453
  HAL_TIM_Base_Start_IT(&htim4);
409
 
454
 
410
  // initialise all the STMCubeMX stuff
455
  // initialise all the STMCubeMX stuff
411
  HAL_TIM_Base_MspInit(&htim2);
456
  HAL_TIM_Base_MspInit(&htim2);
Line 493... Line 538...
493
 
538
 
494
  /* USER CODE END 3 */
539
  /* USER CODE END 3 */
495
}
540
}
496
 
541
 
497
/**
542
/**
498
 * @brief System Clock Configuration
543
  * @brief System Clock Configuration
499
 * @retval None
544
  * @retval None
500
 */
545
  */
501
void SystemClock_Config(void)
546
void SystemClock_Config(void)
502
{
547
{
503
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
548
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
504
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
549
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
505
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
550
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
506
 
551
 
507
  /** Initializes the RCC Oscillators according to the specified parameters
552
  /** Initializes the RCC Oscillators according to the specified parameters
508
   * in the RCC_OscInitTypeDef structure.
553
  * in the RCC_OscInitTypeDef structure.
509
   */
554
  */
510
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE;
555
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
511
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
556
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
512
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
557
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
513
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
558
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
514
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
559
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
515
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
560
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
Line 519... Line 564...
519
  {
564
  {
520
    Error_Handler();
565
    Error_Handler();
521
  }
566
  }
522
 
567
 
523
  /** Initializes the CPU, AHB and APB buses clocks
568
  /** Initializes the CPU, AHB and APB buses clocks
524
   */
569
  */
525
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
570
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
-
 
571
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
526
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
572
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
527
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
573
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
528
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
574
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
529
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
575
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
530
 
576
 
Line 539... Line 585...
539
    Error_Handler();
585
    Error_Handler();
540
  }
586
  }
541
}
587
}
542
 
588
 
543
/**
589
/**
544
 * @brief ADC1 Initialization Function
590
  * @brief ADC1 Initialization Function
545
 * @param None
591
  * @param None
546
 * @retval None
592
  * @retval None
547
 */
593
  */
548
static void MX_ADC1_Init(void)
594
static void MX_ADC1_Init(void)
549
{
595
{
550
 
596
 
551
  /* USER CODE BEGIN ADC1_Init 0 */
597
  /* USER CODE BEGIN ADC1_Init 0 */
552
 
598
 
Line 557... Line 603...
557
  /* USER CODE BEGIN ADC1_Init 1 */
603
  /* USER CODE BEGIN ADC1_Init 1 */
558
 
604
 
559
  /* USER CODE END ADC1_Init 1 */
605
  /* USER CODE END ADC1_Init 1 */
560
 
606
 
561
  /** Common config
607
  /** Common config
562
   */
608
  */
563
  hadc1.Instance = ADC1;
609
  hadc1.Instance = ADC1;
564
  hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
610
  hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
565
  hadc1.Init.ContinuousConvMode = DISABLE;
611
  hadc1.Init.ContinuousConvMode = DISABLE;
566
  hadc1.Init.DiscontinuousConvMode = DISABLE;
612
  hadc1.Init.DiscontinuousConvMode = DISABLE;
567
  hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
613
  hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
Line 571... Line 617...
571
  {
617
  {
572
    Error_Handler();
618
    Error_Handler();
573
  }
619
  }
574
 
620
 
575
  /** Configure Regular Channel
621
  /** Configure Regular Channel
576
   */
622
  */
577
  sConfig.Channel = ADC_CHANNEL_0;
623
  sConfig.Channel = ADC_CHANNEL_0;
578
  sConfig.Rank = ADC_REGULAR_RANK_1;
624
  sConfig.Rank = ADC_REGULAR_RANK_1;
579
  sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
625
  sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
580
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
626
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
581
  {
627
  {
582
    Error_Handler();
628
    Error_Handler();
583
  }
629
  }
584
 
630
 
585
  /** Configure Regular Channel
631
  /** Configure Regular Channel
586
   */
632
  */
587
  sConfig.Channel = ADC_CHANNEL_1;
633
  sConfig.Channel = ADC_CHANNEL_1;
588
  sConfig.Rank = ADC_REGULAR_RANK_2;
634
  sConfig.Rank = ADC_REGULAR_RANK_2;
589
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
635
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
590
  {
636
  {
591
    Error_Handler();
637
    Error_Handler();
592
  }
638
  }
593
 
639
 
594
  /** Configure Regular Channel
640
  /** Configure Regular Channel
595
   */
641
  */
596
  sConfig.Channel = ADC_CHANNEL_2;
642
  sConfig.Channel = ADC_CHANNEL_2;
597
  sConfig.Rank = ADC_REGULAR_RANK_3;
643
  sConfig.Rank = ADC_REGULAR_RANK_3;
598
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
644
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
599
  {
645
  {
600
    Error_Handler();
646
    Error_Handler();
601
  }
647
  }
602
 
648
 
603
  /** Configure Regular Channel
649
  /** Configure Regular Channel
604
   */
650
  */
605
  sConfig.Channel = ADC_CHANNEL_3;
651
  sConfig.Channel = ADC_CHANNEL_3;
606
  sConfig.Rank = ADC_REGULAR_RANK_4;
652
  sConfig.Rank = ADC_REGULAR_RANK_4;
607
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
653
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
608
  {
654
  {
609
    Error_Handler();
655
    Error_Handler();
610
  }
656
  }
611
 
657
 
612
  /** Configure Regular Channel
658
  /** Configure Regular Channel
613
   */
659
  */
614
  sConfig.Channel = ADC_CHANNEL_4;
660
  sConfig.Channel = ADC_CHANNEL_4;
615
  sConfig.Rank = ADC_REGULAR_RANK_5;
661
  sConfig.Rank = ADC_REGULAR_RANK_5;
616
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
662
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
617
  {
663
  {
618
    Error_Handler();
664
    Error_Handler();
619
  }
665
  }
620
 
666
 
621
  /** Configure Regular Channel
667
  /** Configure Regular Channel
622
   */
668
  */
623
  sConfig.Channel = ADC_CHANNEL_VREFINT;
669
  sConfig.Channel = ADC_CHANNEL_VREFINT;
624
  sConfig.Rank = ADC_REGULAR_RANK_6;
670
  sConfig.Rank = ADC_REGULAR_RANK_6;
625
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
671
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
626
  {
672
  {
627
    Error_Handler();
673
    Error_Handler();
628
  }
674
  }
629
 
675
 
630
  /** Configure Regular Channel
676
  /** Configure Regular Channel
631
   */
677
  */
632
  sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
678
  sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
633
  sConfig.Rank = ADC_REGULAR_RANK_7;
679
  sConfig.Rank = ADC_REGULAR_RANK_7;
634
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
680
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
635
  {
681
  {
636
    Error_Handler();
682
    Error_Handler();
637
  }
683
  }
638
  /* USER CODE BEGIN ADC1_Init 2 */
684
  /* USER CODE BEGIN ADC1_Init 2 */
639
 
685
 
640
  /* USER CODE END ADC1_Init 2 */
686
  /* USER CODE END ADC1_Init 2 */
-
 
687
 
641
}
688
}
642
 
689
 
643
/**
690
/**
644
 * @brief CAN Initialization Function
691
  * @brief CAN Initialization Function
645
 * @param None
692
  * @param None
646
 * @retval None
693
  * @retval None
647
 */
694
  */
648
static void MX_CAN_Init(void)
695
static void MX_CAN_Init(void)
649
{
696
{
650
 
697
 
651
  /* USER CODE BEGIN CAN_Init 0 */
698
  /* USER CODE BEGIN CAN_Init 0 */
652
 
699
 
Line 672... Line 719...
672
    Error_Handler();
719
    Error_Handler();
673
  }
720
  }
674
  /* USER CODE BEGIN CAN_Init 2 */
721
  /* USER CODE BEGIN CAN_Init 2 */
675
 
722
 
676
  /* USER CODE END CAN_Init 2 */
723
  /* USER CODE END CAN_Init 2 */
-
 
724
 
677
}
725
}
678
 
726
 
679
/**
727
/**
680
 * @brief IWDG Initialization Function
728
  * @brief IWDG Initialization Function
681
 * @param None
729
  * @param None
682
 * @retval None
730
  * @retval None
683
 */
731
  */
684
static void MX_IWDG_Init(void)
732
static void MX_IWDG_Init(void)
685
{
733
{
686
 
734
 
687
  /* USER CODE BEGIN IWDG_Init 0 */
735
  /* USER CODE BEGIN IWDG_Init 0 */
688
 
736
 
Line 699... Line 747...
699
    Error_Handler();
747
    Error_Handler();
700
  }
748
  }
701
  /* USER CODE BEGIN IWDG_Init 2 */
749
  /* USER CODE BEGIN IWDG_Init 2 */
702
 
750
 
703
  /* USER CODE END IWDG_Init 2 */
751
  /* USER CODE END IWDG_Init 2 */
-
 
752
 
704
}
753
}
705
 
754
 
706
/**
755
/**
707
 * @brief SPI1 Initialization Function
756
  * @brief SPI1 Initialization Function
708
 * @param None
757
  * @param None
709
 * @retval None
758
  * @retval None
710
 */
759
  */
711
static void MX_SPI1_Init(void)
760
static void MX_SPI1_Init(void)
712
{
761
{
713
 
762
 
714
  /* USER CODE BEGIN SPI1_Init 0 */
763
  /* USER CODE BEGIN SPI1_Init 0 */
715
 
764
 
Line 736... Line 785...
736
    Error_Handler();
785
    Error_Handler();
737
  }
786
  }
738
  /* USER CODE BEGIN SPI1_Init 2 */
787
  /* USER CODE BEGIN SPI1_Init 2 */
739
 
788
 
740
  /* USER CODE END SPI1_Init 2 */
789
  /* USER CODE END SPI1_Init 2 */
-
 
790
 
741
}
791
}
742
 
792
 
743
/**
793
/**
744
 * @brief TIM2 Initialization Function
794
  * @brief TIM2 Initialization Function
745
 * @param None
795
  * @param None
746
 * @retval None
796
  * @retval None
747
 */
797
  */
748
static void MX_TIM2_Init(void)
798
static void MX_TIM2_Init(void)
749
{
799
{
750
 
800
 
751
  /* USER CODE BEGIN TIM2_Init 0 */
801
  /* USER CODE BEGIN TIM2_Init 0 */
752
 
802
 
Line 800... Line 850...
800
    Error_Handler();
850
    Error_Handler();
801
  }
851
  }
802
  /* USER CODE BEGIN TIM2_Init 2 */
852
  /* USER CODE BEGIN TIM2_Init 2 */
803
 
853
 
804
  /* USER CODE END TIM2_Init 2 */
854
  /* USER CODE END TIM2_Init 2 */
-
 
855
 
805
}
856
}
806
 
857
 
807
/**
858
/**
808
 * @brief TIM3 Initialization Function
859
  * @brief TIM3 Initialization Function
809
 * @param None
860
  * @param None
810
 * @retval None
861
  * @retval None
811
 */
862
  */
812
static void MX_TIM3_Init(void)
863
static void MX_TIM3_Init(void)
813
{
864
{
814
 
865
 
815
  /* USER CODE BEGIN TIM3_Init 0 */
866
  /* USER CODE BEGIN TIM3_Init 0 */
816
 
867
 
Line 861... Line 912...
861
    Error_Handler();
912
    Error_Handler();
862
  }
913
  }
863
  /* USER CODE BEGIN TIM3_Init 2 */
914
  /* USER CODE BEGIN TIM3_Init 2 */
864
 
915
 
865
  /* USER CODE END TIM3_Init 2 */
916
  /* USER CODE END TIM3_Init 2 */
-
 
917
 
866
}
918
}
867
 
919
 
868
/**
920
/**
869
 * @brief TIM4 Initialization Function
921
  * @brief TIM4 Initialization Function
870
 * @param None
922
  * @param None
871
 * @retval None
923
  * @retval None
872
 */
924
  */
873
static void MX_TIM4_Init(void)
925
static void MX_TIM4_Init(void)
874
{
926
{
875
 
927
 
876
  /* USER CODE BEGIN TIM4_Init 0 */
928
  /* USER CODE BEGIN TIM4_Init 0 */
877
 
929
 
Line 905... Line 957...
905
    Error_Handler();
957
    Error_Handler();
906
  }
958
  }
907
  /* USER CODE BEGIN TIM4_Init 2 */
959
  /* USER CODE BEGIN TIM4_Init 2 */
908
 
960
 
909
  /* USER CODE END TIM4_Init 2 */
961
  /* USER CODE END TIM4_Init 2 */
-
 
962
 
910
}
963
}
911
 
964
 
912
/**
965
/**
913
 * @brief USART1 Initialization Function
966
  * @brief USART1 Initialization Function
914
 * @param None
967
  * @param None
915
 * @retval None
968
  * @retval None
916
 */
969
  */
917
static void MX_USART1_UART_Init(void)
970
static void MX_USART1_UART_Init(void)
918
{
971
{
919
 
972
 
920
  /* USER CODE BEGIN USART1_Init 0 */
973
  /* USER CODE BEGIN USART1_Init 0 */
921
 
974
 
Line 937... Line 990...
937
    Error_Handler();
990
    Error_Handler();
938
  }
991
  }
939
  /* USER CODE BEGIN USART1_Init 2 */
992
  /* USER CODE BEGIN USART1_Init 2 */
940
 
993
 
941
  /* USER CODE END USART1_Init 2 */
994
  /* USER CODE END USART1_Init 2 */
-
 
995
 
942
}
996
}
943
 
997
 
944
/**
998
/**
945
 * Enable DMA controller clock
999
  * Enable DMA controller clock
946
 */
1000
  */
947
static void MX_DMA_Init(void)
1001
static void MX_DMA_Init(void)
948
{
1002
{
949
 
1003
 
950
  /* DMA controller clock enable */
1004
  /* DMA controller clock enable */
951
  __HAL_RCC_DMA1_CLK_ENABLE();
1005
  __HAL_RCC_DMA1_CLK_ENABLE();
952
 
1006
 
953
  /* DMA interrupt init */
1007
  /* DMA interrupt init */
954
  /* DMA1_Channel1_IRQn interrupt configuration */
1008
  /* DMA1_Channel1_IRQn interrupt configuration */
955
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
1009
  HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
956
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
1010
  HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
-
 
1011
 
957
}
1012
}
958
 
1013
 
959
/**
1014
/**
960
 * @brief GPIO Initialization Function
1015
  * @brief GPIO Initialization Function
961
 * @param None
1016
  * @param None
962
 * @retval None
1017
  * @retval None
963
 */
1018
  */
964
static void MX_GPIO_Init(void)
1019
static void MX_GPIO_Init(void)
965
{
1020
{
966
  GPIO_InitTypeDef GPIO_InitStruct = {0};
1021
  GPIO_InitTypeDef GPIO_InitStruct = {0};
967
  /* USER CODE BEGIN MX_GPIO_Init_1 */
1022
/* USER CODE BEGIN MX_GPIO_Init_1 */
968
  /* USER CODE END MX_GPIO_Init_1 */
1023
/* USER CODE END MX_GPIO_Init_1 */
969
 
1024
 
970
  /* GPIO Ports Clock Enable */
1025
  /* GPIO Ports Clock Enable */
971
  __HAL_RCC_GPIOC_CLK_ENABLE();
1026
  __HAL_RCC_GPIOC_CLK_ENABLE();
972
  __HAL_RCC_GPIOD_CLK_ENABLE();
1027
  __HAL_RCC_GPIOD_CLK_ENABLE();
973
  __HAL_RCC_GPIOA_CLK_ENABLE();
1028
  __HAL_RCC_GPIOA_CLK_ENABLE();
Line 975... Line 1030...
975
 
1030
 
976
  /*Configure GPIO pin Output Level */
1031
  /*Configure GPIO pin Output Level */
977
  HAL_GPIO_WritePin(LED_Blink_GPIO_Port, LED_Blink_Pin, GPIO_PIN_RESET);
1032
  HAL_GPIO_WritePin(LED_Blink_GPIO_Port, LED_Blink_Pin, GPIO_PIN_RESET);
978
 
1033
 
979
  /*Configure GPIO pin Output Level */
1034
  /*Configure GPIO pin Output Level */
980
  HAL_GPIO_WritePin(GPIOB, SPI_CS_Clk_Pin | SPI_CS_D_Pin | ENA_AUX_5V_Pin, GPIO_PIN_RESET);
1035
  HAL_GPIO_WritePin(GPIOB, SPI_CS_Clk_Pin|SPI_CS_D_Pin|ENA_AUX_5V_Pin, GPIO_PIN_RESET);
981
 
1036
 
982
  /*Configure GPIO pin : LED_Blink_Pin */
1037
  /*Configure GPIO pin : LED_Blink_Pin */
983
  GPIO_InitStruct.Pin = LED_Blink_Pin;
1038
  GPIO_InitStruct.Pin = LED_Blink_Pin;
984
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
1039
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
985
  GPIO_InitStruct.Pull = GPIO_NOPULL;
1040
  GPIO_InitStruct.Pull = GPIO_NOPULL;
986
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
1041
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
987
  HAL_GPIO_Init(LED_Blink_GPIO_Port, &GPIO_InitStruct);
1042
  HAL_GPIO_Init(LED_Blink_GPIO_Port, &GPIO_InitStruct);
988
 
1043
 
989
  /*Configure GPIO pins : SPI_CS_Clk_Pin SPI_CS_D_Pin ENA_AUX_5V_Pin */
1044
  /*Configure GPIO pins : SPI_CS_Clk_Pin SPI_CS_D_Pin */
990
  GPIO_InitStruct.Pin = SPI_CS_Clk_Pin | SPI_CS_D_Pin | ENA_AUX_5V_Pin;
1045
  GPIO_InitStruct.Pin = SPI_CS_Clk_Pin|SPI_CS_D_Pin;
991
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
1046
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
992
  GPIO_InitStruct.Pull = GPIO_NOPULL;
1047
  GPIO_InitStruct.Pull = GPIO_NOPULL;
993
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
1048
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
994
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
1049
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
995
 
1050
 
996
  /*Configure GPIO pin : STARTER_ON_Pin */
1051
  /*Configure GPIO pin : STARTER_ON_Pin */
997
  GPIO_InitStruct.Pin = STARTER_ON_Pin;
1052
  GPIO_InitStruct.Pin = STARTER_ON_Pin;
998
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
1053
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
999
  GPIO_InitStruct.Pull = GPIO_NOPULL;
1054
  GPIO_InitStruct.Pull = GPIO_NOPULL;
1000
  HAL_GPIO_Init(STARTER_ON_GPIO_Port, &GPIO_InitStruct);
1055
  HAL_GPIO_Init(STARTER_ON_GPIO_Port, &GPIO_InitStruct);
1001
 
1056
 
-
 
1057
  /*Configure GPIO pin : ENA_AUX_5V_Pin */
-
 
1058
  GPIO_InitStruct.Pin = ENA_AUX_5V_Pin;
-
 
1059
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
-
 
1060
  GPIO_InitStruct.Pull = GPIO_NOPULL;
-
 
1061
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
-
 
1062
  HAL_GPIO_Init(ENA_AUX_5V_GPIO_Port, &GPIO_InitStruct);
-
 
1063
 
1002
  /* USER CODE BEGIN MX_GPIO_Init_2 */
1064
/* USER CODE BEGIN MX_GPIO_Init_2 */
1003
  /* USER CODE END MX_GPIO_Init_2 */
1065
/* USER CODE END MX_GPIO_Init_2 */
1004
}
1066
}
1005
 
1067
 
1006
/* USER CODE BEGIN 4 */
1068
/* USER CODE BEGIN 4 */
1007
 
1069
 
1008
/* USER CODE END 4 */
1070
/* USER CODE END 4 */
1009
 
1071
 
1010
/**
1072
/**
1011
 * @brief  This function is executed in case of error occurrence.
1073
  * @brief  This function is executed in case of error occurrence.
1012
 * @retval None
1074
  * @retval None
1013
 */
1075
  */
1014
void Error_Handler(void)
1076
void Error_Handler(void)
1015
{
1077
{
1016
  /* USER CODE BEGIN Error_Handler_Debug */
1078
  /* USER CODE BEGIN Error_Handler_Debug */
1017
  /* User can add his own implementation to report the HAL error return state */
1079
  /* User can add his own implementation to report the HAL error return state */
1018
 
1080
 
1019
  /* USER CODE END Error_Handler_Debug */
1081
  /* USER CODE END Error_Handler_Debug */
1020
}
1082
}
1021
 
1083
 
1022
#ifdef USE_FULL_ASSERT
1084
#ifdef  USE_FULL_ASSERT
1023
/**
1085
/**
1024
 * @brief  Reports the name of the source file and the source line number
1086
  * @brief  Reports the name of the source file and the source line number
1025
 *         where the assert_param error has occurred.
1087
  *         where the assert_param error has occurred.
1026
 * @param  file: pointer to the source file name
1088
  * @param  file: pointer to the source file name
1027
 * @param  line: assert_param error line source number
1089
  * @param  line: assert_param error line source number
1028
 * @retval None
1090
  * @retval None
1029
 */
1091
  */
1030
void assert_failed(uint8_t *file, uint32_t line)
1092
void assert_failed(uint8_t *file, uint32_t line)
1031
{
1093
{
1032
  /* USER CODE BEGIN 6 */
1094
  /* USER CODE BEGIN 6 */
1033
  /* User can add his own implementation to report the file name and line number,
1095
  /* User can add his own implementation to report the file name and line number,
1034
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
1096
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */