Rev 6 | Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * File Name : stm32l1xx_hal_msp.c |
||
| 4 | * Description : This file provides code for the MSP Initialization |
||
| 5 | * and de-Initialization codes. |
||
| 6 | ****************************************************************************** |
||
| 7 | * |
||
| 8 | * COPYRIGHT(c) 2016 STMicroelectronics |
||
| 9 | * |
||
| 10 | * Redistribution and use in source and binary forms, with or without modification, |
||
| 11 | * are permitted provided that the following conditions are met: |
||
| 12 | * 1. Redistributions of source code must retain the above copyright notice, |
||
| 13 | * this list of conditions and the following disclaimer. |
||
| 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
| 15 | * this list of conditions and the following disclaimer in the documentation |
||
| 16 | * and/or other materials provided with the distribution. |
||
| 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
| 18 | * may be used to endorse or promote products derived from this software |
||
| 19 | * without specific prior written permission. |
||
| 20 | * |
||
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
| 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
| 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
| 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 31 | * |
||
| 32 | ****************************************************************************** |
||
| 33 | */ |
||
| 34 | /* Includes ------------------------------------------------------------------*/ |
||
| 35 | #include "stm32l1xx_hal.h" |
||
| 36 | |||
| 6 | mjames | 37 | extern DMA_HandleTypeDef hdma_adc; |
| 38 | |||
| 2 | mjames | 39 | extern void Error_Handler(void); |
| 40 | /* USER CODE BEGIN 0 */ |
||
| 41 | |||
| 42 | /* USER CODE END 0 */ |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Initializes the Global MSP. |
||
| 46 | */ |
||
| 47 | void HAL_MspInit(void) |
||
| 48 | { |
||
| 49 | /* USER CODE BEGIN MspInit 0 */ |
||
| 50 | |||
| 51 | /* USER CODE END MspInit 0 */ |
||
| 52 | |||
| 53 | __HAL_RCC_COMP_CLK_ENABLE(); |
||
| 54 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
||
| 55 | |||
| 56 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
||
| 57 | |||
| 58 | /* System interrupt init*/ |
||
| 59 | /* MemoryManagement_IRQn interrupt configuration */ |
||
| 60 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); |
||
| 61 | /* BusFault_IRQn interrupt configuration */ |
||
| 62 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); |
||
| 63 | /* UsageFault_IRQn interrupt configuration */ |
||
| 64 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); |
||
| 65 | /* SVC_IRQn interrupt configuration */ |
||
| 66 | HAL_NVIC_SetPriority(SVC_IRQn, 0, 0); |
||
| 67 | /* DebugMonitor_IRQn interrupt configuration */ |
||
| 68 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); |
||
| 69 | /* PendSV_IRQn interrupt configuration */ |
||
| 70 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); |
||
| 71 | /* SysTick_IRQn interrupt configuration */ |
||
| 72 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
||
| 73 | |||
| 74 | /* USER CODE BEGIN MspInit 1 */ |
||
| 75 | |||
| 76 | /* USER CODE END MspInit 1 */ |
||
| 77 | } |
||
| 78 | |||
| 79 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
||
| 80 | { |
||
| 81 | |||
| 82 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 83 | if(hadc->Instance==ADC1) |
||
| 84 | { |
||
| 85 | /* USER CODE BEGIN ADC1_MspInit 0 */ |
||
| 86 | |||
| 87 | /* USER CODE END ADC1_MspInit 0 */ |
||
| 88 | /* Peripheral clock enable */ |
||
| 89 | __HAL_RCC_ADC1_CLK_ENABLE(); |
||
| 90 | |||
| 91 | /**ADC GPIO Configuration |
||
| 6 | mjames | 92 | PC0 ------> ADC_IN10 |
| 93 | PC1 ------> ADC_IN11 |
||
| 94 | PC2 ------> ADC_IN12 |
||
| 95 | PC3 ------> ADC_IN13 |
||
| 2 | mjames | 96 | */ |
| 6 | mjames | 97 | GPIO_InitStruct.Pin = V_Batt1_Pin|V_Batt2_Pin|V_Oil_Pin|V_MAP_Pin; |
| 2 | mjames | 98 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
| 99 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 6 | mjames | 100 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
| 2 | mjames | 101 | |
| 6 | mjames | 102 | /* Peripheral DMA init*/ |
| 103 | |||
| 104 | hdma_adc.Instance = DMA1_Channel1; |
||
| 105 | hdma_adc.Init.Direction = DMA_PERIPH_TO_MEMORY; |
||
| 106 | hdma_adc.Init.PeriphInc = DMA_PINC_DISABLE; |
||
| 107 | hdma_adc.Init.MemInc = DMA_MINC_ENABLE; |
||
| 108 | hdma_adc.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; |
||
| 109 | hdma_adc.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; |
||
| 110 | hdma_adc.Init.Mode = DMA_NORMAL; |
||
| 111 | hdma_adc.Init.Priority = DMA_PRIORITY_LOW; |
||
| 112 | if (HAL_DMA_Init(&hdma_adc) != HAL_OK) |
||
| 113 | { |
||
| 114 | Error_Handler(); |
||
| 115 | } |
||
| 116 | |||
| 117 | __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc); |
||
| 118 | |||
| 2 | mjames | 119 | /* USER CODE BEGIN ADC1_MspInit 1 */ |
| 120 | |||
| 121 | /* USER CODE END ADC1_MspInit 1 */ |
||
| 122 | } |
||
| 123 | |||
| 124 | } |
||
| 125 | |||
| 126 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
||
| 127 | { |
||
| 128 | |||
| 129 | if(hadc->Instance==ADC1) |
||
| 130 | { |
||
| 131 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ |
||
| 132 | |||
| 133 | /* USER CODE END ADC1_MspDeInit 0 */ |
||
| 134 | /* Peripheral clock disable */ |
||
| 135 | __HAL_RCC_ADC1_CLK_DISABLE(); |
||
| 136 | |||
| 137 | /**ADC GPIO Configuration |
||
| 6 | mjames | 138 | PC0 ------> ADC_IN10 |
| 139 | PC1 ------> ADC_IN11 |
||
| 140 | PC2 ------> ADC_IN12 |
||
| 141 | PC3 ------> ADC_IN13 |
||
| 2 | mjames | 142 | */ |
| 6 | mjames | 143 | HAL_GPIO_DeInit(GPIOC, V_Batt1_Pin|V_Batt2_Pin|V_Oil_Pin|V_MAP_Pin); |
| 2 | mjames | 144 | |
| 6 | mjames | 145 | /* Peripheral DMA DeInit*/ |
| 146 | HAL_DMA_DeInit(hadc->DMA_Handle); |
||
| 2 | mjames | 147 | } |
| 148 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ |
||
| 149 | |||
| 150 | /* USER CODE END ADC1_MspDeInit 1 */ |
||
| 151 | |||
| 152 | } |
||
| 153 | |||
| 154 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
||
| 155 | { |
||
| 156 | |||
| 157 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 158 | if(hspi->Instance==SPI1) |
||
| 159 | { |
||
| 160 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
||
| 161 | |||
| 162 | /* USER CODE END SPI1_MspInit 0 */ |
||
| 163 | /* Peripheral clock enable */ |
||
| 164 | __HAL_RCC_SPI1_CLK_ENABLE(); |
||
| 165 | |||
| 166 | /**SPI1 GPIO Configuration |
||
| 167 | PA5 ------> SPI1_SCK |
||
| 3 | mjames | 168 | PA6 ------> SPI1_MISO |
| 2 | mjames | 169 | PA7 ------> SPI1_MOSI |
| 170 | */ |
||
| 3 | mjames | 171 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; |
| 2 | mjames | 172 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 173 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 174 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
| 175 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
||
| 176 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 177 | |||
| 178 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
| 179 | |||
| 180 | /* USER CODE END SPI1_MspInit 1 */ |
||
| 181 | } |
||
| 182 | |||
| 183 | } |
||
| 184 | |||
| 185 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
| 186 | { |
||
| 187 | |||
| 188 | if(hspi->Instance==SPI1) |
||
| 189 | { |
||
| 190 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
| 191 | |||
| 192 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
| 193 | /* Peripheral clock disable */ |
||
| 194 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
| 195 | |||
| 196 | /**SPI1 GPIO Configuration |
||
| 197 | PA5 ------> SPI1_SCK |
||
| 3 | mjames | 198 | PA6 ------> SPI1_MISO |
| 2 | mjames | 199 | PA7 ------> SPI1_MOSI |
| 200 | */ |
||
| 3 | mjames | 201 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); |
| 2 | mjames | 202 | |
| 203 | } |
||
| 204 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
| 205 | |||
| 206 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
| 207 | |||
| 208 | } |
||
| 209 | |||
| 210 | void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim_ic) |
||
| 211 | { |
||
| 212 | |||
| 213 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 214 | if(htim_ic->Instance==TIM2) |
||
| 215 | { |
||
| 216 | /* USER CODE BEGIN TIM2_MspInit 0 */ |
||
| 217 | |||
| 218 | /* USER CODE END TIM2_MspInit 0 */ |
||
| 219 | /* Peripheral clock enable */ |
||
| 220 | __HAL_RCC_TIM2_CLK_ENABLE(); |
||
| 221 | |||
| 222 | /**TIM2 GPIO Configuration |
||
| 223 | PA15 ------> TIM2_CH1 |
||
| 224 | PB3 ------> TIM2_CH2 |
||
| 225 | */ |
||
| 226 | GPIO_InitStruct.Pin = CB_Pulse_Pin; |
||
| 227 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 228 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 229 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 230 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 231 | HAL_GPIO_Init(CB_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
| 232 | |||
| 233 | GPIO_InitStruct.Pin = Timing_Pulse_Pin; |
||
| 234 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 235 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 236 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 237 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 238 | HAL_GPIO_Init(Timing_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
| 239 | |||
| 6 | mjames | 240 | /* Peripheral interrupt init */ |
| 241 | HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0); |
||
| 242 | HAL_NVIC_EnableIRQ(TIM2_IRQn); |
||
| 2 | mjames | 243 | /* USER CODE BEGIN TIM2_MspInit 1 */ |
| 244 | |||
| 245 | /* USER CODE END TIM2_MspInit 1 */ |
||
| 246 | } |
||
| 247 | |||
| 248 | } |
||
| 249 | |||
| 250 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) |
||
| 251 | { |
||
| 252 | |||
| 253 | if(htim_base->Instance==TIM6) |
||
| 254 | { |
||
| 255 | /* USER CODE BEGIN TIM6_MspInit 0 */ |
||
| 256 | |||
| 257 | /* USER CODE END TIM6_MspInit 0 */ |
||
| 258 | /* Peripheral clock enable */ |
||
| 259 | __HAL_RCC_TIM6_CLK_ENABLE(); |
||
| 7 | mjames | 260 | /* Peripheral interrupt init */ |
| 261 | HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0); |
||
| 262 | HAL_NVIC_EnableIRQ(TIM6_IRQn); |
||
| 2 | mjames | 263 | /* USER CODE BEGIN TIM6_MspInit 1 */ |
| 264 | |||
| 265 | /* USER CODE END TIM6_MspInit 1 */ |
||
| 266 | } |
||
| 267 | |||
| 268 | } |
||
| 269 | |||
| 270 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
||
| 271 | { |
||
| 272 | |||
| 273 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 274 | if(htim->Instance==TIM2) |
||
| 275 | { |
||
| 276 | /* USER CODE BEGIN TIM2_MspPostInit 0 */ |
||
| 277 | |||
| 278 | /* USER CODE END TIM2_MspPostInit 0 */ |
||
| 279 | |||
| 280 | /**TIM2 GPIO Configuration |
||
| 281 | PB10 ------> TIM2_CH3 |
||
| 282 | PB11 ------> TIM2_CH4 |
||
| 283 | */ |
||
| 284 | GPIO_InitStruct.Pin = CB_Drive_Pin|INJ_Drive_Pin; |
||
| 285 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 286 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 287 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 288 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 289 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||
| 290 | |||
| 291 | /* USER CODE BEGIN TIM2_MspPostInit 1 */ |
||
| 292 | |||
| 293 | /* USER CODE END TIM2_MspPostInit 1 */ |
||
| 294 | } |
||
| 295 | |||
| 296 | } |
||
| 297 | |||
| 298 | void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef* htim_ic) |
||
| 299 | { |
||
| 300 | |||
| 301 | if(htim_ic->Instance==TIM2) |
||
| 302 | { |
||
| 303 | /* USER CODE BEGIN TIM2_MspDeInit 0 */ |
||
| 304 | |||
| 305 | /* USER CODE END TIM2_MspDeInit 0 */ |
||
| 306 | /* Peripheral clock disable */ |
||
| 307 | __HAL_RCC_TIM2_CLK_DISABLE(); |
||
| 308 | |||
| 309 | /**TIM2 GPIO Configuration |
||
| 310 | PB10 ------> TIM2_CH3 |
||
| 311 | PB11 ------> TIM2_CH4 |
||
| 312 | PA15 ------> TIM2_CH1 |
||
| 313 | PB3 ------> TIM2_CH2 |
||
| 314 | */ |
||
| 315 | HAL_GPIO_DeInit(GPIOB, CB_Drive_Pin|INJ_Drive_Pin|Timing_Pulse_Pin); |
||
| 316 | |||
| 317 | HAL_GPIO_DeInit(CB_Pulse_GPIO_Port, CB_Pulse_Pin); |
||
| 318 | |||
| 6 | mjames | 319 | /* Peripheral interrupt DeInit*/ |
| 320 | HAL_NVIC_DisableIRQ(TIM2_IRQn); |
||
| 321 | |||
| 2 | mjames | 322 | } |
| 323 | /* USER CODE BEGIN TIM2_MspDeInit 1 */ |
||
| 324 | |||
| 325 | /* USER CODE END TIM2_MspDeInit 1 */ |
||
| 326 | |||
| 327 | } |
||
| 328 | |||
| 329 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) |
||
| 330 | { |
||
| 331 | |||
| 332 | if(htim_base->Instance==TIM6) |
||
| 333 | { |
||
| 334 | /* USER CODE BEGIN TIM6_MspDeInit 0 */ |
||
| 335 | |||
| 336 | /* USER CODE END TIM6_MspDeInit 0 */ |
||
| 337 | /* Peripheral clock disable */ |
||
| 338 | __HAL_RCC_TIM6_CLK_DISABLE(); |
||
| 7 | mjames | 339 | |
| 340 | /* Peripheral interrupt DeInit*/ |
||
| 341 | HAL_NVIC_DisableIRQ(TIM6_IRQn); |
||
| 342 | |||
| 2 | mjames | 343 | } |
| 344 | /* USER CODE BEGIN TIM6_MspDeInit 1 */ |
||
| 345 | |||
| 346 | /* USER CODE END TIM6_MspDeInit 1 */ |
||
| 347 | |||
| 348 | } |
||
| 349 | |||
| 350 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
||
| 351 | { |
||
| 352 | |||
| 353 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 354 | if(huart->Instance==USART1) |
||
| 355 | { |
||
| 356 | /* USER CODE BEGIN USART1_MspInit 0 */ |
||
| 357 | |||
| 358 | /* USER CODE END USART1_MspInit 0 */ |
||
| 359 | /* Peripheral clock enable */ |
||
| 360 | __HAL_RCC_USART1_CLK_ENABLE(); |
||
| 361 | |||
| 362 | /**USART1 GPIO Configuration |
||
| 363 | PA9 ------> USART1_TX |
||
| 364 | PA10 ------> USART1_RX |
||
| 365 | */ |
||
| 366 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; |
||
| 367 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 368 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
| 369 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
| 370 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
||
| 371 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 372 | |||
| 6 | mjames | 373 | /* Peripheral interrupt init */ |
| 374 | HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); |
||
| 375 | HAL_NVIC_EnableIRQ(USART1_IRQn); |
||
| 2 | mjames | 376 | /* USER CODE BEGIN USART1_MspInit 1 */ |
| 377 | |||
| 378 | /* USER CODE END USART1_MspInit 1 */ |
||
| 379 | } |
||
| 6 | mjames | 380 | else if(huart->Instance==USART2) |
| 381 | { |
||
| 382 | /* USER CODE BEGIN USART2_MspInit 0 */ |
||
| 2 | mjames | 383 | |
| 6 | mjames | 384 | /* USER CODE END USART2_MspInit 0 */ |
| 385 | /* Peripheral clock enable */ |
||
| 386 | __HAL_RCC_USART2_CLK_ENABLE(); |
||
| 387 | |||
| 388 | /**USART2 GPIO Configuration |
||
| 389 | PA2 ------> USART2_TX |
||
| 390 | PA3 ------> USART2_RX |
||
| 391 | */ |
||
| 392 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; |
||
| 393 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 394 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
| 395 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
| 396 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; |
||
| 397 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 398 | |||
| 399 | /* Peripheral interrupt init */ |
||
| 400 | HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); |
||
| 401 | HAL_NVIC_EnableIRQ(USART2_IRQn); |
||
| 402 | /* USER CODE BEGIN USART2_MspInit 1 */ |
||
| 403 | |||
| 404 | /* USER CODE END USART2_MspInit 1 */ |
||
| 405 | } |
||
| 406 | |||
| 2 | mjames | 407 | } |
| 408 | |||
| 409 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
||
| 410 | { |
||
| 411 | |||
| 412 | if(huart->Instance==USART1) |
||
| 413 | { |
||
| 414 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
||
| 415 | |||
| 416 | /* USER CODE END USART1_MspDeInit 0 */ |
||
| 417 | /* Peripheral clock disable */ |
||
| 418 | __HAL_RCC_USART1_CLK_DISABLE(); |
||
| 419 | |||
| 420 | /**USART1 GPIO Configuration |
||
| 421 | PA9 ------> USART1_TX |
||
| 422 | PA10 ------> USART1_RX |
||
| 423 | */ |
||
| 424 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); |
||
| 425 | |||
| 6 | mjames | 426 | /* Peripheral interrupt DeInit*/ |
| 427 | HAL_NVIC_DisableIRQ(USART1_IRQn); |
||
| 428 | |||
| 2 | mjames | 429 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
| 430 | |||
| 431 | /* USER CODE END USART1_MspDeInit 1 */ |
||
| 6 | mjames | 432 | } |
| 433 | else if(huart->Instance==USART2) |
||
| 434 | { |
||
| 435 | /* USER CODE BEGIN USART2_MspDeInit 0 */ |
||
| 2 | mjames | 436 | |
| 6 | mjames | 437 | /* USER CODE END USART2_MspDeInit 0 */ |
| 438 | /* Peripheral clock disable */ |
||
| 439 | __HAL_RCC_USART2_CLK_DISABLE(); |
||
| 440 | |||
| 441 | /**USART2 GPIO Configuration |
||
| 442 | PA2 ------> USART2_TX |
||
| 443 | PA3 ------> USART2_RX |
||
| 444 | */ |
||
| 445 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); |
||
| 446 | |||
| 447 | /* Peripheral interrupt DeInit*/ |
||
| 448 | HAL_NVIC_DisableIRQ(USART2_IRQn); |
||
| 449 | |||
| 450 | /* USER CODE BEGIN USART2_MspDeInit 1 */ |
||
| 451 | |||
| 452 | /* USER CODE END USART2_MspDeInit 1 */ |
||
| 453 | } |
||
| 454 | |||
| 2 | mjames | 455 | } |
| 456 | |||
| 457 | /* USER CODE BEGIN 1 */ |
||
| 458 | |||
| 459 | /* USER CODE END 1 */ |
||
| 460 | |||
| 461 | /** |
||
| 462 | * @} |
||
| 463 | */ |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @} |
||
| 467 | */ |
||
| 468 | |||
| 469 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |