Rev 3 | Go to most recent revision | Details | 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 |
||
147 | PA7 ------> SPI1_MOSI |
||
148 | */ |
||
149 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; |
||
150 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
151 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
152 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
153 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
||
154 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
155 | |||
156 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
157 | |||
158 | /* USER CODE END SPI1_MspInit 1 */ |
||
159 | } |
||
160 | |||
161 | } |
||
162 | |||
163 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
164 | { |
||
165 | |||
166 | if(hspi->Instance==SPI1) |
||
167 | { |
||
168 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
169 | |||
170 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
171 | /* Peripheral clock disable */ |
||
172 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
173 | |||
174 | /**SPI1 GPIO Configuration |
||
175 | PA5 ------> SPI1_SCK |
||
176 | PA7 ------> SPI1_MOSI |
||
177 | */ |
||
178 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); |
||
179 | |||
180 | } |
||
181 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
182 | |||
183 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
184 | |||
185 | } |
||
186 | |||
187 | void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim_ic) |
||
188 | { |
||
189 | |||
190 | GPIO_InitTypeDef GPIO_InitStruct; |
||
191 | if(htim_ic->Instance==TIM2) |
||
192 | { |
||
193 | /* USER CODE BEGIN TIM2_MspInit 0 */ |
||
194 | |||
195 | /* USER CODE END TIM2_MspInit 0 */ |
||
196 | /* Peripheral clock enable */ |
||
197 | __HAL_RCC_TIM2_CLK_ENABLE(); |
||
198 | |||
199 | /**TIM2 GPIO Configuration |
||
200 | PA15 ------> TIM2_CH1 |
||
201 | PB3 ------> TIM2_CH2 |
||
202 | */ |
||
203 | GPIO_InitStruct.Pin = CB_Pulse_Pin; |
||
204 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
205 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
206 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
207 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
208 | HAL_GPIO_Init(CB_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
209 | |||
210 | GPIO_InitStruct.Pin = Timing_Pulse_Pin; |
||
211 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
212 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
213 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
214 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
215 | HAL_GPIO_Init(Timing_Pulse_GPIO_Port, &GPIO_InitStruct); |
||
216 | |||
217 | /* USER CODE BEGIN TIM2_MspInit 1 */ |
||
218 | |||
219 | /* USER CODE END TIM2_MspInit 1 */ |
||
220 | } |
||
221 | |||
222 | } |
||
223 | |||
224 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) |
||
225 | { |
||
226 | |||
227 | if(htim_base->Instance==TIM6) |
||
228 | { |
||
229 | /* USER CODE BEGIN TIM6_MspInit 0 */ |
||
230 | |||
231 | /* USER CODE END TIM6_MspInit 0 */ |
||
232 | /* Peripheral clock enable */ |
||
233 | __HAL_RCC_TIM6_CLK_ENABLE(); |
||
234 | /* USER CODE BEGIN TIM6_MspInit 1 */ |
||
235 | |||
236 | /* USER CODE END TIM6_MspInit 1 */ |
||
237 | } |
||
238 | |||
239 | } |
||
240 | |||
241 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
||
242 | { |
||
243 | |||
244 | GPIO_InitTypeDef GPIO_InitStruct; |
||
245 | if(htim->Instance==TIM2) |
||
246 | { |
||
247 | /* USER CODE BEGIN TIM2_MspPostInit 0 */ |
||
248 | |||
249 | /* USER CODE END TIM2_MspPostInit 0 */ |
||
250 | |||
251 | /**TIM2 GPIO Configuration |
||
252 | PB10 ------> TIM2_CH3 |
||
253 | PB11 ------> TIM2_CH4 |
||
254 | */ |
||
255 | GPIO_InitStruct.Pin = CB_Drive_Pin|INJ_Drive_Pin; |
||
256 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
257 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
258 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
||
259 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; |
||
260 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||
261 | |||
262 | /* USER CODE BEGIN TIM2_MspPostInit 1 */ |
||
263 | |||
264 | /* USER CODE END TIM2_MspPostInit 1 */ |
||
265 | } |
||
266 | |||
267 | } |
||
268 | |||
269 | void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef* htim_ic) |
||
270 | { |
||
271 | |||
272 | if(htim_ic->Instance==TIM2) |
||
273 | { |
||
274 | /* USER CODE BEGIN TIM2_MspDeInit 0 */ |
||
275 | |||
276 | /* USER CODE END TIM2_MspDeInit 0 */ |
||
277 | /* Peripheral clock disable */ |
||
278 | __HAL_RCC_TIM2_CLK_DISABLE(); |
||
279 | |||
280 | /**TIM2 GPIO Configuration |
||
281 | PB10 ------> TIM2_CH3 |
||
282 | PB11 ------> TIM2_CH4 |
||
283 | PA15 ------> TIM2_CH1 |
||
284 | PB3 ------> TIM2_CH2 |
||
285 | */ |
||
286 | HAL_GPIO_DeInit(GPIOB, CB_Drive_Pin|INJ_Drive_Pin|Timing_Pulse_Pin); |
||
287 | |||
288 | HAL_GPIO_DeInit(CB_Pulse_GPIO_Port, CB_Pulse_Pin); |
||
289 | |||
290 | } |
||
291 | /* USER CODE BEGIN TIM2_MspDeInit 1 */ |
||
292 | |||
293 | /* USER CODE END TIM2_MspDeInit 1 */ |
||
294 | |||
295 | } |
||
296 | |||
297 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) |
||
298 | { |
||
299 | |||
300 | if(htim_base->Instance==TIM6) |
||
301 | { |
||
302 | /* USER CODE BEGIN TIM6_MspDeInit 0 */ |
||
303 | |||
304 | /* USER CODE END TIM6_MspDeInit 0 */ |
||
305 | /* Peripheral clock disable */ |
||
306 | __HAL_RCC_TIM6_CLK_DISABLE(); |
||
307 | } |
||
308 | /* USER CODE BEGIN TIM6_MspDeInit 1 */ |
||
309 | |||
310 | /* USER CODE END TIM6_MspDeInit 1 */ |
||
311 | |||
312 | } |
||
313 | |||
314 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
||
315 | { |
||
316 | |||
317 | GPIO_InitTypeDef GPIO_InitStruct; |
||
318 | if(huart->Instance==USART1) |
||
319 | { |
||
320 | /* USER CODE BEGIN USART1_MspInit 0 */ |
||
321 | |||
322 | /* USER CODE END USART1_MspInit 0 */ |
||
323 | /* Peripheral clock enable */ |
||
324 | __HAL_RCC_USART1_CLK_ENABLE(); |
||
325 | |||
326 | /**USART1 GPIO Configuration |
||
327 | PA9 ------> USART1_TX |
||
328 | PA10 ------> USART1_RX |
||
329 | */ |
||
330 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; |
||
331 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
332 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
333 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
334 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
||
335 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
336 | |||
337 | /* USER CODE BEGIN USART1_MspInit 1 */ |
||
338 | |||
339 | /* USER CODE END USART1_MspInit 1 */ |
||
340 | } |
||
341 | |||
342 | } |
||
343 | |||
344 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
||
345 | { |
||
346 | |||
347 | if(huart->Instance==USART1) |
||
348 | { |
||
349 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
||
350 | |||
351 | /* USER CODE END USART1_MspDeInit 0 */ |
||
352 | /* Peripheral clock disable */ |
||
353 | __HAL_RCC_USART1_CLK_DISABLE(); |
||
354 | |||
355 | /**USART1 GPIO Configuration |
||
356 | PA9 ------> USART1_TX |
||
357 | PA10 ------> USART1_RX |
||
358 | */ |
||
359 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); |
||
360 | |||
361 | } |
||
362 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
||
363 | |||
364 | /* USER CODE END USART1_MspDeInit 1 */ |
||
365 | |||
366 | } |
||
367 | |||
368 | /* USER CODE BEGIN 1 */ |
||
369 | |||
370 | /* USER CODE END 1 */ |
||
371 | |||
372 | /** |
||
373 | * @} |
||
374 | */ |
||
375 | |||
376 | /** |
||
377 | * @} |
||
378 | */ |
||
379 | |||
380 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |