main.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 Application Entry Function.
  32. * @retval int
  33. */
  34. int main(void)
  35. {
  36. /* Reset of all peripherals, Initializes the Systick */
  37. HAL_Init();
  38. /* System clock configuration */
  39. APP_SystemClockConfig();
  40. /* infinite loop */
  41. while (1)
  42. {
  43. }
  44. }
  45. /**
  46. * @brief System clock configuration function
  47. * @param None
  48. * @retval None
  49. */
  50. static void APP_SystemClockConfig(void)
  51. {
  52. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  53. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  54. /* Oscillator configuration */
  55. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; /* Select oscillator HSE, HSI, LSI, LSE */
  56. RCC_OscInitStruct.HSIState = RCC_HSI_ON; /* Enable HSI */
  57. RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; /* HSI 1 frequency division */
  58. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_24MHz; /* Configure HSI clock 24MHz */
  59. RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_DISABLE; /* Close HSE bypass */
  60. RCC_OscInitStruct.LSIState = RCC_LSI_OFF; /* Close LSI */
  61. /*RCC_OscInitStruct.LSICalibrationValue = RCC_LSICALIBRATION_32768Hz;*/
  62. RCC_OscInitStruct.LSEState = RCC_LSE_OFF; /* Close LSE */
  63. /*RCC_OscInitStruct.LSEDriver = RCC_LSEDRIVE_MEDIUM;*/
  64. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  65. {
  66. APP_ErrorHandler();
  67. }
  68. /* Clock source configuration */
  69. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1; /* Choose to configure clock HCLK, SYSCLK, PCLK1 */
  70. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSISYS; /* Select HSISYS as the system clock */
  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 Error executing function.
  80. * @param None
  81. * @retval None
  82. */
  83. void APP_ErrorHandler(void)
  84. {
  85. while (1)
  86. {
  87. }
  88. }
  89. #ifdef USE_FULL_ASSERT
  90. /**
  91. * @brief Reports the name of the source file and the source line number
  92. * where the assert_param error has occurred.
  93. * @param file: pointer to the source file name
  94. * @param line: assert_param error line source number
  95. * @retval None
  96. */
  97. void assert_failed(uint8_t *file, uint32_t line)
  98. {
  99. /* Users can add their own printing information as needed,
  100. for example: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  101. /* Infinite loop */
  102. while (1)
  103. {
  104. }
  105. }
  106. #endif /* USE_FULL_ASSERT */
  107. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/