Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main.c 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. #include "cmsis_os.h"
  23. #include "usart.h"
  24. #include "gpio.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. /* USER CODE END Includes */
  28. /* Private typedef -----------------------------------------------------------*/
  29. /* USER CODE BEGIN PTD */
  30. /* USER CODE END PTD */
  31. /* Private define ------------------------------------------------------------*/
  32. /* USER CODE BEGIN PD */
  33. /* USER CODE END PD */
  34. /* Private macro -------------------------------------------------------------*/
  35. /* USER CODE BEGIN PM */
  36. /* USER CODE END PM */
  37. /* Private variables ---------------------------------------------------------*/
  38. /* USER CODE BEGIN PV */
  39. /* USER CODE END PV */
  40. /* Private function prototypes -----------------------------------------------*/
  41. void SystemClock_Config(void);
  42. void MX_FREERTOS_Init(void);
  43. /* USER CODE BEGIN PFP */
  44. /* USER CODE END PFP */
  45. /* Private user code ---------------------------------------------------------*/
  46. /* USER CODE BEGIN 0 */
  47. /* USER CODE END 0 */
  48. /**
  49. * @brief The application entry point.
  50. * @retval int
  51. */
  52. int main(void)
  53. {
  54. /* USER CODE BEGIN 1 */
  55. /* USER CODE END 1 */
  56. /* MCU Configuration--------------------------------------------------------*/
  57. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  58. HAL_Init();
  59. /* USER CODE BEGIN Init */
  60. /* USER CODE END Init */
  61. /* Configure the system clock */
  62. SystemClock_Config();
  63. /* USER CODE BEGIN SysInit */
  64. /* USER CODE END SysInit */
  65. /* Initialize all configured peripherals */
  66. MX_GPIO_Init();
  67. MX_USART1_UART_Init();
  68. /* USER CODE BEGIN 2 */
  69. /* USER CODE END 2 */
  70. /* Init scheduler */
  71. osKernelInitialize(); /* Call init function for freertos objects (in freertos.c) */
  72. MX_FREERTOS_Init();
  73. /* Start scheduler */
  74. osKernelStart();
  75. /* We should never get here as control is now taken by the scheduler */
  76. /* Infinite loop */
  77. /* USER CODE BEGIN WHILE */
  78. while (1)
  79. {
  80. /* USER CODE END WHILE */
  81. /* USER CODE BEGIN 3 */
  82. }
  83. /* USER CODE END 3 */
  84. }
  85. /**
  86. * @brief System Clock Configuration
  87. * @retval None
  88. */
  89. void SystemClock_Config(void)
  90. {
  91. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  92. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  93. /** Initializes the RCC Oscillators according to the specified parameters
  94. * in the RCC_OscInitTypeDef structure.
  95. */
  96. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  97. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  98. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  99. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  100. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  101. {
  102. Error_Handler();
  103. }
  104. /** Initializes the CPU, AHB and APB buses clocks
  105. */
  106. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  107. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  108. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  109. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  110. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  111. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  112. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  113. {
  114. Error_Handler();
  115. }
  116. }
  117. /* USER CODE BEGIN 4 */
  118. /* USER CODE END 4 */
  119. /**
  120. * @brief Period elapsed callback in non blocking mode
  121. * @note This function is called when TIM1 interrupt took place, inside
  122. * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  123. * a global variable "uwTick" used as application time base.
  124. * @param htim : TIM handle
  125. * @retval None
  126. */
  127. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  128. {
  129. /* USER CODE BEGIN Callback 0 */
  130. /* USER CODE END Callback 0 */
  131. if (htim->Instance == TIM1) {
  132. HAL_IncTick();
  133. }
  134. /* USER CODE BEGIN Callback 1 */
  135. /* USER CODE END Callback 1 */
  136. }
  137. /**
  138. * @brief This function is executed in case of error occurrence.
  139. * @retval None
  140. */
  141. void Error_Handler(void)
  142. {
  143. /* USER CODE BEGIN Error_Handler_Debug */
  144. /* User can add his own implementation to report the HAL error return state */
  145. __disable_irq();
  146. while (1)
  147. {
  148. }
  149. /* USER CODE END Error_Handler_Debug */
  150. }
  151. #ifdef USE_FULL_ASSERT
  152. /**
  153. * @brief Reports the name of the source file and the source line number
  154. * where the assert_param error has occurred.
  155. * @param file: pointer to the source file name
  156. * @param line: assert_param error line source number
  157. * @retval None
  158. */
  159. void assert_failed(uint8_t *file, uint32_t line)
  160. {
  161. /* USER CODE BEGIN 6 */
  162. /* User can add his own implementation to report the file name and line number,
  163. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  164. /* USER CODE END 6 */
  165. }
  166. #endif /* USE_FULL_ASSERT */
  167. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/