main.c 3.8 KB

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