main.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2022 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. /* Private includes ----------------------------------------------------------*/
  22. /* USER CODE BEGIN Includes */
  23. /* USER CODE END Includes */
  24. /* Private typedef -----------------------------------------------------------*/
  25. /* USER CODE BEGIN PTD */
  26. /* USER CODE END PTD */
  27. /* Private define ------------------------------------------------------------*/
  28. /* USER CODE BEGIN PD */
  29. #ifndef HSEM_ID_0
  30. #define HSEM_ID_0 (0U) /* HW semaphore 0*/
  31. #endif
  32. /* USER CODE END PD */
  33. /* Private macro -------------------------------------------------------------*/
  34. /* USER CODE BEGIN PM */
  35. /* USER CODE END PM */
  36. /* Private variables ---------------------------------------------------------*/
  37. /* USER CODE BEGIN PV */
  38. /* USER CODE END PV */
  39. /* Private function prototypes -----------------------------------------------*/
  40. static void MX_GPIO_Init(void);
  41. /* USER CODE BEGIN PFP */
  42. /* USER CODE END PFP */
  43. /* Private user code ---------------------------------------------------------*/
  44. /* USER CODE BEGIN 0 */
  45. /* USER CODE END 0 */
  46. /**
  47. * @brief The application entry point.
  48. * @retval int
  49. */
  50. int main(void)
  51. {
  52. /* USER CODE BEGIN 1 */
  53. /* USER CODE END 1 */
  54. /* USER CODE BEGIN Boot_Mode_Sequence_1 */
  55. /* ETH_CODE: fixed core synchronization
  56. * Busy wait, since entering STOP mode breaks debug session.
  57. */
  58. __HAL_RCC_HSEM_CLK_ENABLE();
  59. while((__HAL_HSEM_GET_FLAG(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0))) == 0);
  60. __HAL_HSEM_CLEAR_FLAG(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
  61. /* USER CODE END Boot_Mode_Sequence_1 */
  62. /* MCU Configuration--------------------------------------------------------*/
  63. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  64. HAL_Init();
  65. /* USER CODE BEGIN Init */
  66. /* USER CODE END Init */
  67. /* USER CODE BEGIN SysInit */
  68. /* USER CODE END SysInit */
  69. /* Initialize all configured peripherals */
  70. MX_GPIO_Init();
  71. /* USER CODE BEGIN 2 */
  72. /* USER CODE END 2 */
  73. /* Infinite loop */
  74. /* USER CODE BEGIN WHILE */
  75. while (1)
  76. {
  77. /* USER CODE END WHILE */
  78. /* USER CODE BEGIN 3 */
  79. }
  80. /* USER CODE END 3 */
  81. }
  82. /**
  83. * @brief GPIO Initialization Function
  84. * @param None
  85. * @retval None
  86. */
  87. static void MX_GPIO_Init(void)
  88. {
  89. GPIO_InitTypeDef GPIO_InitStruct = {0};
  90. /* GPIO Ports Clock Enable */
  91. __HAL_RCC_GPIOE_CLK_ENABLE();
  92. /*Configure GPIO pins : PE5 PE4 */
  93. GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_4;
  94. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  95. GPIO_InitStruct.Pull = GPIO_NOPULL;
  96. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  97. GPIO_InitStruct.Alternate = GPIO_AF10_SAI4;
  98. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  99. }
  100. /* USER CODE BEGIN 4 */
  101. /* USER CODE END 4 */
  102. /**
  103. * @brief This function is executed in case of error occurrence.
  104. * @retval None
  105. */
  106. void Error_Handler(void)
  107. {
  108. /* USER CODE BEGIN Error_Handler_Debug */
  109. /* User can add his own implementation to report the HAL error return state */
  110. __disable_irq();
  111. while (1)
  112. {
  113. }
  114. /* USER CODE END Error_Handler_Debug */
  115. }
  116. #ifdef USE_FULL_ASSERT
  117. /**
  118. * @brief Reports the name of the source file and the source line number
  119. * where the assert_param error has occurred.
  120. * @param file: pointer to the source file name
  121. * @param line: assert_param error line source number
  122. * @retval None
  123. */
  124. void assert_failed(uint8_t *file, uint32_t line)
  125. {
  126. /* USER CODE BEGIN 6 */
  127. /* User can add his own implementation to report the file name and line number,
  128. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  129. /* USER CODE END 6 */
  130. }
  131. #endif /* USE_FULL_ASSERT */