Changeset 39 for ctrl/firmware/Main/CubeMX/Core/Src
- Timestamp:
- Dec 2, 2024, 10:55:02 AM (6 weeks ago)
- Location:
- ctrl/firmware/Main/CubeMX/Core/Src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/CubeMX/Core/Src/main.c
r38 r39 42 42 /* Private variables ---------------------------------------------------------*/ 43 43 44 RTC_HandleTypeDef hrtc; 45 44 46 /* USER CODE BEGIN PV */ 45 47 … … 49 51 void SystemClock_Config(void); 50 52 static void MPU_Config(void); 53 static void MX_GPIO_Init(void); 54 static void MX_RTC_Init(void); 51 55 /* USER CODE BEGIN PFP */ 52 56 … … 97 101 98 102 /* Initialize all configured peripherals */ 103 MX_GPIO_Init(); 104 MX_RTC_Init(); 99 105 /* USER CODE BEGIN 2 */ 100 106 … … 118 124 void SystemClock_Config(void) 119 125 { 120 RCC_OscInitTypeDef RCC_OscInitStruct {};121 RCC_ClkInitTypeDef RCC_ClkInitStruct {};126 RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 127 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 122 128 123 129 /** Supply configuration update enable … … 127 133 /** Configure the main internal regulator output voltage 128 134 */ 129 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE 3);135 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); 130 136 131 137 while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} 138 139 /** Configure LSE Drive Capability 140 */ 141 HAL_PWR_EnableBkUpAccess(); 142 __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); 132 143 133 144 /** Initializes the RCC Oscillators according to the specified parameters 134 145 * in the RCC_OscInitTypeDef structure. 135 146 */ 136 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 137 RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; 138 RCC_OscInitStruct.HSICalibrationValue = 64; 139 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; 147 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; 148 RCC_OscInitStruct.HSEState = RCC_HSE_ON; 149 RCC_OscInitStruct.LSEState = RCC_LSE_ON; 150 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 151 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 152 RCC_OscInitStruct.PLL.PLLM = 25; 153 RCC_OscInitStruct.PLL.PLLN = 200; 154 RCC_OscInitStruct.PLL.PLLP = 2; 155 RCC_OscInitStruct.PLL.PLLQ = 2; 156 RCC_OscInitStruct.PLL.PLLR = 2; 157 RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_0; 158 RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM; 159 RCC_OscInitStruct.PLL.PLLFRACN = 0; 140 160 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 141 161 { … … 148 168 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 149 169 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; 150 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_ HSI;170 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 151 171 RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; 152 172 RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; … … 162 182 } 163 183 184 /** 185 * @brief RTC Initialization Function 186 * @param None 187 * @retval None 188 */ 189 static void MX_RTC_Init(void) 190 { 191 192 /* USER CODE BEGIN RTC_Init 0 */ 193 194 /* USER CODE END RTC_Init 0 */ 195 196 /* USER CODE BEGIN RTC_Init 1 */ 197 198 /* USER CODE END RTC_Init 1 */ 199 200 /** Initialize RTC Only 201 */ 202 hrtc.Instance = RTC; 203 hrtc.Init.HourFormat = RTC_HOURFORMAT_24; 204 hrtc.Init.AsynchPrediv = 127; 205 hrtc.Init.SynchPrediv = 255; 206 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 207 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 208 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 209 hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 210 if (HAL_RTC_Init(&hrtc) != HAL_OK) 211 { 212 Error_Handler(); 213 } 214 /* USER CODE BEGIN RTC_Init 2 */ 215 216 /* USER CODE END RTC_Init 2 */ 217 218 } 219 220 /** 221 * @brief GPIO Initialization Function 222 * @param None 223 * @retval None 224 */ 225 static void MX_GPIO_Init(void) 226 { 227 /* USER CODE BEGIN MX_GPIO_Init_1 */ 228 /* USER CODE END MX_GPIO_Init_1 */ 229 230 /* GPIO Ports Clock Enable */ 231 __HAL_RCC_GPIOC_CLK_ENABLE(); 232 __HAL_RCC_GPIOH_CLK_ENABLE(); 233 234 /* USER CODE BEGIN MX_GPIO_Init_2 */ 235 /* USER CODE END MX_GPIO_Init_2 */ 236 } 237 164 238 /* USER CODE BEGIN 4 */ 165 239 … … 170 244 void MPU_Config(void) 171 245 { 172 MPU_Region_InitTypeDef MPU_InitStruct {};246 MPU_Region_InitTypeDef MPU_InitStruct = {0}; 173 247 174 248 /* Disables the MPU */ -
ctrl/firmware/Main/CubeMX/Core/Src/stm32h7xx_hal_msp.c
r13 r39 77 77 } 78 78 79 /** 80 * @brief RTC MSP Initialization 81 * This function configures the hardware resources used in this example 82 * @param hrtc: RTC handle pointer 83 * @retval None 84 */ 85 void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) 86 { 87 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 88 if(hrtc->Instance==RTC) 89 { 90 /* USER CODE BEGIN RTC_MspInit 0 */ 91 92 /* USER CODE END RTC_MspInit 0 */ 93 94 /** Initializes the peripherals clock 95 */ 96 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; 97 PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 98 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 99 { 100 Error_Handler(); 101 } 102 103 /* Peripheral clock enable */ 104 __HAL_RCC_RTC_ENABLE(); 105 /* USER CODE BEGIN RTC_MspInit 1 */ 106 107 /* USER CODE END RTC_MspInit 1 */ 108 109 } 110 111 } 112 113 /** 114 * @brief RTC MSP De-Initialization 115 * This function freeze the hardware resources used in this example 116 * @param hrtc: RTC handle pointer 117 * @retval None 118 */ 119 void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) 120 { 121 if(hrtc->Instance==RTC) 122 { 123 /* USER CODE BEGIN RTC_MspDeInit 0 */ 124 125 /* USER CODE END RTC_MspDeInit 0 */ 126 /* Peripheral clock disable */ 127 __HAL_RCC_RTC_DISABLE(); 128 /* USER CODE BEGIN RTC_MspDeInit 1 */ 129 130 /* USER CODE END RTC_MspDeInit 1 */ 131 } 132 133 } 134 79 135 /* USER CODE BEGIN 1 */ 80 136
Note: See TracChangeset
for help on using the changeset viewer.