fatih
Dependencies: mbed-rtos mbed ros_lib_indigo
stm32f7xx_hal_msp.c@1:0f99619433e0, 2017-03-04 (annotated)
- Committer:
- randalthor
- Date:
- Sat Mar 04 14:08:19 2017 +0000
- Revision:
- 1:0f99619433e0
- Parent:
- 0:4d2d2219c8e4
fatihh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
randalthor | 0:4d2d2219c8e4 | 1 | /** |
randalthor | 0:4d2d2219c8e4 | 2 | ****************************************************************************** |
randalthor | 0:4d2d2219c8e4 | 3 | * File Name : stm32f7xx_hal_msp.c |
randalthor | 0:4d2d2219c8e4 | 4 | * Description : This file provides code for the MSP Initialization |
randalthor | 0:4d2d2219c8e4 | 5 | * and de-Initialization codes. |
randalthor | 0:4d2d2219c8e4 | 6 | ****************************************************************************** |
randalthor | 0:4d2d2219c8e4 | 7 | * |
randalthor | 0:4d2d2219c8e4 | 8 | * COPYRIGHT(c) 2017 STMicroelectronics |
randalthor | 0:4d2d2219c8e4 | 9 | * |
randalthor | 0:4d2d2219c8e4 | 10 | * Redistribution and use in source and binary forms, with or without modification, |
randalthor | 0:4d2d2219c8e4 | 11 | * are permitted provided that the following conditions are met: |
randalthor | 0:4d2d2219c8e4 | 12 | * 1. Redistributions of source code must retain the above copyright notice, |
randalthor | 0:4d2d2219c8e4 | 13 | * this list of conditions and the following disclaimer. |
randalthor | 0:4d2d2219c8e4 | 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
randalthor | 0:4d2d2219c8e4 | 15 | * this list of conditions and the following disclaimer in the documentation |
randalthor | 0:4d2d2219c8e4 | 16 | * and/or other materials provided with the distribution. |
randalthor | 0:4d2d2219c8e4 | 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
randalthor | 0:4d2d2219c8e4 | 18 | * may be used to endorse or promote products derived from this software |
randalthor | 0:4d2d2219c8e4 | 19 | * without specific prior written permission. |
randalthor | 0:4d2d2219c8e4 | 20 | * |
randalthor | 0:4d2d2219c8e4 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
randalthor | 0:4d2d2219c8e4 | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
randalthor | 0:4d2d2219c8e4 | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
randalthor | 0:4d2d2219c8e4 | 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
randalthor | 0:4d2d2219c8e4 | 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
randalthor | 0:4d2d2219c8e4 | 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
randalthor | 0:4d2d2219c8e4 | 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
randalthor | 0:4d2d2219c8e4 | 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
randalthor | 0:4d2d2219c8e4 | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
randalthor | 0:4d2d2219c8e4 | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
randalthor | 0:4d2d2219c8e4 | 31 | * |
randalthor | 0:4d2d2219c8e4 | 32 | ****************************************************************************** |
randalthor | 0:4d2d2219c8e4 | 33 | */ |
randalthor | 0:4d2d2219c8e4 | 34 | /* Includes ------------------------------------------------------------------*/ |
randalthor | 0:4d2d2219c8e4 | 35 | #include "stm32f7xx_hal.h" |
randalthor | 0:4d2d2219c8e4 | 36 | |
randalthor | 0:4d2d2219c8e4 | 37 | extern DMA_HandleTypeDef hdma_adc2; |
randalthor | 0:4d2d2219c8e4 | 38 | |
randalthor | 0:4d2d2219c8e4 | 39 | extern void Error_Handler(void); |
randalthor | 0:4d2d2219c8e4 | 40 | /* USER CODE BEGIN 0 */ |
randalthor | 0:4d2d2219c8e4 | 41 | |
randalthor | 0:4d2d2219c8e4 | 42 | /* USER CODE END 0 */ |
randalthor | 0:4d2d2219c8e4 | 43 | /** |
randalthor | 0:4d2d2219c8e4 | 44 | * Initializes the Global MSP. |
randalthor | 0:4d2d2219c8e4 | 45 | */ |
randalthor | 0:4d2d2219c8e4 | 46 | void HAL_MspInit(void) |
randalthor | 0:4d2d2219c8e4 | 47 | { |
randalthor | 0:4d2d2219c8e4 | 48 | /* USER CODE BEGIN MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 49 | |
randalthor | 0:4d2d2219c8e4 | 50 | /* USER CODE END MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 51 | |
randalthor | 0:4d2d2219c8e4 | 52 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
randalthor | 0:4d2d2219c8e4 | 53 | |
randalthor | 0:4d2d2219c8e4 | 54 | /* System interrupt init*/ |
randalthor | 0:4d2d2219c8e4 | 55 | /* MemoryManagement_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 56 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 57 | /* BusFault_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 58 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 59 | /* UsageFault_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 60 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 61 | /* SVCall_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 62 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 63 | /* DebugMonitor_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 64 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 65 | /* PendSV_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 66 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 67 | /* SysTick_IRQn interrupt configuration */ |
randalthor | 0:4d2d2219c8e4 | 68 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
randalthor | 0:4d2d2219c8e4 | 69 | |
randalthor | 0:4d2d2219c8e4 | 70 | /* USER CODE BEGIN MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 71 | |
randalthor | 0:4d2d2219c8e4 | 72 | /* USER CODE END MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 73 | } |
randalthor | 0:4d2d2219c8e4 | 74 | |
randalthor | 0:4d2d2219c8e4 | 75 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
randalthor | 0:4d2d2219c8e4 | 76 | { |
randalthor | 0:4d2d2219c8e4 | 77 | |
randalthor | 0:4d2d2219c8e4 | 78 | GPIO_InitTypeDef GPIO_InitStruct; |
randalthor | 0:4d2d2219c8e4 | 79 | if(hadc->Instance==ADC2) |
randalthor | 0:4d2d2219c8e4 | 80 | { |
randalthor | 0:4d2d2219c8e4 | 81 | /* USER CODE BEGIN ADC2_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 82 | |
randalthor | 0:4d2d2219c8e4 | 83 | /* USER CODE END ADC2_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 84 | /* Peripheral clock enable */ |
randalthor | 0:4d2d2219c8e4 | 85 | __HAL_RCC_ADC2_CLK_ENABLE(); |
randalthor | 0:4d2d2219c8e4 | 86 | |
randalthor | 0:4d2d2219c8e4 | 87 | /**ADC2 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 88 | PA5 ------> ADC2_IN5 |
randalthor | 0:4d2d2219c8e4 | 89 | PA6 ------> ADC2_IN6 |
randalthor | 0:4d2d2219c8e4 | 90 | */ |
randalthor | 0:4d2d2219c8e4 | 91 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; |
randalthor | 0:4d2d2219c8e4 | 92 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
randalthor | 0:4d2d2219c8e4 | 93 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
randalthor | 0:4d2d2219c8e4 | 94 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 95 | |
randalthor | 0:4d2d2219c8e4 | 96 | /* Peripheral DMA init*/ |
randalthor | 0:4d2d2219c8e4 | 97 | |
randalthor | 0:4d2d2219c8e4 | 98 | hdma_adc2.Instance = DMA2_Stream2; |
randalthor | 0:4d2d2219c8e4 | 99 | hdma_adc2.Init.Channel = DMA_CHANNEL_1; |
randalthor | 0:4d2d2219c8e4 | 100 | hdma_adc2.Init.Direction = DMA_PERIPH_TO_MEMORY; |
randalthor | 0:4d2d2219c8e4 | 101 | hdma_adc2.Init.PeriphInc = DMA_PINC_DISABLE; |
randalthor | 0:4d2d2219c8e4 | 102 | hdma_adc2.Init.MemInc = DMA_MINC_ENABLE; |
randalthor | 0:4d2d2219c8e4 | 103 | hdma_adc2.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; |
randalthor | 0:4d2d2219c8e4 | 104 | hdma_adc2.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; |
randalthor | 0:4d2d2219c8e4 | 105 | hdma_adc2.Init.Mode = DMA_CIRCULAR; |
randalthor | 0:4d2d2219c8e4 | 106 | hdma_adc2.Init.Priority = DMA_PRIORITY_LOW; |
randalthor | 0:4d2d2219c8e4 | 107 | hdma_adc2.Init.FIFOMode = DMA_FIFOMODE_DISABLE; |
randalthor | 0:4d2d2219c8e4 | 108 | if (HAL_DMA_Init(&hdma_adc2) != HAL_OK) |
randalthor | 0:4d2d2219c8e4 | 109 | { |
randalthor | 0:4d2d2219c8e4 | 110 | Error_Handler(); |
randalthor | 0:4d2d2219c8e4 | 111 | } |
randalthor | 0:4d2d2219c8e4 | 112 | |
randalthor | 0:4d2d2219c8e4 | 113 | __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc2); |
randalthor | 0:4d2d2219c8e4 | 114 | |
randalthor | 0:4d2d2219c8e4 | 115 | /* USER CODE BEGIN ADC2_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 116 | |
randalthor | 0:4d2d2219c8e4 | 117 | /* USER CODE END ADC2_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 118 | } |
randalthor | 0:4d2d2219c8e4 | 119 | |
randalthor | 0:4d2d2219c8e4 | 120 | } |
randalthor | 0:4d2d2219c8e4 | 121 | |
randalthor | 0:4d2d2219c8e4 | 122 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
randalthor | 0:4d2d2219c8e4 | 123 | { |
randalthor | 0:4d2d2219c8e4 | 124 | |
randalthor | 0:4d2d2219c8e4 | 125 | if(hadc->Instance==ADC2) |
randalthor | 0:4d2d2219c8e4 | 126 | { |
randalthor | 0:4d2d2219c8e4 | 127 | /* USER CODE BEGIN ADC2_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 128 | |
randalthor | 0:4d2d2219c8e4 | 129 | /* USER CODE END ADC2_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 130 | /* Peripheral clock disable */ |
randalthor | 0:4d2d2219c8e4 | 131 | __HAL_RCC_ADC2_CLK_DISABLE(); |
randalthor | 0:4d2d2219c8e4 | 132 | |
randalthor | 0:4d2d2219c8e4 | 133 | /**ADC2 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 134 | PA5 ------> ADC2_IN5 |
randalthor | 0:4d2d2219c8e4 | 135 | PA6 ------> ADC2_IN6 |
randalthor | 0:4d2d2219c8e4 | 136 | */ |
randalthor | 0:4d2d2219c8e4 | 137 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6); |
randalthor | 0:4d2d2219c8e4 | 138 | |
randalthor | 0:4d2d2219c8e4 | 139 | /* Peripheral DMA DeInit*/ |
randalthor | 0:4d2d2219c8e4 | 140 | HAL_DMA_DeInit(hadc->DMA_Handle); |
randalthor | 0:4d2d2219c8e4 | 141 | } |
randalthor | 0:4d2d2219c8e4 | 142 | /* USER CODE BEGIN ADC2_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 143 | |
randalthor | 0:4d2d2219c8e4 | 144 | /* USER CODE END ADC2_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 145 | |
randalthor | 0:4d2d2219c8e4 | 146 | } |
randalthor | 0:4d2d2219c8e4 | 147 | |
randalthor | 0:4d2d2219c8e4 | 148 | void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) |
randalthor | 0:4d2d2219c8e4 | 149 | { |
randalthor | 0:4d2d2219c8e4 | 150 | |
randalthor | 0:4d2d2219c8e4 | 151 | GPIO_InitTypeDef GPIO_InitStruct; |
randalthor | 0:4d2d2219c8e4 | 152 | if(htim_encoder->Instance==TIM1) |
randalthor | 0:4d2d2219c8e4 | 153 | { |
randalthor | 0:4d2d2219c8e4 | 154 | /* USER CODE BEGIN TIM1_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 155 | |
randalthor | 0:4d2d2219c8e4 | 156 | /* USER CODE END TIM1_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 157 | /* Peripheral clock enable */ |
randalthor | 0:4d2d2219c8e4 | 158 | __HAL_RCC_TIM1_CLK_ENABLE(); |
randalthor | 0:4d2d2219c8e4 | 159 | |
randalthor | 0:4d2d2219c8e4 | 160 | /**TIM1 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 161 | PE9 ------> TIM1_CH1 |
randalthor | 0:4d2d2219c8e4 | 162 | PE11 ------> TIM1_CH2 |
randalthor | 0:4d2d2219c8e4 | 163 | */ |
randalthor | 0:4d2d2219c8e4 | 164 | GPIO_InitStruct.Pin = GPIO_PIN_9; |
randalthor | 0:4d2d2219c8e4 | 165 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
randalthor | 0:4d2d2219c8e4 | 166 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
randalthor | 0:4d2d2219c8e4 | 167 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
randalthor | 0:4d2d2219c8e4 | 168 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; |
randalthor | 0:4d2d2219c8e4 | 169 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 170 | |
randalthor | 0:4d2d2219c8e4 | 171 | GPIO_InitStruct.Pin = GPIO_PIN_11; |
randalthor | 0:4d2d2219c8e4 | 172 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
randalthor | 0:4d2d2219c8e4 | 173 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
randalthor | 0:4d2d2219c8e4 | 174 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
randalthor | 0:4d2d2219c8e4 | 175 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; |
randalthor | 0:4d2d2219c8e4 | 176 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 177 | |
randalthor | 0:4d2d2219c8e4 | 178 | /* USER CODE BEGIN TIM1_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 179 | |
randalthor | 0:4d2d2219c8e4 | 180 | /* USER CODE END TIM1_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 181 | } |
randalthor | 0:4d2d2219c8e4 | 182 | else if(htim_encoder->Instance==TIM4) |
randalthor | 0:4d2d2219c8e4 | 183 | { |
randalthor | 0:4d2d2219c8e4 | 184 | /* USER CODE BEGIN TIM4_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 185 | |
randalthor | 0:4d2d2219c8e4 | 186 | /* USER CODE END TIM4_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 187 | /* Peripheral clock enable */ |
randalthor | 0:4d2d2219c8e4 | 188 | __HAL_RCC_TIM4_CLK_ENABLE(); |
randalthor | 0:4d2d2219c8e4 | 189 | |
randalthor | 0:4d2d2219c8e4 | 190 | /**TIM4 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 191 | PD12 ------> TIM4_CH1 |
randalthor | 0:4d2d2219c8e4 | 192 | PD13 ------> TIM4_CH2 |
randalthor | 0:4d2d2219c8e4 | 193 | */ |
randalthor | 0:4d2d2219c8e4 | 194 | GPIO_InitStruct.Pin = GPIO_PIN_12; |
randalthor | 0:4d2d2219c8e4 | 195 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
randalthor | 0:4d2d2219c8e4 | 196 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
randalthor | 0:4d2d2219c8e4 | 197 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
randalthor | 0:4d2d2219c8e4 | 198 | GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; |
randalthor | 0:4d2d2219c8e4 | 199 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 200 | |
randalthor | 0:4d2d2219c8e4 | 201 | GPIO_InitStruct.Pin = GPIO_PIN_13; |
randalthor | 0:4d2d2219c8e4 | 202 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
randalthor | 0:4d2d2219c8e4 | 203 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
randalthor | 0:4d2d2219c8e4 | 204 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
randalthor | 0:4d2d2219c8e4 | 205 | GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; |
randalthor | 0:4d2d2219c8e4 | 206 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 207 | |
randalthor | 0:4d2d2219c8e4 | 208 | /* USER CODE BEGIN TIM4_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 209 | |
randalthor | 0:4d2d2219c8e4 | 210 | /* USER CODE END TIM4_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 211 | } |
randalthor | 0:4d2d2219c8e4 | 212 | |
randalthor | 0:4d2d2219c8e4 | 213 | } |
randalthor | 0:4d2d2219c8e4 | 214 | |
randalthor | 0:4d2d2219c8e4 | 215 | void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) |
randalthor | 0:4d2d2219c8e4 | 216 | { |
randalthor | 0:4d2d2219c8e4 | 217 | |
randalthor | 0:4d2d2219c8e4 | 218 | if(htim_pwm->Instance==TIM9) |
randalthor | 0:4d2d2219c8e4 | 219 | { |
randalthor | 0:4d2d2219c8e4 | 220 | /* USER CODE BEGIN TIM9_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 221 | |
randalthor | 0:4d2d2219c8e4 | 222 | /* USER CODE END TIM9_MspInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 223 | /* Peripheral clock enable */ |
randalthor | 0:4d2d2219c8e4 | 224 | __HAL_RCC_TIM9_CLK_ENABLE(); |
randalthor | 0:4d2d2219c8e4 | 225 | /* USER CODE BEGIN TIM9_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 226 | |
randalthor | 0:4d2d2219c8e4 | 227 | /* USER CODE END TIM9_MspInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 228 | } |
randalthor | 0:4d2d2219c8e4 | 229 | |
randalthor | 0:4d2d2219c8e4 | 230 | } |
randalthor | 0:4d2d2219c8e4 | 231 | |
randalthor | 0:4d2d2219c8e4 | 232 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
randalthor | 0:4d2d2219c8e4 | 233 | { |
randalthor | 0:4d2d2219c8e4 | 234 | |
randalthor | 0:4d2d2219c8e4 | 235 | GPIO_InitTypeDef GPIO_InitStruct; |
randalthor | 0:4d2d2219c8e4 | 236 | if(htim->Instance==TIM9) |
randalthor | 0:4d2d2219c8e4 | 237 | { |
randalthor | 0:4d2d2219c8e4 | 238 | /* USER CODE BEGIN TIM9_MspPostInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 239 | |
randalthor | 0:4d2d2219c8e4 | 240 | /* USER CODE END TIM9_MspPostInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 241 | |
randalthor | 0:4d2d2219c8e4 | 242 | /**TIM9 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 243 | PE5 ------> TIM9_CH1 |
randalthor | 0:4d2d2219c8e4 | 244 | PE6 ------> TIM9_CH2 |
randalthor | 0:4d2d2219c8e4 | 245 | */ |
randalthor | 0:4d2d2219c8e4 | 246 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; |
randalthor | 0:4d2d2219c8e4 | 247 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
randalthor | 0:4d2d2219c8e4 | 248 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
randalthor | 0:4d2d2219c8e4 | 249 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
randalthor | 0:4d2d2219c8e4 | 250 | GPIO_InitStruct.Alternate = GPIO_AF3_TIM9; |
randalthor | 0:4d2d2219c8e4 | 251 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
randalthor | 0:4d2d2219c8e4 | 252 | |
randalthor | 0:4d2d2219c8e4 | 253 | /* USER CODE BEGIN TIM9_MspPostInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 254 | |
randalthor | 0:4d2d2219c8e4 | 255 | /* USER CODE END TIM9_MspPostInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 256 | } |
randalthor | 0:4d2d2219c8e4 | 257 | |
randalthor | 0:4d2d2219c8e4 | 258 | } |
randalthor | 0:4d2d2219c8e4 | 259 | |
randalthor | 0:4d2d2219c8e4 | 260 | void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) |
randalthor | 0:4d2d2219c8e4 | 261 | { |
randalthor | 0:4d2d2219c8e4 | 262 | |
randalthor | 0:4d2d2219c8e4 | 263 | if(htim_encoder->Instance==TIM1) |
randalthor | 0:4d2d2219c8e4 | 264 | { |
randalthor | 0:4d2d2219c8e4 | 265 | /* USER CODE BEGIN TIM1_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 266 | |
randalthor | 0:4d2d2219c8e4 | 267 | /* USER CODE END TIM1_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 268 | /* Peripheral clock disable */ |
randalthor | 0:4d2d2219c8e4 | 269 | __HAL_RCC_TIM1_CLK_DISABLE(); |
randalthor | 0:4d2d2219c8e4 | 270 | |
randalthor | 0:4d2d2219c8e4 | 271 | /**TIM1 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 272 | PE9 ------> TIM1_CH1 |
randalthor | 0:4d2d2219c8e4 | 273 | PE11 ------> TIM1_CH2 |
randalthor | 0:4d2d2219c8e4 | 274 | */ |
randalthor | 0:4d2d2219c8e4 | 275 | HAL_GPIO_DeInit(GPIOE, GPIO_PIN_9|GPIO_PIN_11); |
randalthor | 0:4d2d2219c8e4 | 276 | |
randalthor | 0:4d2d2219c8e4 | 277 | /* USER CODE BEGIN TIM1_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 278 | |
randalthor | 0:4d2d2219c8e4 | 279 | /* USER CODE END TIM1_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 280 | } |
randalthor | 0:4d2d2219c8e4 | 281 | else if(htim_encoder->Instance==TIM4) |
randalthor | 0:4d2d2219c8e4 | 282 | { |
randalthor | 0:4d2d2219c8e4 | 283 | /* USER CODE BEGIN TIM4_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 284 | |
randalthor | 0:4d2d2219c8e4 | 285 | /* USER CODE END TIM4_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 286 | /* Peripheral clock disable */ |
randalthor | 0:4d2d2219c8e4 | 287 | __HAL_RCC_TIM4_CLK_DISABLE(); |
randalthor | 0:4d2d2219c8e4 | 288 | |
randalthor | 0:4d2d2219c8e4 | 289 | /**TIM4 GPIO Configuration |
randalthor | 0:4d2d2219c8e4 | 290 | PD12 ------> TIM4_CH1 |
randalthor | 0:4d2d2219c8e4 | 291 | PD13 ------> TIM4_CH2 |
randalthor | 0:4d2d2219c8e4 | 292 | */ |
randalthor | 0:4d2d2219c8e4 | 293 | HAL_GPIO_DeInit(GPIOD, GPIO_PIN_12|GPIO_PIN_13); |
randalthor | 0:4d2d2219c8e4 | 294 | |
randalthor | 0:4d2d2219c8e4 | 295 | /* USER CODE BEGIN TIM4_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 296 | |
randalthor | 0:4d2d2219c8e4 | 297 | /* USER CODE END TIM4_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 298 | } |
randalthor | 0:4d2d2219c8e4 | 299 | |
randalthor | 0:4d2d2219c8e4 | 300 | } |
randalthor | 0:4d2d2219c8e4 | 301 | |
randalthor | 0:4d2d2219c8e4 | 302 | void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) |
randalthor | 0:4d2d2219c8e4 | 303 | { |
randalthor | 0:4d2d2219c8e4 | 304 | |
randalthor | 0:4d2d2219c8e4 | 305 | if(htim_pwm->Instance==TIM9) |
randalthor | 0:4d2d2219c8e4 | 306 | { |
randalthor | 0:4d2d2219c8e4 | 307 | /* USER CODE BEGIN TIM9_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 308 | |
randalthor | 0:4d2d2219c8e4 | 309 | /* USER CODE END TIM9_MspDeInit 0 */ |
randalthor | 0:4d2d2219c8e4 | 310 | /* Peripheral clock disable */ |
randalthor | 0:4d2d2219c8e4 | 311 | __HAL_RCC_TIM9_CLK_DISABLE(); |
randalthor | 0:4d2d2219c8e4 | 312 | } |
randalthor | 0:4d2d2219c8e4 | 313 | /* USER CODE BEGIN TIM9_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 314 | |
randalthor | 0:4d2d2219c8e4 | 315 | /* USER CODE END TIM9_MspDeInit 1 */ |
randalthor | 0:4d2d2219c8e4 | 316 | |
randalthor | 0:4d2d2219c8e4 | 317 | } |
randalthor | 0:4d2d2219c8e4 | 318 | |
randalthor | 0:4d2d2219c8e4 | 319 | /* USER CODE BEGIN 1 */ |
randalthor | 0:4d2d2219c8e4 | 320 | void Error_Handler(void) |
randalthor | 0:4d2d2219c8e4 | 321 | { |
randalthor | 0:4d2d2219c8e4 | 322 | /* USER CODE BEGIN Error_Handler */ |
randalthor | 0:4d2d2219c8e4 | 323 | /* User can add his own implementation to report the HAL error return state */ |
randalthor | 0:4d2d2219c8e4 | 324 | while(1) |
randalthor | 0:4d2d2219c8e4 | 325 | { |
randalthor | 0:4d2d2219c8e4 | 326 | } |
randalthor | 0:4d2d2219c8e4 | 327 | /* USER CODE END Error_Handler */ |
randalthor | 0:4d2d2219c8e4 | 328 | } |
randalthor | 0:4d2d2219c8e4 | 329 | /* USER CODE END 1 */ |
randalthor | 0:4d2d2219c8e4 | 330 | |
randalthor | 0:4d2d2219c8e4 | 331 | /** |
randalthor | 0:4d2d2219c8e4 | 332 | * @} |
randalthor | 0:4d2d2219c8e4 | 333 | */ |
randalthor | 0:4d2d2219c8e4 | 334 | |
randalthor | 0:4d2d2219c8e4 | 335 | /** |
randalthor | 0:4d2d2219c8e4 | 336 | * @} |
randalthor | 0:4d2d2219c8e4 | 337 | */ |
randalthor | 0:4d2d2219c8e4 | 338 | |
randalthor | 0:4d2d2219c8e4 | 339 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
randalthor | 0:4d2d2219c8e4 | 340 |