main.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. ******************************************************************************
  3. * @file main.c
  4. * @author MCU Application Team
  5. * @brief Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  13. * All rights reserved.</center></h2>
  14. *
  15. * This software component is licensed by ST under BSD 3-Clause license,
  16. * the "License"; You may not use this file except in compliance with the
  17. * License. You may obtain a copy of the License at:
  18. * opensource.org/licenses/BSD-3-Clause
  19. *
  20. ******************************************************************************
  21. */
  22. /* Includes ------------------------------------------------------------------*/
  23. #include "main.h"
  24. /* Private define ------------------------------------------------------------*/
  25. /* Private variables ---------------------------------------------------------*/
  26. /* Private user code ---------------------------------------------------------*/
  27. /* Private macro -------------------------------------------------------------*/
  28. /* Private function prototypes -----------------------------------------------*/
  29. static void APP_SystemClockConfig(void);
  30. /**
  31. * @brief The application entry point
  32. * @retval int
  33. */
  34. int main(void)
  35. {
  36. /* Reset of all peripherals, Initializes the Flash interface and the Systick */
  37. HAL_Init();
  38. /* Configure the system clock */
  39. APP_SystemClockConfig();
  40. while (1)
  41. {
  42. }
  43. }
  44. /**
  45. * @brief System Clock Configuration
  46. * @param None
  47. * @retval None
  48. */
  49. static void APP_SystemClockConfig(void)
  50. {
  51. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  52. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  53. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
  54. RCC_OscInitStruct.HSIState = RCC_HSI_ON; /* Enable HSI */
  55. RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; /* HSI clock 1 division */
  56. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_8MHz; /* Config HSI 8MHz Calibration */
  57. RCC_OscInitStruct.HSEState = RCC_HSE_OFF; /* Disable HSE */
  58. /*RCC_OscInitStruct.HSEFreq = RCC_HSE_16_32MHz;*/
  59. RCC_OscInitStruct.LSIState = RCC_LSI_OFF; /* Disable LSI */
  60. RCC_OscInitStruct.LSEState = RCC_LSE_OFF; /* Disable LSE */
  61. /*RCC_OscInitStruct.LSEDriver = RCC_LSEDRIVE_MEDIUM;*/
  62. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF; /* Disable PLL */
  63. /*RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_NONE;*/
  64. /*RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2;*/
  65. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  66. {
  67. APP_ErrorHandler();
  68. }
  69. /* Configure Clock */
  70. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
  71. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSISYS; /* System clock selection HSI */
  72. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* AHB clock 1 division */
  73. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* APB clock 1 division */
  74. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  75. {
  76. APP_ErrorHandler();
  77. }
  78. }
  79. /**
  80. * @brief This function is executed in case of error occurrence.
  81. * @param None
  82. * @retval None
  83. */
  84. void APP_ErrorHandler(void)
  85. {
  86. /* Infinite loop */
  87. while (1)
  88. {
  89. }
  90. }
  91. #ifdef USE_FULL_ASSERT
  92. /**
  93. * @brief Reports the name of the source file and the source line number
  94. * where the assert_param error has occurred.
  95. * @param file: pointer to the source file name
  96. * @param line: assert_param error line source number
  97. * @retval None
  98. */
  99. void assert_failed(uint8_t *file, uint32_t line)
  100. {
  101. /* User can add his own implementation to report the file name and line number,
  102. for example: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  103. /* Infinite loop */
  104. while (1)
  105. {
  106. }
  107. }
  108. #endif /* USE_FULL_ASSERT */
  109. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/