27 RCC_OscInitTypeDef RCC_OscInitStruct = {0U};
28 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0U};
29 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0U};
31 __HAL_RCC_SYSCFG_CLK_ENABLE();
32 __HAL_RCC_PWR_CLK_ENABLE();
34 RCC_OscInitStruct.OscillatorType =
35 RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSI;
36 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
37 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
38 RCC_OscInitStruct.LSIState = RCC_LSI_ON;
39 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
40 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
41 RCC_OscInitStruct.PLL.PLLM = 1U;
42 RCC_OscInitStruct.PLL.PLLN = 10U;
43 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
44 RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
45 RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
46 if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
51 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
52 RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
53 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
54 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
55 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
56 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
58 if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
63 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
64 PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
65 if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
70 if(HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
81 GPIO_InitTypeDef GPIO_InitStruct = {0U};
83 __HAL_RCC_GPIOA_CLK_ENABLE();
84 __HAL_RCC_GPIOB_CLK_ENABLE();
89 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
90 GPIO_InitStruct.Pull = GPIO_NOPULL;
91 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
105 GPIO_InitTypeDef GPIO_InitStruct = {0U};
107 __HAL_RCC_GPIOA_CLK_ENABLE();
108 __HAL_RCC_GPIOB_CLK_ENABLE();
113 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
114 GPIO_InitStruct.Pull = GPIO_NOPULL;
115 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
123 __HAL_RCC_GPIOA_CLK_DISABLE();
124 __HAL_RCC_GPIOB_CLK_DISABLE();