main.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  65. {
  66. APP_ErrorHandler();
  67. }
  68. /* Configure Clock */
  69. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
  70. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; /* System clock selection HSI */
  71. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* AHB clock 1 division */
  72. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* APB clock 1 division */
  73. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  74. {
  75. APP_ErrorHandler();
  76. }
  77. }
  78. /**
  79. * @brief This function is executed in case of error occurrence.
  80. * @param None
  81. * @retval None
  82. */
  83. void APP_ErrorHandler(void)
  84. {
  85. /* Infinite loop */
  86. while (1)
  87. {
  88. }
  89. }
  90. #ifdef USE_FULL_ASSERT
  91. /**
  92. * @brief Reports the name of the source file and the source line number
  93. * where the assert_param error has occurred.
  94. * @param file: pointer to the source file name
  95. * @param line: assert_param error line source number
  96. * @retval None
  97. */
  98. void assert_failed(uint8_t *file, uint32_t line)
  99. {
  100. /* User can add his own implementation to report the file name and line number,
  101. for example: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  102. /* Infinite loop */
  103. while (1)
  104. {
  105. }
  106. }
  107. #endif /* USE_FULL_ASSERT */
  108. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/