Rev 33 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
30 | 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) 2017 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_SPI_MspInit(SPI_HandleTypeDef* hspi) |
||
78 | { |
||
79 | |||
80 | GPIO_InitTypeDef GPIO_InitStruct; |
||
81 | if(hspi->Instance==SPI1) |
||
82 | { |
||
83 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
||
84 | |||
85 | /* USER CODE END SPI1_MspInit 0 */ |
||
86 | /* Peripheral clock enable */ |
||
87 | __HAL_RCC_SPI1_CLK_ENABLE(); |
||
88 | |||
89 | /**SPI1 GPIO Configuration |
||
90 | PA5 ------> SPI1_SCK |
||
91 | PA7 ------> SPI1_MOSI |
||
92 | */ |
||
93 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; |
||
94 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
95 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
96 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
97 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
||
98 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
99 | |||
100 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
101 | |||
102 | /* USER CODE END SPI1_MspInit 1 */ |
||
103 | } |
||
104 | |||
105 | } |
||
106 | |||
107 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
108 | { |
||
109 | |||
110 | if(hspi->Instance==SPI1) |
||
111 | { |
||
112 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
113 | |||
114 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
115 | /* Peripheral clock disable */ |
||
116 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
117 | |||
118 | /**SPI1 GPIO Configuration |
||
119 | PA5 ------> SPI1_SCK |
||
120 | PA7 ------> SPI1_MOSI |
||
121 | */ |
||
122 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); |
||
123 | |||
124 | } |
||
125 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
126 | |||
127 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
128 | |||
129 | } |
||
130 | |||
131 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
||
132 | { |
||
133 | |||
134 | GPIO_InitTypeDef GPIO_InitStruct; |
||
135 | if(huart->Instance==USART1) |
||
136 | { |
||
137 | /* USER CODE BEGIN USART1_MspInit 0 */ |
||
138 | |||
139 | /* USER CODE END USART1_MspInit 0 */ |
||
140 | /* Peripheral clock enable */ |
||
141 | __HAL_RCC_USART1_CLK_ENABLE(); |
||
142 | |||
143 | /**USART1 GPIO Configuration |
||
144 | PA9 ------> USART1_TX |
||
145 | PA10 ------> USART1_RX |
||
146 | */ |
||
147 | GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin; |
||
148 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
149 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
150 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
151 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
||
152 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
153 | |||
154 | /* USER CODE BEGIN USART1_MspInit 1 */ |
||
155 | |||
156 | /* USER CODE END USART1_MspInit 1 */ |
||
157 | } |
||
158 | else if(huart->Instance==USART2) |
||
159 | { |
||
160 | /* USER CODE BEGIN USART2_MspInit 0 */ |
||
161 | |||
162 | /* USER CODE END USART2_MspInit 0 */ |
||
163 | /* Peripheral clock enable */ |
||
164 | __HAL_RCC_USART2_CLK_ENABLE(); |
||
165 | |||
166 | /**USART2 GPIO Configuration |
||
167 | PA2 ------> USART2_TX |
||
168 | PA3 ------> USART2_RX |
||
169 | */ |
||
170 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; |
||
171 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
172 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
173 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
174 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; |
||
175 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
176 | |||
177 | /* USER CODE BEGIN USART2_MspInit 1 */ |
||
178 | |||
179 | /* USER CODE END USART2_MspInit 1 */ |
||
180 | } |
||
181 | else if(huart->Instance==USART3) |
||
182 | { |
||
183 | /* USER CODE BEGIN USART3_MspInit 0 */ |
||
184 | |||
185 | /* USER CODE END USART3_MspInit 0 */ |
||
186 | /* Peripheral clock enable */ |
||
187 | __HAL_RCC_USART3_CLK_ENABLE(); |
||
188 | |||
189 | /**USART3 GPIO Configuration |
||
190 | PB10 ------> USART3_TX |
||
191 | PB11 ------> USART3_RX |
||
192 | */ |
||
193 | GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11; |
||
194 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
195 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
||
196 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
||
197 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; |
||
198 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
||
199 | |||
200 | /* USER CODE BEGIN USART3_MspInit 1 */ |
||
201 | |||
202 | /* USER CODE END USART3_MspInit 1 */ |
||
203 | } |
||
204 | |||
205 | } |
||
206 | |||
207 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
||
208 | { |
||
209 | |||
210 | if(huart->Instance==USART1) |
||
211 | { |
||
212 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
||
213 | |||
214 | /* USER CODE END USART1_MspDeInit 0 */ |
||
215 | /* Peripheral clock disable */ |
||
216 | __HAL_RCC_USART1_CLK_DISABLE(); |
||
217 | |||
218 | /**USART1 GPIO Configuration |
||
219 | PA9 ------> USART1_TX |
||
220 | PA10 ------> USART1_RX |
||
221 | */ |
||
222 | HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin); |
||
223 | |||
224 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
||
225 | |||
226 | /* USER CODE END USART1_MspDeInit 1 */ |
||
227 | } |
||
228 | else if(huart->Instance==USART2) |
||
229 | { |
||
230 | /* USER CODE BEGIN USART2_MspDeInit 0 */ |
||
231 | |||
232 | /* USER CODE END USART2_MspDeInit 0 */ |
||
233 | /* Peripheral clock disable */ |
||
234 | __HAL_RCC_USART2_CLK_DISABLE(); |
||
235 | |||
236 | /**USART2 GPIO Configuration |
||
237 | PA2 ------> USART2_TX |
||
238 | PA3 ------> USART2_RX |
||
239 | */ |
||
240 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); |
||
241 | |||
242 | /* USER CODE BEGIN USART2_MspDeInit 1 */ |
||
243 | |||
244 | /* USER CODE END USART2_MspDeInit 1 */ |
||
245 | } |
||
246 | else if(huart->Instance==USART3) |
||
247 | { |
||
248 | /* USER CODE BEGIN USART3_MspDeInit 0 */ |
||
249 | |||
250 | /* USER CODE END USART3_MspDeInit 0 */ |
||
251 | /* Peripheral clock disable */ |
||
252 | __HAL_RCC_USART3_CLK_DISABLE(); |
||
253 | |||
254 | /**USART3 GPIO Configuration |
||
255 | PB10 ------> USART3_TX |
||
256 | PB11 ------> USART3_RX |
||
257 | */ |
||
258 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); |
||
259 | |||
260 | /* USER CODE BEGIN USART3_MspDeInit 1 */ |
||
261 | |||
262 | /* USER CODE END USART3_MspDeInit 1 */ |
||
263 | } |
||
264 | |||
265 | } |
||
266 | |||
267 | /* USER CODE BEGIN 1 */ |
||
268 | |||
269 | /* USER CODE END 1 */ |
||
270 | |||
271 | /** |
||
272 | * @} |
||
273 | */ |
||
274 | |||
275 | /** |
||
276 | * @} |
||
277 | */ |
||
278 | |||
279 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |