main.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. /* Infinite loop */
  41. while (1)
  42. {
  43. }
  44. }
  45. /**
  46. * @brief System Clock Configuration
  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. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI;
  55. RCC_OscInitStruct.HSIState = RCC_HSI_ON; /* Enable HSI */
  56. RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; /* HSI clock 1 division */
  57. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_8MHz; /* Config HSI 8MHz Calibration */
  58. RCC_OscInitStruct.HSEState = RCC_HSE_OFF; /* Disable HSE */
  59. /*RCC_OscInitStruct.HSEFreq = RCC_HSE_16_32MHz;*/
  60. RCC_OscInitStruct.LSIState = RCC_LSI_OFF; /* Disable LSI */
  61. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  62. {
  63. APP_ErrorHandler();
  64. }
  65. /* Configure Clock */
  66. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
  67. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; /* System clock selection HSI */
  68. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* AHB clock 1 division */
  69. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; /* APB clock 1 division */
  70. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  71. {
  72. APP_ErrorHandler();
  73. }
  74. }
  75. /**
  76. * @brief This function is executed in case of error occurrence.
  77. * @param None
  78. * @retval None
  79. */
  80. void APP_ErrorHandler(void)
  81. {
  82. /* Infinite loop */
  83. while (1)
  84. {
  85. }
  86. }
  87. #ifdef USE_FULL_ASSERT
  88. /**
  89. * @brief Reports the name of the source file and the source line number
  90. * where the assert_param error has occurred.
  91. * @param file: pointer to the source file name
  92. * @param line: assert_param error line source number
  93. * @retval None
  94. */
  95. void assert_failed(uint8_t *file, uint32_t line)
  96. {
  97. /* User can add his own implementation to report the file name and line number,
  98. for example: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  99. /* Infinite loop */
  100. while (1)
  101. {
  102. }
  103. }
  104. #endif /* USE_FULL_ASSERT */
  105. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/