Rev 2 | Rev 6 | 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 | |||
| 37 | extern void Error_Handler(void); |
||
| 38 | /* USER CODE BEGIN 0 */ |
||
| 39 | |||
| 40 | /* USER CODE END 0 */ |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Initializes the Global MSP. |
||
| 44 | */ |
||
| 45 | void HAL_MspInit(void) |
||
| 46 | { |
||
| 47 | /* USER CODE BEGIN MspInit 0 */ |
||
| 48 | |||
| 49 | /* USER CODE END MspInit 0 */ |
||
| 50 | |||
| 51 | __HAL_RCC_COMP_CLK_ENABLE(); |
||
| 52 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
||
| 53 | |||
| 54 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
||
| 55 | |||
| 56 | /* System interrupt init*/ |
||
| 57 | /* MemoryManagement_IRQn interrupt configuration */ |
||
| 58 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); |
||
| 59 | /* BusFault_IRQn interrupt configuration */ |
||
| 60 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); |
||
| 61 | /* UsageFault_IRQn interrupt configuration */ |
||
| 62 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); |
||
| 63 | /* SVC_IRQn interrupt configuration */ |
||
| 64 | HAL_NVIC_SetPriority(SVC_IRQn, 0, 0); |
||
| 65 | /* DebugMonitor_IRQn interrupt configuration */ |
||
| 66 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); |
||
| 67 | /* PendSV_IRQn interrupt configuration */ |
||
| 68 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); |
||
| 69 | /* SysTick_IRQn interrupt configuration */ |
||
| 70 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
||
| 71 | |||
| 72 | /* USER CODE BEGIN MspInit 1 */ |
||
| 73 | |||
| 74 | /* USER CODE END MspInit 1 */ |
||
| 75 | } |
||
| 76 | |||
| 77 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
||
| 78 | { |
||
| 79 | |||
| 80 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 81 | if(hadc->Instance==ADC1) |
||
| 82 | { |
||
| 83 | /* USER CODE BEGIN ADC1_MspInit 0 */ |
||
| 84 | |||
| 85 | /* USER CODE END ADC1_MspInit 0 */ |
||
| 86 | /* Peripheral clock enable */ |
||
| 87 | __HAL_RCC_ADC1_CLK_ENABLE(); |
||
| 88 | |||
| 89 | /**ADC GPIO Configuration |
||
| 90 | PA0-WKUP1 ------> ADC_IN0 |
||
| 91 | PA1 ------> ADC_IN1 |
||
| 92 | PA2 ------> ADC_IN2 |
||
| 93 | PA3 ------> ADC_IN3 |
||
| 94 | */ |
||
| 95 | GPIO_InitStruct.Pin = VBatt_1_Pin|VBatt_2_Pin|VMAP_Pin|VOil_Pin; |
||
| 96 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||
| 97 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 98 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 99 | |||
| 100 | /* USER CODE BEGIN ADC1_MspInit 1 */ |
||
| 101 | |||
| 102 | /* USER CODE END ADC1_MspInit 1 */ |
||
| 103 | } |
||
| 104 | |||
| 105 | } |
||
| 106 | |||
| 107 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
||
| 108 | { |
||
| 109 | |||
| 110 | if(hadc->Instance==ADC1) |
||
| 111 | { |
||
| 112 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ |
||
| 113 | |||
| 114 | /* USER CODE END ADC1_MspDeInit 0 */ |
||
| 115 | /* Peripheral clock disable */ |
||
| 116 | __HAL_RCC_ADC1_CLK_DISABLE(); |
||
| 117 | |||
| 118 | /**ADC GPIO Configuration |
||
| 119 | PA0-WKUP1 ------> ADC_IN0 |
||
| 120 | PA1 ------> ADC_IN1 |
||
| 121 | PA2 ------> ADC_IN2 |
||
| 122 | PA3 ------> ADC_IN3 |
||
| 123 | */ |
||
| 124 | HAL_GPIO_DeInit(GPIOA, VBatt_1_Pin|VBatt_2_Pin|VMAP_Pin|VOil_Pin); |
||
| 125 | |||
| 126 | } |
||
| 127 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ |
||
| 128 | |||
| 129 | /* USER CODE END ADC1_MspDeInit 1 */ |
||
| 130 | |||
| 131 | } |
||
| 132 | |||
| 133 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
||
| 134 | { |
||
| 135 | |||
| 136 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 137 | if(hspi->Instance==SPI1) |
||
| 138 | { |
||
| 139 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
||
| 140 | |||
| 141 | /* USER CODE END SPI1_MspInit 0 */ |
||
| 142 | /* Peripheral clock enable */ |
||
| 143 | __HAL_RCC_SPI1_CLK_ENABLE(); |
||
| 144 | |||
| 145 | /**SPI1 GPIO Configuration |
||
| 146 | PA5 ------> SPI1_SCK |
||
| 3 | mjames | 147 | PA6 ------> SPI1_MISO |
| 2 | mjames | 148 | PA7 ------> SPI1_MOSI |
| 149 | */ |
||
| 3 | mjames | 150 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; |
| 2 | mjames | 151 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 152 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 153 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
| 154 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
||
| 155 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 156 | |||
| 157 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
| 158 | |||
| 159 | /* USER CODE END SPI1_MspInit 1 */ |
||
| 160 | } |
||
| 161 | |||
| 162 | } |
||
| 163 | |||
| 164 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
| 165 | { |
||
| 166 | |||
| 167 | if(hspi->Instance==SPI1) |
||
| 168 | { |
||
| 169 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
| 170 | |||
| 171 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
| 172 | /* Peripheral clock disable */ |
||
| 173 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
| 174 | |||
| 175 | /**SPI1 GPIO Configuration |
||
| 176 | PA5 ------> SPI1_SCK |
||
| 3 | mjames | 177 | PA6 ------> SPI1_MISO |
| 2 | mjames | 178 | PA7 ------> SPI1_MOSI |
| 179 | */ |
||
| 3 | mjames | 180 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); |
| 2 | mjames | 181 | |
| 182 | } |
||
| 183 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
| 184 | |||
| 185 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
| 186 | |||
| 187 | } |
||
| 188 | |||
| 189 | void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim_ic) |
||
| 190 | { |
||
| 191 | |||
| 192 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 193 | if(htim_ic->Instance==TIM2) |
||
| 194 | { |
||
| 195 | /* USER CODE BEGIN TIM2_MspInit 0 */ |
||
| 196 | |||
| 197 | /* USER CODE END TIM2_MspInit 0 */ |
||
| 198 | /* Peripheral clock enable */ |
||
| 199 | __HAL_RCC_TIM2_CLK_ENABLE(); |
||
| 200 | |||
| 201 | /**TIM2 GPIO Configuration |
||
| 202 | PA15 ------> TIM2_CH1 |
||
| 203 | PB3 ------> TIM2_CH2 |
||
| 204 | */ |
||
| 205 | GPIO_InitStruct.Pin = CB_Pulse_Pin; |
||
| 206 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 207 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 208 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 209 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 210 | HAL_GPIO_Init(CB_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
| 211 | |||
| 212 | GPIO_InitStruct.Pin = Timing_Pulse_Pin; |
||
| 213 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 214 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 215 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 216 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 217 | HAL_GPIO_Init(Timing_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
| 218 | |||
| 219 | /* USER CODE BEGIN TIM2_MspInit 1 */ |
||
| 220 | |||
| 221 | /* USER CODE END TIM2_MspInit 1 */ |
||
| 222 | } |
||
| 223 | |||
| 224 | } |
||
| 225 | |||
| 226 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) |
||
| 227 | { |
||
| 228 | |||
| 229 | if(htim_base->Instance==TIM6) |
||
| 230 | { |
||
| 231 | /* USER CODE BEGIN TIM6_MspInit 0 */ |
||
| 232 | |||
| 233 | /* USER CODE END TIM6_MspInit 0 */ |
||
| 234 | /* Peripheral clock enable */ |
||
| 235 | __HAL_RCC_TIM6_CLK_ENABLE(); |
||
| 236 | /* USER CODE BEGIN TIM6_MspInit 1 */ |
||
| 237 | |||
| 238 | /* USER CODE END TIM6_MspInit 1 */ |
||
| 239 | } |
||
| 240 | |||
| 241 | } |
||
| 242 | |||
| 243 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
||
| 244 | { |
||
| 245 | |||
| 246 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 247 | if(htim->Instance==TIM2) |
||
| 248 | { |
||
| 249 | /* USER CODE BEGIN TIM2_MspPostInit 0 */ |
||
| 250 | |||
| 251 | /* USER CODE END TIM2_MspPostInit 0 */ |
||
| 252 | |||
| 253 | /**TIM2 GPIO Configuration |
||
| 254 | PB10 ------> TIM2_CH3 |
||
| 255 | PB11 ------> TIM2_CH4 |
||
| 256 | */ |
||
| 257 | GPIO_InitStruct.Pin = CB_Drive_Pin|INJ_Drive_Pin; |
||
| 258 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 259 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 260 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
| 261 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
| 262 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||
| 263 | |||
| 264 | /* USER CODE BEGIN TIM2_MspPostInit 1 */ |
||
| 265 | |||
| 266 | /* USER CODE END TIM2_MspPostInit 1 */ |
||
| 267 | } |
||
| 268 | |||
| 269 | } |
||
| 270 | |||
| 271 | void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef* htim_ic) |
||
| 272 | { |
||
| 273 | |||
| 274 | if(htim_ic->Instance==TIM2) |
||
| 275 | { |
||
| 276 | /* USER CODE BEGIN TIM2_MspDeInit 0 */ |
||
| 277 | |||
| 278 | /* USER CODE END TIM2_MspDeInit 0 */ |
||
| 279 | /* Peripheral clock disable */ |
||
| 280 | __HAL_RCC_TIM2_CLK_DISABLE(); |
||
| 281 | |||
| 282 | /**TIM2 GPIO Configuration |
||
| 283 | PB10 ------> TIM2_CH3 |
||
| 284 | PB11 ------> TIM2_CH4 |
||
| 285 | PA15 ------> TIM2_CH1 |
||
| 286 | PB3 ------> TIM2_CH2 |
||
| 287 | */ |
||
| 288 | HAL_GPIO_DeInit(GPIOB, CB_Drive_Pin|INJ_Drive_Pin|Timing_Pulse_Pin); |
||
| 289 | |||
| 290 | HAL_GPIO_DeInit(CB_Pulse_GPIO_Port, CB_Pulse_Pin); |
||
| 291 | |||
| 292 | } |
||
| 293 | /* USER CODE BEGIN TIM2_MspDeInit 1 */ |
||
| 294 | |||
| 295 | /* USER CODE END TIM2_MspDeInit 1 */ |
||
| 296 | |||
| 297 | } |
||
| 298 | |||
| 299 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) |
||
| 300 | { |
||
| 301 | |||
| 302 | if(htim_base->Instance==TIM6) |
||
| 303 | { |
||
| 304 | /* USER CODE BEGIN TIM6_MspDeInit 0 */ |
||
| 305 | |||
| 306 | /* USER CODE END TIM6_MspDeInit 0 */ |
||
| 307 | /* Peripheral clock disable */ |
||
| 308 | __HAL_RCC_TIM6_CLK_DISABLE(); |
||
| 309 | } |
||
| 310 | /* USER CODE BEGIN TIM6_MspDeInit 1 */ |
||
| 311 | |||
| 312 | /* USER CODE END TIM6_MspDeInit 1 */ |
||
| 313 | |||
| 314 | } |
||
| 315 | |||
| 316 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
||
| 317 | { |
||
| 318 | |||
| 319 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 320 | if(huart->Instance==USART1) |
||
| 321 | { |
||
| 322 | /* USER CODE BEGIN USART1_MspInit 0 */ |
||
| 323 | |||
| 324 | /* USER CODE END USART1_MspInit 0 */ |
||
| 325 | /* Peripheral clock enable */ |
||
| 326 | __HAL_RCC_USART1_CLK_ENABLE(); |
||
| 327 | |||
| 328 | /**USART1 GPIO Configuration |
||
| 329 | PA9 ------> USART1_TX |
||
| 330 | PA10 ------> USART1_RX |
||
| 331 | */ |
||
| 332 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; |
||
| 333 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 334 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
| 335 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
| 336 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
||
| 337 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 338 | |||
| 339 | /* USER CODE BEGIN USART1_MspInit 1 */ |
||
| 340 | |||
| 341 | /* USER CODE END USART1_MspInit 1 */ |
||
| 342 | } |
||
| 343 | |||
| 344 | } |
||
| 345 | |||
| 346 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
||
| 347 | { |
||
| 348 | |||
| 349 | if(huart->Instance==USART1) |
||
| 350 | { |
||
| 351 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
||
| 352 | |||
| 353 | /* USER CODE END USART1_MspDeInit 0 */ |
||
| 354 | /* Peripheral clock disable */ |
||
| 355 | __HAL_RCC_USART1_CLK_DISABLE(); |
||
| 356 | |||
| 357 | /**USART1 GPIO Configuration |
||
| 358 | PA9 ------> USART1_TX |
||
| 359 | PA10 ------> USART1_RX |
||
| 360 | */ |
||
| 361 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); |
||
| 362 | |||
| 363 | } |
||
| 364 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
||
| 365 | |||
| 366 | /* USER CODE END USART1_MspDeInit 1 */ |
||
| 367 | |||
| 368 | } |
||
| 369 | |||
| 370 | /* USER CODE BEGIN 1 */ |
||
| 371 | |||
| 372 | /* USER CODE END 1 */ |
||
| 373 | |||
| 374 | /** |
||
| 375 | * @} |
||
| 376 | */ |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @} |
||
| 380 | */ |
||
| 381 | |||
| 382 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |