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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. __WEAK 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. pkt_kprintf("%s\n", __func__);
  70. /* USER CODE END 2 */
  71. /* Init scheduler */
  72. osKernelInitialize(); /* Call init function for freertos objects (in freertos.c) */
  73. MX_FREERTOS_Init();
  74. /* Start scheduler */
  75. osKernelStart();
  76. /* We should never get here as control is now taken by the scheduler */
  77. /* Infinite loop */
  78. /* USER CODE BEGIN WHILE */
  79. while (1)
  80. {
  81. /* USER CODE END WHILE */
  82. /* USER CODE BEGIN 3 */
  83. }
  84. /* USER CODE END 3 */
  85. }
  86. /**
  87. * @brief System Clock Configuration
  88. * @retval None
  89. */
  90. void SystemClock_Config(void)
  91. {
  92. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  93. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  94. /** Initializes the RCC Oscillators according to the specified parameters
  95. * in the RCC_OscInitTypeDef structure.
  96. */
  97. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  98. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  99. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  100. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  101. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  102. {
  103. Error_Handler();
  104. }
  105. /** Initializes the CPU, AHB and APB buses clocks
  106. */
  107. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  108. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  109. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  110. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  111. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  112. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  113. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  114. {
  115. Error_Handler();
  116. }
  117. }
  118. /* USER CODE BEGIN 4 */
  119. /* USER CODE END 4 */
  120. /**
  121. * @brief Period elapsed callback in non blocking mode
  122. * @note This function is called when TIM1 interrupt took place, inside
  123. * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  124. * a global variable "uwTick" used as application time base.
  125. * @param htim : TIM handle
  126. * @retval None
  127. */
  128. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  129. {
  130. /* USER CODE BEGIN Callback 0 */
  131. /* USER CODE END Callback 0 */
  132. if (htim->Instance == TIM1) {
  133. HAL_IncTick();
  134. }
  135. /* USER CODE BEGIN Callback 1 */
  136. /* USER CODE END Callback 1 */
  137. }
  138. /**
  139. * @brief This function is executed in case of error occurrence.
  140. * @retval None
  141. */
  142. void Error_Handler(void)
  143. {
  144. /* USER CODE BEGIN Error_Handler_Debug */
  145. /* User can add his own implementation to report the HAL error return state */
  146. __disable_irq();
  147. while (1)
  148. {
  149. }
  150. /* USER CODE END Error_Handler_Debug */
  151. }
  152. #ifdef USE_FULL_ASSERT
  153. /**
  154. * @brief Reports the name of the source file and the source line number
  155. * where the assert_param error has occurred.
  156. * @param file: pointer to the source file name
  157. * @param line: assert_param error line source number
  158. * @retval None
  159. */
  160. void assert_failed(uint8_t *file, uint32_t line)
  161. {
  162. /* USER CODE BEGIN 6 */
  163. /* User can add his own implementation to report the file name and line number,
  164. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  165. /* USER CODE END 6 */
  166. }
  167. #endif /* USE_FULL_ASSERT */
  168. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/