Subversion Repositories EDIS_Ignition

Rev

Rev 12 | Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 13
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
CAN_HandleTypeDef hcan;
49
 CAN_HandleTypeDef hcan;
50
 
50
 
51
I2C_HandleTypeDef hi2c1;
51
I2C_HandleTypeDef hi2c1;
52
 
52
 
53
IWDG_HandleTypeDef hiwdg;
53
IWDG_HandleTypeDef hiwdg;
54
 
54
 
Line 125... Line 125...
125
}
125
}
126
 
126
 
127
/* USER CODE END 0 */
127
/* USER CODE END 0 */
128
 
128
 
129
/**
129
/**
130
 * @brief  The application entry point.
130
  * @brief  The application entry point.
131
 * @retval int
131
  * @retval int
132
 */
132
  */
133
int main(void)
133
int main(void)
134
{
134
{
135
  /* USER CODE BEGIN 1 */
135
  /* USER CODE BEGIN 1 */
136
 
136
 
137
  /* USER CODE END 1 */
137
  /* USER CODE END 1 */
Line 211... Line 211...
211
    int button = HAL_GPIO_ReadPin(PUSHBUTTON_GPIO_Port, PUSHBUTTON_Pin) == GPIO_PIN_RESET;
211
    int button = HAL_GPIO_ReadPin(PUSHBUTTON_GPIO_Port, PUSHBUTTON_Pin) == GPIO_PIN_RESET;
212
 
212
 
213
    if (button)
213
    if (button)
214
    {
214
    {
215
      intensity = 2;
215
      intensity = 2;
216
      displayOff = lastTick + 10000;
216
      displayOff = lastTick + 30000;
217
    }
217
    }
218
 
218
 
219
    switch (intensity)
219
    switch (intensity)
220
    {
220
    {
221
    case 2:
221
    case 2:
Line 232... Line 232...
232
        intensity = 1; // was 0
232
        intensity = 1; // was 0
233
      }
233
      }
234
    default:
234
    default:
235
      break;
235
      break;
236
    }
236
    }
237
    cc_display(0, intensity);
237
    cc_display(0, intensity, 0);
238
 
238
 
239
    if (HAL_GetTick() - lastTick > T100MS)
239
    if (HAL_GetTick() - lastTick > T100MS)
240
    {
240
    {
241
      lastTick = HAL_GetTick();
241
      lastTick = HAL_GetTick();
242
      /* Reading the raw data from sensor */
242
      /* Reading the raw data from sensor */
Line 339... Line 339...
339
  }
339
  }
340
  /* USER CODE END 3 */
340
  /* USER CODE END 3 */
341
}
341
}
342
 
342
 
343
/**
343
/**
344
 * @brief System Clock Configuration
344
  * @brief System Clock Configuration
345
 * @retval None
345
  * @retval None
346
 */
346
  */
347
void SystemClock_Config(void)
347
void SystemClock_Config(void)
348
{
348
{
349
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
349
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
350
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
350
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
351
 
351
 
352
  /** Initializes the RCC Oscillators according to the specified parameters
352
  /** Initializes the RCC Oscillators according to the specified parameters
353
   * in the RCC_OscInitTypeDef structure.
353
  * in the RCC_OscInitTypeDef structure.
354
   */
354
  */
355
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE;
355
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
356
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
356
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
357
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
357
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
358
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
358
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
359
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
359
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
360
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
360
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
Line 364... Line 364...
364
  {
364
  {
365
    Error_Handler();
365
    Error_Handler();
366
  }
366
  }
367
 
367
 
368
  /** Initializes the CPU, AHB and APB buses clocks
368
  /** Initializes the CPU, AHB and APB buses clocks
369
   */
369
  */
370
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
370
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
-
 
371
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
371
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
372
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
372
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
373
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
373
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
374
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
374
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
375
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
375
 
376
 
Line 378... Line 379...
378
    Error_Handler();
379
    Error_Handler();
379
  }
380
  }
380
}
381
}
381
 
382
 
382
/**
383
/**
383
 * @brief CAN Initialization Function
384
  * @brief CAN Initialization Function
384
 * @param None
385
  * @param None
385
 * @retval None
386
  * @retval None
386
 */
387
  */
387
static void MX_CAN_Init(void)
388
static void MX_CAN_Init(void)
388
{
389
{
389
 
390
 
390
  /* USER CODE BEGIN CAN_Init 0 */
391
  /* USER CODE BEGIN CAN_Init 0 */
391
 
392
 
Line 411... Line 412...
411
    Error_Handler();
412
    Error_Handler();
412
  }
413
  }
413
  /* USER CODE BEGIN CAN_Init 2 */
414
  /* USER CODE BEGIN CAN_Init 2 */
414
 
415
 
415
  /* USER CODE END CAN_Init 2 */
416
  /* USER CODE END CAN_Init 2 */
-
 
417
 
416
}
418
}
417
 
419
 
418
/**
420
/**
419
 * @brief I2C1 Initialization Function
421
  * @brief I2C1 Initialization Function
420
 * @param None
422
  * @param None
421
 * @retval None
423
  * @retval None
422
 */
424
  */
423
static void MX_I2C1_Init(void)
425
static void MX_I2C1_Init(void)
424
{
426
{
425
 
427
 
426
  /* USER CODE BEGIN I2C1_Init 0 */
428
  /* USER CODE BEGIN I2C1_Init 0 */
427
 
429
 
Line 444... Line 446...
444
    Error_Handler();
446
    Error_Handler();
445
  }
447
  }
446
  /* USER CODE BEGIN I2C1_Init 2 */
448
  /* USER CODE BEGIN I2C1_Init 2 */
447
 
449
 
448
  /* USER CODE END I2C1_Init 2 */
450
  /* USER CODE END I2C1_Init 2 */
-
 
451
 
449
}
452
}
450
 
453
 
451
/**
454
/**
452
 * @brief IWDG Initialization Function
455
  * @brief IWDG Initialization Function
453
 * @param None
456
  * @param None
454
 * @retval None
457
  * @retval None
455
 */
458
  */
456
static void MX_IWDG_Init(void)
459
static void MX_IWDG_Init(void)
457
{
460
{
458
 
461
 
459
  /* USER CODE BEGIN IWDG_Init 0 */
462
  /* USER CODE BEGIN IWDG_Init 0 */
460
 
463
 
Line 471... Line 474...
471
    Error_Handler();
474
    Error_Handler();
472
  }
475
  }
473
  /* USER CODE BEGIN IWDG_Init 2 */
476
  /* USER CODE BEGIN IWDG_Init 2 */
474
 
477
 
475
  /* USER CODE END IWDG_Init 2 */
478
  /* USER CODE END IWDG_Init 2 */
-
 
479
 
476
}
480
}
477
 
481
 
478
/**
482
/**
479
 * @brief SPI1 Initialization Function
483
  * @brief SPI1 Initialization Function
480
 * @param None
484
  * @param None
481
 * @retval None
485
  * @retval None
482
 */
486
  */
483
static void MX_SPI1_Init(void)
487
static void MX_SPI1_Init(void)
484
{
488
{
485
 
489
 
486
  /* USER CODE BEGIN SPI1_Init 0 */
490
  /* USER CODE BEGIN SPI1_Init 0 */
487
 
491
 
Line 493... Line 497...
493
  /* SPI1 parameter configuration*/
497
  /* SPI1 parameter configuration*/
494
  hspi1.Instance = SPI1;
498
  hspi1.Instance = SPI1;
495
  hspi1.Init.Mode = SPI_MODE_MASTER;
499
  hspi1.Init.Mode = SPI_MODE_MASTER;
496
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
500
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
497
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
501
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
498
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
502
  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
499
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
503
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
500
  hspi1.Init.NSS = SPI_NSS_SOFT;
504
  hspi1.Init.NSS = SPI_NSS_SOFT;
501
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
505
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
502
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
506
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
503
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
507
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
504
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
508
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
Line 508... Line 512...
508
    Error_Handler();
512
    Error_Handler();
509
  }
513
  }
510
  /* USER CODE BEGIN SPI1_Init 2 */
514
  /* USER CODE BEGIN SPI1_Init 2 */
511
 
515
 
512
  /* USER CODE END SPI1_Init 2 */
516
  /* USER CODE END SPI1_Init 2 */
-
 
517
 
513
}
518
}
514
 
519
 
515
/**
520
/**
516
 * @brief TIM1 Initialization Function
521
  * @brief TIM1 Initialization Function
517
 * @param None
522
  * @param None
518
 * @retval None
523
  * @retval None
519
 */
524
  */
520
static void MX_TIM1_Init(void)
525
static void MX_TIM1_Init(void)
521
{
526
{
522
 
527
 
523
  /* USER CODE BEGIN TIM1_Init 0 */
528
  /* USER CODE BEGIN TIM1_Init 0 */
524
 
529
 
Line 586... Line 591...
586
  }
591
  }
587
  /* USER CODE BEGIN TIM1_Init 2 */
592
  /* USER CODE BEGIN TIM1_Init 2 */
588
 
593
 
589
  /* USER CODE END TIM1_Init 2 */
594
  /* USER CODE END TIM1_Init 2 */
590
  HAL_TIM_MspPostInit(&htim1);
595
  HAL_TIM_MspPostInit(&htim1);
-
 
596
 
591
}
597
}
592
 
598
 
593
/**
599
/**
594
 * @brief TIM2 Initialization Function
600
  * @brief TIM2 Initialization Function
595
 * @param None
601
  * @param None
596
 * @retval None
602
  * @retval None
597
 */
603
  */
598
static void MX_TIM2_Init(void)
604
static void MX_TIM2_Init(void)
599
{
605
{
600
 
606
 
601
  /* USER CODE BEGIN TIM2_Init 0 */
607
  /* USER CODE BEGIN TIM2_Init 0 */
602
 
608
 
Line 649... Line 655...
649
    Error_Handler();
655
    Error_Handler();
650
  }
656
  }
651
  /* USER CODE BEGIN TIM2_Init 2 */
657
  /* USER CODE BEGIN TIM2_Init 2 */
652
 
658
 
653
  /* USER CODE END TIM2_Init 2 */
659
  /* USER CODE END TIM2_Init 2 */
-
 
660
 
654
}
661
}
655
 
662
 
656
/**
663
/**
657
 * @brief TIM3 Initialization Function
664
  * @brief TIM3 Initialization Function
658
 * @param None
665
  * @param None
659
 * @retval None
666
  * @retval None
660
 */
667
  */
661
static void MX_TIM3_Init(void)
668
static void MX_TIM3_Init(void)
662
{
669
{
663
 
670
 
664
  /* USER CODE BEGIN TIM3_Init 0 */
671
  /* USER CODE BEGIN TIM3_Init 0 */
665
 
672
 
Line 693... Line 700...
693
    Error_Handler();
700
    Error_Handler();
694
  }
701
  }
695
  /* USER CODE BEGIN TIM3_Init 2 */
702
  /* USER CODE BEGIN TIM3_Init 2 */
696
 
703
 
697
  /* USER CODE END TIM3_Init 2 */
704
  /* USER CODE END TIM3_Init 2 */
-
 
705
 
698
}
706
}
699
 
707
 
700
/**
708
/**
701
 * @brief USART2 Initialization Function
709
  * @brief USART2 Initialization Function
702
 * @param None
710
  * @param None
703
 * @retval None
711
  * @retval None
704
 */
712
  */
705
static void MX_USART2_UART_Init(void)
713
static void MX_USART2_UART_Init(void)
706
{
714
{
707
 
715
 
708
  /* USER CODE BEGIN USART2_Init 0 */
716
  /* USER CODE BEGIN USART2_Init 0 */
709
 
717
 
Line 725... Line 733...
725
    Error_Handler();
733
    Error_Handler();
726
  }
734
  }
727
  /* USER CODE BEGIN USART2_Init 2 */
735
  /* USER CODE BEGIN USART2_Init 2 */
728
 
736
 
729
  /* USER CODE END USART2_Init 2 */
737
  /* USER CODE END USART2_Init 2 */
-
 
738
 
730
}
739
}
731
 
740
 
732
/**
741
/**
733
 * @brief GPIO Initialization Function
742
  * @brief GPIO Initialization Function
734
 * @param None
743
  * @param None
735
 * @retval None
744
  * @retval None
736
 */
745
  */
737
static void MX_GPIO_Init(void)
746
static void MX_GPIO_Init(void)
738
{
747
{
739
  GPIO_InitTypeDef GPIO_InitStruct = {0};
748
  GPIO_InitTypeDef GPIO_InitStruct = {0};
740
 
749
 
741
  /* GPIO Ports Clock Enable */
750
  /* GPIO Ports Clock Enable */
742
  __HAL_RCC_GPIOD_CLK_ENABLE();
751
  __HAL_RCC_GPIOD_CLK_ENABLE();
743
  __HAL_RCC_GPIOA_CLK_ENABLE();
752
  __HAL_RCC_GPIOA_CLK_ENABLE();
744
  __HAL_RCC_GPIOB_CLK_ENABLE();
753
  __HAL_RCC_GPIOB_CLK_ENABLE();
745
 
754
 
746
  /*Configure GPIO pin Output Level */
755
  /*Configure GPIO pin Output Level */
747
  HAL_GPIO_WritePin(GPIOA, SPI1_NSS_Pin | SPI1_RESET_Pin, GPIO_PIN_RESET);
756
  HAL_GPIO_WritePin(GPIOA, SPI1_NSS_Pin|SPI1_RESET_Pin, GPIO_PIN_RESET);
748
 
757
 
749
  /*Configure GPIO pin Output Level */
758
  /*Configure GPIO pin Output Level */
750
  HAL_GPIO_WritePin(SPI1_CD_GPIO_Port, SPI1_CD_Pin, GPIO_PIN_RESET);
759
  HAL_GPIO_WritePin(SPI1_CD_GPIO_Port, SPI1_CD_Pin, GPIO_PIN_RESET);
751
 
760
 
752
  /*Configure GPIO pins : SPI1_NSS_Pin SPI1_RESET_Pin */
761
  /*Configure GPIO pins : SPI1_NSS_Pin SPI1_RESET_Pin */
753
  GPIO_InitStruct.Pin = SPI1_NSS_Pin | SPI1_RESET_Pin;
762
  GPIO_InitStruct.Pin = SPI1_NSS_Pin|SPI1_RESET_Pin;
754
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
763
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
755
  GPIO_InitStruct.Pull = GPIO_NOPULL;
764
  GPIO_InitStruct.Pull = GPIO_NOPULL;
756
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
765
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
757
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
766
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
758
 
767
 
Line 772... Line 781...
772
  /*Configure GPIO pin : dualSpark_Pin */
781
  /*Configure GPIO pin : dualSpark_Pin */
773
  GPIO_InitStruct.Pin = dualSpark_Pin;
782
  GPIO_InitStruct.Pin = dualSpark_Pin;
774
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
783
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
775
  GPIO_InitStruct.Pull = GPIO_PULLUP;
784
  GPIO_InitStruct.Pull = GPIO_PULLUP;
776
  HAL_GPIO_Init(dualSpark_GPIO_Port, &GPIO_InitStruct);
785
  HAL_GPIO_Init(dualSpark_GPIO_Port, &GPIO_InitStruct);
-
 
786
 
777
}
787
}
778
 
788
 
779
/* USER CODE BEGIN 4 */
789
/* USER CODE BEGIN 4 */
780
 
790
 
781
/* USER CODE END 4 */
791
/* USER CODE END 4 */
782
 
792
 
783
/**
793
/**
784
 * @brief  This function is executed in case of error occurrence.
794
  * @brief  This function is executed in case of error occurrence.
785
 * @retval None
795
  * @retval None
786
 */
796
  */
787
void Error_Handler(void)
797
void Error_Handler(void)
788
{
798
{
789
  /* USER CODE BEGIN Error_Handler_Debug */
799
  /* USER CODE BEGIN Error_Handler_Debug */
790
  /* User can add his own implementation to report the HAL error return state */
800
  /* User can add his own implementation to report the HAL error return state */
791
  __disable_irq();
801
  __disable_irq();
Line 793... Line 803...
793
  {
803
  {
794
  }
804
  }
795
  /* USER CODE END Error_Handler_Debug */
805
  /* USER CODE END Error_Handler_Debug */
796
}
806
}
797
 
807
 
798
#ifdef USE_FULL_ASSERT
808
#ifdef  USE_FULL_ASSERT
799
/**
809
/**
800
 * @brief  Reports the name of the source file and the source line number
810
  * @brief  Reports the name of the source file and the source line number
801
 *         where the assert_param error has occurred.
811
  *         where the assert_param error has occurred.
802
 * @param  file: pointer to the source file name
812
  * @param  file: pointer to the source file name
803
 * @param  line: assert_param error line source number
813
  * @param  line: assert_param error line source number
804
 * @retval None
814
  * @retval None
805
 */
815
  */
806
void assert_failed(uint8_t *file, uint32_t line)
816
void assert_failed(uint8_t *file, uint32_t line)
807
{
817
{
808
  /* USER CODE BEGIN 6 */
818
  /* USER CODE BEGIN 6 */
809
  /* User can add his own implementation to report the file name and line number,
819
  /* User can add his own implementation to report the file name and line number,
810
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
820
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */