Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed ros_lib_indigo
stm32f7xx_hal_msp.c
00001 /** 00002 ****************************************************************************** 00003 * File Name : stm32f7xx_hal_msp.c 00004 * Description : This file provides code for the MSP Initialization 00005 * and de-Initialization codes. 00006 ****************************************************************************** 00007 * 00008 * COPYRIGHT(c) 2017 STMicroelectronics 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 1. Redistributions of source code must retain the above copyright notice, 00013 * this list of conditions and the following disclaimer. 00014 * 2. Redistributions in binary form must reproduce the above copyright notice, 00015 * this list of conditions and the following disclaimer in the documentation 00016 * and/or other materials provided with the distribution. 00017 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00018 * may be used to endorse or promote products derived from this software 00019 * without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00025 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00026 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00027 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00028 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00030 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 * 00032 ****************************************************************************** 00033 */ 00034 /* Includes ------------------------------------------------------------------*/ 00035 #include "stm32f7xx_hal.h" 00036 00037 extern DMA_HandleTypeDef hdma_adc2; 00038 00039 extern void Error_Handler(void); 00040 /* USER CODE BEGIN 0 */ 00041 00042 /* USER CODE END 0 */ 00043 /** 00044 * Initializes the Global MSP. 00045 */ 00046 void HAL_MspInit(void) 00047 { 00048 /* USER CODE BEGIN MspInit 0 */ 00049 00050 /* USER CODE END MspInit 0 */ 00051 00052 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 00053 00054 /* System interrupt init*/ 00055 /* MemoryManagement_IRQn interrupt configuration */ 00056 HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 00057 /* BusFault_IRQn interrupt configuration */ 00058 HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 00059 /* UsageFault_IRQn interrupt configuration */ 00060 HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 00061 /* SVCall_IRQn interrupt configuration */ 00062 HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 00063 /* DebugMonitor_IRQn interrupt configuration */ 00064 HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 00065 /* PendSV_IRQn interrupt configuration */ 00066 HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 00067 /* SysTick_IRQn interrupt configuration */ 00068 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 00069 00070 /* USER CODE BEGIN MspInit 1 */ 00071 00072 /* USER CODE END MspInit 1 */ 00073 } 00074 00075 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) 00076 { 00077 00078 GPIO_InitTypeDef GPIO_InitStruct; 00079 if(hadc->Instance==ADC2) 00080 { 00081 /* USER CODE BEGIN ADC2_MspInit 0 */ 00082 00083 /* USER CODE END ADC2_MspInit 0 */ 00084 /* Peripheral clock enable */ 00085 __HAL_RCC_ADC2_CLK_ENABLE(); 00086 00087 /**ADC2 GPIO Configuration 00088 PA5 ------> ADC2_IN5 00089 PA6 ------> ADC2_IN6 00090 */ 00091 GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; 00092 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 00093 GPIO_InitStruct.Pull = GPIO_NOPULL; 00094 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 00095 00096 /* Peripheral DMA init*/ 00097 00098 hdma_adc2.Instance = DMA2_Stream2; 00099 hdma_adc2.Init.Channel = DMA_CHANNEL_1; 00100 hdma_adc2.Init.Direction = DMA_PERIPH_TO_MEMORY; 00101 hdma_adc2.Init.PeriphInc = DMA_PINC_DISABLE; 00102 hdma_adc2.Init.MemInc = DMA_MINC_ENABLE; 00103 hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 00104 hdma_adc2.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 00105 hdma_adc2.Init.Mode = DMA_CIRCULAR; 00106 hdma_adc2.Init.Priority = DMA_PRIORITY_LOW; 00107 hdma_adc2.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 00108 if (HAL_DMA_Init(&hdma_adc2) != HAL_OK) 00109 { 00110 Error_Handler(); 00111 } 00112 00113 __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc2); 00114 00115 /* USER CODE BEGIN ADC2_MspInit 1 */ 00116 00117 /* USER CODE END ADC2_MspInit 1 */ 00118 } 00119 00120 } 00121 00122 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) 00123 { 00124 00125 if(hadc->Instance==ADC2) 00126 { 00127 /* USER CODE BEGIN ADC2_MspDeInit 0 */ 00128 00129 /* USER CODE END ADC2_MspDeInit 0 */ 00130 /* Peripheral clock disable */ 00131 __HAL_RCC_ADC2_CLK_DISABLE(); 00132 00133 /**ADC2 GPIO Configuration 00134 PA5 ------> ADC2_IN5 00135 PA6 ------> ADC2_IN6 00136 */ 00137 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6); 00138 00139 /* Peripheral DMA DeInit*/ 00140 HAL_DMA_DeInit(hadc->DMA_Handle); 00141 } 00142 /* USER CODE BEGIN ADC2_MspDeInit 1 */ 00143 00144 /* USER CODE END ADC2_MspDeInit 1 */ 00145 00146 } 00147 00148 void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) 00149 { 00150 00151 GPIO_InitTypeDef GPIO_InitStruct; 00152 if(htim_encoder->Instance==TIM1) 00153 { 00154 /* USER CODE BEGIN TIM1_MspInit 0 */ 00155 00156 /* USER CODE END TIM1_MspInit 0 */ 00157 /* Peripheral clock enable */ 00158 __HAL_RCC_TIM1_CLK_ENABLE(); 00159 00160 /**TIM1 GPIO Configuration 00161 PE9 ------> TIM1_CH1 00162 PE11 ------> TIM1_CH2 00163 */ 00164 GPIO_InitStruct.Pin = GPIO_PIN_9; 00165 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 00166 GPIO_InitStruct.Pull = GPIO_PULLUP; 00167 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 00168 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; 00169 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 00170 00171 GPIO_InitStruct.Pin = GPIO_PIN_11; 00172 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 00173 GPIO_InitStruct.Pull = GPIO_PULLUP; 00174 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 00175 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; 00176 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 00177 00178 /* USER CODE BEGIN TIM1_MspInit 1 */ 00179 00180 /* USER CODE END TIM1_MspInit 1 */ 00181 } 00182 else if(htim_encoder->Instance==TIM4) 00183 { 00184 /* USER CODE BEGIN TIM4_MspInit 0 */ 00185 00186 /* USER CODE END TIM4_MspInit 0 */ 00187 /* Peripheral clock enable */ 00188 __HAL_RCC_TIM4_CLK_ENABLE(); 00189 00190 /**TIM4 GPIO Configuration 00191 PD12 ------> TIM4_CH1 00192 PD13 ------> TIM4_CH2 00193 */ 00194 GPIO_InitStruct.Pin = GPIO_PIN_12; 00195 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 00196 GPIO_InitStruct.Pull = GPIO_PULLUP; 00197 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 00198 GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; 00199 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 00200 00201 GPIO_InitStruct.Pin = GPIO_PIN_13; 00202 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 00203 GPIO_InitStruct.Pull = GPIO_PULLUP; 00204 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 00205 GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; 00206 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 00207 00208 /* USER CODE BEGIN TIM4_MspInit 1 */ 00209 00210 /* USER CODE END TIM4_MspInit 1 */ 00211 } 00212 00213 } 00214 00215 void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) 00216 { 00217 00218 if(htim_pwm->Instance==TIM9) 00219 { 00220 /* USER CODE BEGIN TIM9_MspInit 0 */ 00221 00222 /* USER CODE END TIM9_MspInit 0 */ 00223 /* Peripheral clock enable */ 00224 __HAL_RCC_TIM9_CLK_ENABLE(); 00225 /* USER CODE BEGIN TIM9_MspInit 1 */ 00226 00227 /* USER CODE END TIM9_MspInit 1 */ 00228 } 00229 00230 } 00231 00232 void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) 00233 { 00234 00235 GPIO_InitTypeDef GPIO_InitStruct; 00236 if(htim->Instance==TIM9) 00237 { 00238 /* USER CODE BEGIN TIM9_MspPostInit 0 */ 00239 00240 /* USER CODE END TIM9_MspPostInit 0 */ 00241 00242 /**TIM9 GPIO Configuration 00243 PE5 ------> TIM9_CH1 00244 PE6 ------> TIM9_CH2 00245 */ 00246 GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; 00247 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 00248 GPIO_InitStruct.Pull = GPIO_NOPULL; 00249 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 00250 GPIO_InitStruct.Alternate = GPIO_AF3_TIM9; 00251 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 00252 00253 /* USER CODE BEGIN TIM9_MspPostInit 1 */ 00254 00255 /* USER CODE END TIM9_MspPostInit 1 */ 00256 } 00257 00258 } 00259 00260 void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) 00261 { 00262 00263 if(htim_encoder->Instance==TIM1) 00264 { 00265 /* USER CODE BEGIN TIM1_MspDeInit 0 */ 00266 00267 /* USER CODE END TIM1_MspDeInit 0 */ 00268 /* Peripheral clock disable */ 00269 __HAL_RCC_TIM1_CLK_DISABLE(); 00270 00271 /**TIM1 GPIO Configuration 00272 PE9 ------> TIM1_CH1 00273 PE11 ------> TIM1_CH2 00274 */ 00275 HAL_GPIO_DeInit(GPIOE, GPIO_PIN_9|GPIO_PIN_11); 00276 00277 /* USER CODE BEGIN TIM1_MspDeInit 1 */ 00278 00279 /* USER CODE END TIM1_MspDeInit 1 */ 00280 } 00281 else if(htim_encoder->Instance==TIM4) 00282 { 00283 /* USER CODE BEGIN TIM4_MspDeInit 0 */ 00284 00285 /* USER CODE END TIM4_MspDeInit 0 */ 00286 /* Peripheral clock disable */ 00287 __HAL_RCC_TIM4_CLK_DISABLE(); 00288 00289 /**TIM4 GPIO Configuration 00290 PD12 ------> TIM4_CH1 00291 PD13 ------> TIM4_CH2 00292 */ 00293 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_12|GPIO_PIN_13); 00294 00295 /* USER CODE BEGIN TIM4_MspDeInit 1 */ 00296 00297 /* USER CODE END TIM4_MspDeInit 1 */ 00298 } 00299 00300 } 00301 00302 void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) 00303 { 00304 00305 if(htim_pwm->Instance==TIM9) 00306 { 00307 /* USER CODE BEGIN TIM9_MspDeInit 0 */ 00308 00309 /* USER CODE END TIM9_MspDeInit 0 */ 00310 /* Peripheral clock disable */ 00311 __HAL_RCC_TIM9_CLK_DISABLE(); 00312 } 00313 /* USER CODE BEGIN TIM9_MspDeInit 1 */ 00314 00315 /* USER CODE END TIM9_MspDeInit 1 */ 00316 00317 } 00318 00319 /* USER CODE BEGIN 1 */ 00320 void Error_Handler(void) 00321 { 00322 /* USER CODE BEGIN Error_Handler */ 00323 /* User can add his own implementation to report the HAL error return state */ 00324 while(1) 00325 { 00326 } 00327 /* USER CODE END Error_Handler */ 00328 } 00329 /* USER CODE END 1 */ 00330 00331 /** 00332 * @} 00333 */ 00334 00335 /** 00336 * @} 00337 */ 00338 00339 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00340
Generated on Mon Jul 18 2022 08:42:57 by
