You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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