Changeset 47 for ctrl/firmware/Main/CubeMX
- Timestamp:
- Dec 4, 2024, 1:39:50 PM (6 weeks ago)
- Location:
- ctrl/firmware/Main/CubeMX
- Files:
-
- 10 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/CubeMX/Core/Inc/stm32h7xx_hal_conf.h
r45 r47 236 236 * HAL drivers code 237 237 */ 238 /* #define USE_FULL_ASSERT 1U */ 238 #define USE_FULL_ASSERT 1U 239 239 240 240 /* Includes ------------------------------------------------------------------*/ -
ctrl/firmware/Main/CubeMX/Core/Src/main.c
r45 r47 19 19 /* Includes ------------------------------------------------------------------*/ 20 20 #include "main.h" 21 #include "dma.h" 22 #include "memorymap.h" 23 #include "rtc.h" 24 #include "spi.h" 25 #include "gpio.h" 21 26 22 27 /* Private includes ----------------------------------------------------------*/ … … 41 46 42 47 /* Private variables ---------------------------------------------------------*/ 43 44 RTC_HandleTypeDef hrtc;45 46 SPI_HandleTypeDef hspi4;47 DMA_HandleTypeDef hdma_spi4_tx;48 48 49 49 /* USER CODE BEGIN PV */ … … 54 54 void SystemClock_Config(void); 55 55 static void MPU_Config(void); 56 static void MX_GPIO_Init(void);57 static void MX_DMA_Init(void);58 static void MX_RTC_Init(void);59 static void MX_SPI4_Init(void);60 56 /* USER CODE BEGIN PFP */ 61 57 … … 189 185 } 190 186 191 /**192 * @brief RTC Initialization Function193 * @param None194 * @retval None195 */196 static void MX_RTC_Init(void)197 {198 199 /* USER CODE BEGIN RTC_Init 0 */200 201 /* USER CODE END RTC_Init 0 */202 203 /* USER CODE BEGIN RTC_Init 1 */204 205 /* USER CODE END RTC_Init 1 */206 207 /** Initialize RTC Only208 */209 hrtc.Instance = RTC;210 hrtc.Init.HourFormat = RTC_HOURFORMAT_24;211 hrtc.Init.AsynchPrediv = 127;212 hrtc.Init.SynchPrediv = 255;213 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;214 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;215 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;216 hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;217 if (HAL_RTC_Init(&hrtc) != HAL_OK)218 {219 Error_Handler();220 }221 /* USER CODE BEGIN RTC_Init 2 */222 223 /* USER CODE END RTC_Init 2 */224 225 }226 227 /**228 * @brief SPI4 Initialization Function229 * @param None230 * @retval None231 */232 static void MX_SPI4_Init(void)233 {234 235 /* USER CODE BEGIN SPI4_Init 0 */236 237 /* USER CODE END SPI4_Init 0 */238 239 /* USER CODE BEGIN SPI4_Init 1 */240 241 /* USER CODE END SPI4_Init 1 */242 /* SPI4 parameter configuration*/243 hspi4.Instance = SPI4;244 hspi4.Init.Mode = SPI_MODE_MASTER;245 hspi4.Init.Direction = SPI_DIRECTION_1LINE;246 hspi4.Init.DataSize = SPI_DATASIZE_9BIT;247 hspi4.Init.CLKPolarity = SPI_POLARITY_LOW;248 hspi4.Init.CLKPhase = SPI_PHASE_1EDGE;249 hspi4.Init.NSS = SPI_NSS_HARD_OUTPUT;250 hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;251 hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB;252 hspi4.Init.TIMode = SPI_TIMODE_DISABLE;253 hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;254 hspi4.Init.CRCPolynomial = 0x0;255 hspi4.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;256 hspi4.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;257 hspi4.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;258 hspi4.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;259 hspi4.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;260 hspi4.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;261 hspi4.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;262 hspi4.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;263 hspi4.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;264 hspi4.Init.IOSwap = SPI_IO_SWAP_DISABLE;265 if (HAL_SPI_Init(&hspi4) != HAL_OK)266 {267 Error_Handler();268 }269 /* USER CODE BEGIN SPI4_Init 2 */270 271 /* USER CODE END SPI4_Init 2 */272 273 }274 275 /**276 * Enable DMA controller clock277 */278 static void MX_DMA_Init(void)279 {280 281 /* DMA controller clock enable */282 __HAL_RCC_DMA1_CLK_ENABLE();283 284 /* DMA interrupt init */285 /* DMA1_Stream0_IRQn interrupt configuration */286 HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);287 HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);288 289 }290 291 /**292 * @brief GPIO Initialization Function293 * @param None294 * @retval None295 */296 static void MX_GPIO_Init(void)297 {298 /* USER CODE BEGIN MX_GPIO_Init_1 */299 /* USER CODE END MX_GPIO_Init_1 */300 301 /* GPIO Ports Clock Enable */302 __HAL_RCC_GPIOC_CLK_ENABLE();303 __HAL_RCC_GPIOH_CLK_ENABLE();304 __HAL_RCC_GPIOE_CLK_ENABLE();305 306 /* USER CODE BEGIN MX_GPIO_Init_2 */307 /* USER CODE END MX_GPIO_Init_2 */308 }309 310 187 /* USER CODE BEGIN 4 */ 311 188 … … 369 246 /* User can add his own implementation to report the file name and line number, 370 247 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 248 371 249 /* USER CODE END 6 */ 372 250 } -
ctrl/firmware/Main/CubeMX/Core/Src/stm32h7xx_hal_msp.c
r45 r47 24 24 25 25 /* USER CODE END Includes */ 26 extern DMA_HandleTypeDef hdma_spi4_tx;27 26 28 27 /* Private typedef -----------------------------------------------------------*/ … … 78 77 } 79 78 80 /**81 * @brief RTC MSP Initialization82 * This function configures the hardware resources used in this example83 * @param hrtc: RTC handle pointer84 * @retval None85 */86 void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)87 {88 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};89 if(hrtc->Instance==RTC)90 {91 /* USER CODE BEGIN RTC_MspInit 0 */92 93 /* USER CODE END RTC_MspInit 0 */94 95 /** Initializes the peripherals clock96 */97 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;98 PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;99 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)100 {101 Error_Handler();102 }103 104 /* Peripheral clock enable */105 __HAL_RCC_RTC_ENABLE();106 /* USER CODE BEGIN RTC_MspInit 1 */107 108 /* USER CODE END RTC_MspInit 1 */109 110 }111 112 }113 114 /**115 * @brief RTC MSP De-Initialization116 * This function freeze the hardware resources used in this example117 * @param hrtc: RTC handle pointer118 * @retval None119 */120 void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)121 {122 if(hrtc->Instance==RTC)123 {124 /* USER CODE BEGIN RTC_MspDeInit 0 */125 126 /* USER CODE END RTC_MspDeInit 0 */127 /* Peripheral clock disable */128 __HAL_RCC_RTC_DISABLE();129 /* USER CODE BEGIN RTC_MspDeInit 1 */130 131 /* USER CODE END RTC_MspDeInit 1 */132 }133 134 }135 136 /**137 * @brief SPI MSP Initialization138 * This function configures the hardware resources used in this example139 * @param hspi: SPI handle pointer140 * @retval None141 */142 void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)143 {144 GPIO_InitTypeDef GPIO_InitStruct = {0};145 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};146 if(hspi->Instance==SPI4)147 {148 /* USER CODE BEGIN SPI4_MspInit 0 */149 150 /* USER CODE END SPI4_MspInit 0 */151 152 /** Initializes the peripherals clock153 */154 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI4;155 PeriphClkInitStruct.PLL2.PLL2M = 3;156 PeriphClkInitStruct.PLL2.PLL2N = 40;157 PeriphClkInitStruct.PLL2.PLL2P = 2;158 PeriphClkInitStruct.PLL2.PLL2Q = 11;159 PeriphClkInitStruct.PLL2.PLL2R = 2;160 PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;161 PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;162 PeriphClkInitStruct.PLL2.PLL2FRACN = 0.0;163 PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_PLL2;164 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)165 {166 Error_Handler();167 }168 169 /* Peripheral clock enable */170 __HAL_RCC_SPI4_CLK_ENABLE();171 172 __HAL_RCC_GPIOE_CLK_ENABLE();173 /**SPI4 GPIO Configuration174 PE11 ------> SPI4_NSS175 PE12 ------> SPI4_SCK176 PE14 ------> SPI4_MOSI177 */178 GPIO_InitStruct.Pin = SPI4_NSS_DISPLAY_Pin|SPI4_SCK_DISPLAY_Pin|SPI4_MOSI_DISPLAY_Pin;179 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;180 GPIO_InitStruct.Pull = GPIO_NOPULL;181 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;182 GPIO_InitStruct.Alternate = GPIO_AF5_SPI4;183 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);184 185 /* SPI4 DMA Init */186 /* SPI4_TX Init */187 hdma_spi4_tx.Instance = DMA1_Stream0;188 hdma_spi4_tx.Init.Request = DMA_REQUEST_SPI4_TX;189 hdma_spi4_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;190 hdma_spi4_tx.Init.PeriphInc = DMA_PINC_DISABLE;191 hdma_spi4_tx.Init.MemInc = DMA_MINC_ENABLE;192 hdma_spi4_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;193 hdma_spi4_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;194 hdma_spi4_tx.Init.Mode = DMA_NORMAL;195 hdma_spi4_tx.Init.Priority = DMA_PRIORITY_LOW;196 hdma_spi4_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;197 if (HAL_DMA_Init(&hdma_spi4_tx) != HAL_OK)198 {199 Error_Handler();200 }201 202 __HAL_LINKDMA(hspi,hdmatx,hdma_spi4_tx);203 204 /* SPI4 interrupt Init */205 HAL_NVIC_SetPriority(SPI4_IRQn, 0, 0);206 HAL_NVIC_EnableIRQ(SPI4_IRQn);207 /* USER CODE BEGIN SPI4_MspInit 1 */208 209 /* USER CODE END SPI4_MspInit 1 */210 211 }212 213 }214 215 /**216 * @brief SPI MSP De-Initialization217 * This function freeze the hardware resources used in this example218 * @param hspi: SPI handle pointer219 * @retval None220 */221 void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)222 {223 if(hspi->Instance==SPI4)224 {225 /* USER CODE BEGIN SPI4_MspDeInit 0 */226 227 /* USER CODE END SPI4_MspDeInit 0 */228 /* Peripheral clock disable */229 __HAL_RCC_SPI4_CLK_DISABLE();230 231 /**SPI4 GPIO Configuration232 PE11 ------> SPI4_NSS233 PE12 ------> SPI4_SCK234 PE14 ------> SPI4_MOSI235 */236 HAL_GPIO_DeInit(GPIOE, SPI4_NSS_DISPLAY_Pin|SPI4_SCK_DISPLAY_Pin|SPI4_MOSI_DISPLAY_Pin);237 238 /* SPI4 DMA DeInit */239 HAL_DMA_DeInit(hspi->hdmatx);240 241 /* SPI4 interrupt DeInit */242 HAL_NVIC_DisableIRQ(SPI4_IRQn);243 /* USER CODE BEGIN SPI4_MspDeInit 1 */244 245 /* USER CODE END SPI4_MspDeInit 1 */246 }247 248 }249 250 79 /* USER CODE BEGIN 1 */ 251 80 -
ctrl/firmware/Main/CubeMX/charger.ioc
r45 r47 102 102 ProjectManager.CompilerOptimize=6 103 103 ProjectManager.ComputerToolchain=false 104 ProjectManager.CoupleFile= false104 ProjectManager.CoupleFile=true 105 105 ProjectManager.CustomerFirmwarePackage= 106 106 ProjectManager.DefaultFWLocation=true … … 108 108 ProjectManager.DeviceId=STM32H723ZETx 109 109 ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.12.0 110 ProjectManager.FreePins= false111 ProjectManager.HalAssertFull= false110 ProjectManager.FreePins=true 111 ProjectManager.HalAssertFull=true 112 112 ProjectManager.HeapSize=0x200 113 113 ProjectManager.KeepUserCode=true
Note: See TracChangeset
for help on using the changeset viewer.