Rev 49 | Rev 60 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 49 | Rev 50 | ||
|---|---|---|---|
| Line -... | Line 1... | ||
| - | 1 | /* USER CODE BEGIN Header */ |
|
| 1 | /** |
2 | /** |
| 2 | ****************************************************************************** |
3 | ****************************************************************************** |
| 3 | * File Name : stm32l1xx_hal_msp.c |
4 | * File Name : stm32l1xx_hal_msp.c |
| 4 | * Description : This file provides code for the MSP Initialization |
5 | * Description : This file provides code for the MSP Initialization |
| 5 | * and de-Initialization codes. |
6 | * and de-Initialization codes. |
| 6 | ****************************************************************************** |
7 | ****************************************************************************** |
| - | 8 | * @attention |
|
| 7 | * |
9 | * |
| 8 | * COPYRIGHT(c) 2018 STMicroelectronics |
10 | * <h2><center>© Copyright (c) 2020 STMicroelectronics. |
| - | 11 | * All rights reserved.</center></h2> |
|
| 9 | * |
12 | * |
| 10 | * Redistribution and use in source and binary forms, with or without modification, |
13 | * This software component is licensed by ST under BSD 3-Clause license, |
| 11 | * are permitted provided that the following conditions are met: |
14 | * the "License"; You may not use this file except in compliance with the |
| 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. |
15 | * License. You may obtain a copy of the License at: |
| 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 |
16 | * opensource.org/licenses/BSD-3-Clause |
| 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 | * |
17 | * |
| 32 | ****************************************************************************** |
18 | ****************************************************************************** |
| 33 | */ |
19 | */ |
| - | 20 | /* USER CODE END Header */ |
|
| - | 21 | ||
| 34 | /* Includes ------------------------------------------------------------------*/ |
22 | /* Includes ------------------------------------------------------------------*/ |
| 35 | #include "stm32l1xx_hal.h" |
23 | #include "main.h" |
| - | 24 | /* USER CODE BEGIN Includes */ |
|
| - | 25 | ||
| - | 26 | /* USER CODE END Includes */ |
|
| - | 27 | ||
| - | 28 | /* Private typedef -----------------------------------------------------------*/ |
|
| - | 29 | /* USER CODE BEGIN TD */ |
|
| - | 30 | ||
| - | 31 | /* USER CODE END TD */ |
|
| - | 32 | ||
| - | 33 | /* Private define ------------------------------------------------------------*/ |
|
| - | 34 | /* USER CODE BEGIN Define */ |
|
| - | 35 | ||
| - | 36 | /* USER CODE END Define */ |
|
| - | 37 | ||
| - | 38 | /* Private macro -------------------------------------------------------------*/ |
|
| - | 39 | /* USER CODE BEGIN Macro */ |
|
| - | 40 | ||
| - | 41 | /* USER CODE END Macro */ |
|
| - | 42 | ||
| - | 43 | /* Private variables ---------------------------------------------------------*/ |
|
| - | 44 | /* USER CODE BEGIN PV */ |
|
| - | 45 | ||
| - | 46 | /* USER CODE END PV */ |
|
| - | 47 | ||
| - | 48 | /* Private function prototypes -----------------------------------------------*/ |
|
| - | 49 | /* USER CODE BEGIN PFP */ |
|
| - | 50 | ||
| - | 51 | /* USER CODE END PFP */ |
|
| - | 52 | ||
| - | 53 | /* External functions --------------------------------------------------------*/ |
|
| - | 54 | /* USER CODE BEGIN ExternalFunctions */ |
|
| - | 55 | ||
| - | 56 | /* USER CODE END ExternalFunctions */ |
|
| 36 | 57 | ||
| 37 | extern void Error_Handler(void); |
- | |
| 38 | /* USER CODE BEGIN 0 */ |
58 | /* USER CODE BEGIN 0 */ |
| 39 | 59 | ||
| 40 | /* USER CODE END 0 */ |
60 | /* USER CODE END 0 */ |
| 41 | - | ||
| 42 | /** |
61 | /** |
| 43 | * Initializes the Global MSP. |
62 | * Initializes the Global MSP. |
| 44 | */ |
63 | */ |
| 45 | void HAL_MspInit(void) |
64 | void HAL_MspInit(void) |
| 46 | { |
65 | { |
| Line 48... | Line 67... | ||
| 48 | 67 | ||
| 49 | /* USER CODE END MspInit 0 */ |
68 | /* USER CODE END MspInit 0 */ |
| 50 | 69 | ||
| 51 | __HAL_RCC_COMP_CLK_ENABLE(); |
70 | __HAL_RCC_COMP_CLK_ENABLE(); |
| 52 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
| 53 | - | ||
| 54 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
72 | __HAL_RCC_PWR_CLK_ENABLE(); |
| 55 | 73 | ||
| 56 | /* System interrupt init*/ |
74 | /* 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 | 75 | ||
| 72 | /* USER CODE BEGIN MspInit 1 */ |
76 | /* USER CODE BEGIN MspInit 1 */ |
| 73 | 77 | ||
| 74 | /* USER CODE END MspInit 1 */ |
78 | /* USER CODE END MspInit 1 */ |
| 75 | } |
79 | } |
| 76 | 80 | ||
| - | 81 | /** |
|
| - | 82 | * @brief SPI MSP Initialization |
|
| - | 83 | * This function configures the hardware resources used in this example |
|
| - | 84 | * @param hspi: SPI handle pointer |
|
| - | 85 | * @retval None |
|
| - | 86 | */ |
|
| 77 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
87 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
| 78 | { |
88 | { |
| 79 | - | ||
| 80 | GPIO_InitTypeDef GPIO_InitStruct; |
89 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| 81 | if(hspi->Instance==SPI1) |
90 | if(hspi->Instance==SPI1) |
| 82 | { |
91 | { |
| 83 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
92 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
| 84 | 93 | ||
| 85 | /* USER CODE END SPI1_MspInit 0 */ |
94 | /* USER CODE END SPI1_MspInit 0 */ |
| 86 | /* Peripheral clock enable */ |
95 | /* Peripheral clock enable */ |
| 87 | __HAL_RCC_SPI1_CLK_ENABLE(); |
96 | __HAL_RCC_SPI1_CLK_ENABLE(); |
| 88 | 97 | ||
| - | 98 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
|
| 89 | /**SPI1 GPIO Configuration |
99 | /**SPI1 GPIO Configuration |
| 90 | PA5 ------> SPI1_SCK |
100 | PA5 ------> SPI1_SCK |
| 91 | PA7 ------> SPI1_MOSI |
101 | PA7 ------> SPI1_MOSI |
| 92 | */ |
102 | */ |
| 93 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; |
103 | GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MOSI_Pin; |
| 94 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
104 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 95 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
105 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 96 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
106 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
| 97 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
107 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; |
| 98 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
108 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| Line 102... | Line 112... | ||
| 102 | /* USER CODE END SPI1_MspInit 1 */ |
112 | /* USER CODE END SPI1_MspInit 1 */ |
| 103 | } |
113 | } |
| 104 | 114 | ||
| 105 | } |
115 | } |
| 106 | 116 | ||
| - | 117 | /** |
|
| - | 118 | * @brief SPI MSP De-Initialization |
|
| - | 119 | * This function freeze the hardware resources used in this example |
|
| - | 120 | * @param hspi: SPI handle pointer |
|
| - | 121 | * @retval None |
|
| - | 122 | */ |
|
| 107 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
123 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
| 108 | { |
124 | { |
| 109 | - | ||
| 110 | if(hspi->Instance==SPI1) |
125 | if(hspi->Instance==SPI1) |
| 111 | { |
126 | { |
| 112 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
127 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
| 113 | 128 | ||
| 114 | /* USER CODE END SPI1_MspDeInit 0 */ |
129 | /* USER CODE END SPI1_MspDeInit 0 */ |
| 115 | /* Peripheral clock disable */ |
130 | /* Peripheral clock disable */ |
| 116 | __HAL_RCC_SPI1_CLK_DISABLE(); |
131 | __HAL_RCC_SPI1_CLK_DISABLE(); |
| 117 | 132 | ||
| 118 | /**SPI1 GPIO Configuration |
133 | /**SPI1 GPIO Configuration |
| 119 | PA5 ------> SPI1_SCK |
134 | PA5 ------> SPI1_SCK |
| 120 | PA7 ------> SPI1_MOSI |
135 | PA7 ------> SPI1_MOSI |
| 121 | */ |
136 | */ |
| 122 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); |
137 | HAL_GPIO_DeInit(GPIOA, SPI_SCK_Pin|SPI_MOSI_Pin); |
| 123 | 138 | ||
| 124 | } |
- | |
| 125 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
139 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
| 126 | 140 | ||
| 127 | /* USER CODE END SPI1_MspDeInit 1 */ |
141 | /* USER CODE END SPI1_MspDeInit 1 */ |
| - | 142 | } |
|
| 128 | 143 | ||
| 129 | } |
144 | } |
| 130 | 145 | ||
| - | 146 | /** |
|
| - | 147 | * @brief TIM_Base MSP Initialization |
|
| - | 148 | * This function configures the hardware resources used in this example |
|
| - | 149 | * @param htim_base: TIM_Base handle pointer |
|
| - | 150 | * @retval None |
|
| - | 151 | */ |
|
| 131 | void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) |
152 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) |
| 132 | { |
153 | { |
| - | 154 | if(htim_base->Instance==TIM2) |
|
| - | 155 | { |
|
| - | 156 | /* USER CODE BEGIN TIM2_MspInit 0 */ |
|
| 133 | 157 | ||
| - | 158 | /* USER CODE END TIM2_MspInit 0 */ |
|
| - | 159 | /* Peripheral clock enable */ |
|
| - | 160 | __HAL_RCC_TIM2_CLK_ENABLE(); |
|
| - | 161 | /* USER CODE BEGIN TIM2_MspInit 1 */ |
|
| - | 162 | ||
| - | 163 | /* USER CODE END TIM2_MspInit 1 */ |
|
| - | 164 | } |
|
| - | 165 | ||
| - | 166 | } |
|
| - | 167 | ||
| - | 168 | /** |
|
| - | 169 | * @brief TIM_Encoder MSP Initialization |
|
| - | 170 | * This function configures the hardware resources used in this example |
|
| - | 171 | * @param htim_encoder: TIM_Encoder handle pointer |
|
| - | 172 | * @retval None |
|
| - | 173 | */ |
|
| - | 174 | void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) |
|
| - | 175 | { |
|
| 134 | GPIO_InitTypeDef GPIO_InitStruct; |
176 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| 135 | if(htim_encoder->Instance==TIM3) |
177 | if(htim_encoder->Instance==TIM3) |
| 136 | { |
178 | { |
| 137 | /* USER CODE BEGIN TIM3_MspInit 0 */ |
179 | /* USER CODE BEGIN TIM3_MspInit 0 */ |
| 138 | 180 | ||
| 139 | /* USER CODE END TIM3_MspInit 0 */ |
181 | /* USER CODE END TIM3_MspInit 0 */ |
| 140 | /* Peripheral clock enable */ |
182 | /* Peripheral clock enable */ |
| 141 | __HAL_RCC_TIM3_CLK_ENABLE(); |
183 | __HAL_RCC_TIM3_CLK_ENABLE(); |
| 142 | 184 | ||
| - | 185 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
|
| 143 | /**TIM3 GPIO Configuration |
186 | /**TIM3 GPIO Configuration |
| 144 | PC6 ------> TIM3_CH1 |
187 | PC6 ------> TIM3_CH1 |
| 145 | PC7 ------> TIM3_CH2 |
188 | PC7 ------> TIM3_CH2 |
| 146 | */ |
189 | */ |
| 147 | GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin; |
190 | GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin; |
| 148 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
191 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 149 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
192 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 150 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
193 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| Line 160... | Line 203... | ||
| 160 | /* USER CODE BEGIN TIM9_MspInit 0 */ |
203 | /* USER CODE BEGIN TIM9_MspInit 0 */ |
| 161 | 204 | ||
| 162 | /* USER CODE END TIM9_MspInit 0 */ |
205 | /* USER CODE END TIM9_MspInit 0 */ |
| 163 | /* Peripheral clock enable */ |
206 | /* Peripheral clock enable */ |
| 164 | __HAL_RCC_TIM9_CLK_ENABLE(); |
207 | __HAL_RCC_TIM9_CLK_ENABLE(); |
| 165 | 208 | ||
| - | 209 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
|
| 166 | /**TIM9 GPIO Configuration |
210 | /**TIM9 GPIO Configuration |
| 167 | PB13 ------> TIM9_CH1 |
211 | PB13 ------> TIM9_CH1 |
| 168 | PB14 ------> TIM9_CH2 |
212 | PB14 ------> TIM9_CH2 |
| 169 | */ |
213 | */ |
| 170 | GPIO_InitStruct.Pin = SW1_I_Pin|SW1_Q_Pin; |
214 | GPIO_InitStruct.Pin = SW1_I_Pin|SW1_Q_Pin; |
| 171 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
215 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 172 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
216 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 173 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
217 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| Line 179... | Line 223... | ||
| 179 | /* USER CODE END TIM9_MspInit 1 */ |
223 | /* USER CODE END TIM9_MspInit 1 */ |
| 180 | } |
224 | } |
| 181 | 225 | ||
| 182 | } |
226 | } |
| 183 | 227 | ||
| - | 228 | /** |
|
| - | 229 | * @brief TIM_Base MSP De-Initialization |
|
| - | 230 | * This function freeze the hardware resources used in this example |
|
| - | 231 | * @param htim_base: TIM_Base handle pointer |
|
| - | 232 | * @retval None |
|
| - | 233 | */ |
|
| 184 | void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) |
234 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) |
| 185 | { |
235 | { |
| - | 236 | if(htim_base->Instance==TIM2) |
|
| - | 237 | { |
|
| - | 238 | /* USER CODE BEGIN TIM2_MspDeInit 0 */ |
|
| - | 239 | ||
| - | 240 | /* USER CODE END TIM2_MspDeInit 0 */ |
|
| - | 241 | /* Peripheral clock disable */ |
|
| - | 242 | __HAL_RCC_TIM2_CLK_DISABLE(); |
|
| - | 243 | /* USER CODE BEGIN TIM2_MspDeInit 1 */ |
|
| - | 244 | ||
| - | 245 | /* USER CODE END TIM2_MspDeInit 1 */ |
|
| - | 246 | } |
|
| 186 | 247 | ||
| - | 248 | } |
|
| - | 249 | ||
| - | 250 | /** |
|
| - | 251 | * @brief TIM_Encoder MSP De-Initialization |
|
| - | 252 | * This function freeze the hardware resources used in this example |
|
| - | 253 | * @param htim_encoder: TIM_Encoder handle pointer |
|
| - | 254 | * @retval None |
|
| - | 255 | */ |
|
| - | 256 | void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) |
|
| - | 257 | { |
|
| 187 | if(htim_encoder->Instance==TIM3) |
258 | if(htim_encoder->Instance==TIM3) |
| 188 | { |
259 | { |
| 189 | /* USER CODE BEGIN TIM3_MspDeInit 0 */ |
260 | /* USER CODE BEGIN TIM3_MspDeInit 0 */ |
| 190 | 261 | ||
| 191 | /* USER CODE END TIM3_MspDeInit 0 */ |
262 | /* USER CODE END TIM3_MspDeInit 0 */ |
| 192 | /* Peripheral clock disable */ |
263 | /* Peripheral clock disable */ |
| 193 | __HAL_RCC_TIM3_CLK_DISABLE(); |
264 | __HAL_RCC_TIM3_CLK_DISABLE(); |
| 194 | 265 | ||
| 195 | /**TIM3 GPIO Configuration |
266 | /**TIM3 GPIO Configuration |
| 196 | PC6 ------> TIM3_CH1 |
267 | PC6 ------> TIM3_CH1 |
| 197 | PC7 ------> TIM3_CH2 |
268 | PC7 ------> TIM3_CH2 |
| 198 | */ |
269 | */ |
| 199 | HAL_GPIO_DeInit(GPIOC, SW2_I_Pin|SW2_Q_Pin); |
270 | HAL_GPIO_DeInit(GPIOC, SW2_I_Pin|SW2_Q_Pin); |
| 200 | 271 | ||
| 201 | /* USER CODE BEGIN TIM3_MspDeInit 1 */ |
272 | /* USER CODE BEGIN TIM3_MspDeInit 1 */ |
| 202 | 273 | ||
| Line 207... | Line 278... | ||
| 207 | /* USER CODE BEGIN TIM9_MspDeInit 0 */ |
278 | /* USER CODE BEGIN TIM9_MspDeInit 0 */ |
| 208 | 279 | ||
| 209 | /* USER CODE END TIM9_MspDeInit 0 */ |
280 | /* USER CODE END TIM9_MspDeInit 0 */ |
| 210 | /* Peripheral clock disable */ |
281 | /* Peripheral clock disable */ |
| 211 | __HAL_RCC_TIM9_CLK_DISABLE(); |
282 | __HAL_RCC_TIM9_CLK_DISABLE(); |
| 212 | 283 | ||
| 213 | /**TIM9 GPIO Configuration |
284 | /**TIM9 GPIO Configuration |
| 214 | PB13 ------> TIM9_CH1 |
285 | PB13 ------> TIM9_CH1 |
| 215 | PB14 ------> TIM9_CH2 |
286 | PB14 ------> TIM9_CH2 |
| 216 | */ |
287 | */ |
| 217 | HAL_GPIO_DeInit(GPIOB, SW1_I_Pin|SW1_Q_Pin); |
288 | HAL_GPIO_DeInit(GPIOB, SW1_I_Pin|SW1_Q_Pin); |
| 218 | 289 | ||
| 219 | /* USER CODE BEGIN TIM9_MspDeInit 1 */ |
290 | /* USER CODE BEGIN TIM9_MspDeInit 1 */ |
| 220 | 291 | ||
| 221 | /* USER CODE END TIM9_MspDeInit 1 */ |
292 | /* USER CODE END TIM9_MspDeInit 1 */ |
| 222 | } |
293 | } |
| 223 | 294 | ||
| 224 | } |
295 | } |
| 225 | 296 | ||
| - | 297 | /** |
|
| - | 298 | * @brief UART MSP Initialization |
|
| - | 299 | * This function configures the hardware resources used in this example |
|
| - | 300 | * @param huart: UART handle pointer |
|
| - | 301 | * @retval None |
|
| - | 302 | */ |
|
| 226 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
303 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
| 227 | { |
304 | { |
| 228 | - | ||
| 229 | GPIO_InitTypeDef GPIO_InitStruct; |
305 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| 230 | if(huart->Instance==USART1) |
306 | if(huart->Instance==USART1) |
| 231 | { |
307 | { |
| 232 | /* USER CODE BEGIN USART1_MspInit 0 */ |
308 | /* USER CODE BEGIN USART1_MspInit 0 */ |
| 233 | 309 | ||
| 234 | /* USER CODE END USART1_MspInit 0 */ |
310 | /* USER CODE END USART1_MspInit 0 */ |
| 235 | /* Peripheral clock enable */ |
311 | /* Peripheral clock enable */ |
| 236 | __HAL_RCC_USART1_CLK_ENABLE(); |
312 | __HAL_RCC_USART1_CLK_ENABLE(); |
| 237 | 313 | ||
| - | 314 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
|
| 238 | /**USART1 GPIO Configuration |
315 | /**USART1 GPIO Configuration |
| 239 | PA9 ------> USART1_TX |
316 | PA9 ------> USART1_TX |
| 240 | PA10 ------> USART1_RX |
317 | PA10 ------> USART1_RX |
| 241 | */ |
318 | */ |
| 242 | GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin; |
319 | GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin; |
| 243 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
320 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 244 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
321 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 245 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
322 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
| 246 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
323 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1; |
| 247 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
324 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| 248 | 325 | ||
| 249 | /* Peripheral interrupt init */ |
- | |
| 250 | HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); |
- | |
| 251 | HAL_NVIC_EnableIRQ(USART1_IRQn); |
- | |
| 252 | /* USER CODE BEGIN USART1_MspInit 1 */ |
326 | /* USER CODE BEGIN USART1_MspInit 1 */ |
| 253 | 327 | ||
| 254 | /* USER CODE END USART1_MspInit 1 */ |
328 | /* USER CODE END USART1_MspInit 1 */ |
| 255 | } |
329 | } |
| 256 | else if(huart->Instance==USART2) |
330 | else if(huart->Instance==USART2) |
| Line 258... | Line 332... | ||
| 258 | /* USER CODE BEGIN USART2_MspInit 0 */ |
332 | /* USER CODE BEGIN USART2_MspInit 0 */ |
| 259 | 333 | ||
| 260 | /* USER CODE END USART2_MspInit 0 */ |
334 | /* USER CODE END USART2_MspInit 0 */ |
| 261 | /* Peripheral clock enable */ |
335 | /* Peripheral clock enable */ |
| 262 | __HAL_RCC_USART2_CLK_ENABLE(); |
336 | __HAL_RCC_USART2_CLK_ENABLE(); |
| 263 | 337 | ||
| - | 338 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
|
| 264 | /**USART2 GPIO Configuration |
339 | /**USART2 GPIO Configuration |
| 265 | PA2 ------> USART2_TX |
340 | PA2 ------> USART2_TX |
| 266 | PA3 ------> USART2_RX |
341 | PA3 ------> USART2_RX |
| 267 | */ |
342 | */ |
| 268 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; |
343 | GPIO_InitStruct.Pin = GPIO_PIN_2; |
| - | 344 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
|
| - | 345 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
| - | 346 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
|
| - | 347 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; |
|
| - | 348 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
|
| - | 349 | ||
| - | 350 | GPIO_InitStruct.Pin = GPIO_PIN_3; |
|
| 269 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
351 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 270 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
352 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 271 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
353 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
| 272 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; |
354 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; |
| 273 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
355 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| 274 | 356 | ||
| 275 | /* Peripheral interrupt init */ |
- | |
| 276 | HAL_NVIC_SetPriority(USART2_IRQn, 0, 0); |
- | |
| 277 | HAL_NVIC_EnableIRQ(USART2_IRQn); |
- | |
| 278 | /* USER CODE BEGIN USART2_MspInit 1 */ |
357 | /* USER CODE BEGIN USART2_MspInit 1 */ |
| 279 | 358 | ||
| 280 | /* USER CODE END USART2_MspInit 1 */ |
359 | /* USER CODE END USART2_MspInit 1 */ |
| 281 | } |
360 | } |
| 282 | else if(huart->Instance==USART3) |
361 | else if(huart->Instance==USART3) |
| Line 284... | Line 363... | ||
| 284 | /* USER CODE BEGIN USART3_MspInit 0 */ |
363 | /* USER CODE BEGIN USART3_MspInit 0 */ |
| 285 | 364 | ||
| 286 | /* USER CODE END USART3_MspInit 0 */ |
365 | /* USER CODE END USART3_MspInit 0 */ |
| 287 | /* Peripheral clock enable */ |
366 | /* Peripheral clock enable */ |
| 288 | __HAL_RCC_USART3_CLK_ENABLE(); |
367 | __HAL_RCC_USART3_CLK_ENABLE(); |
| 289 | 368 | ||
| - | 369 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
|
| 290 | /**USART3 GPIO Configuration |
370 | /**USART3 GPIO Configuration |
| 291 | PB10 ------> USART3_TX |
371 | PB10 ------> USART3_TX |
| 292 | PB11 ------> USART3_RX |
372 | PB11 ------> USART3_RX |
| 293 | */ |
373 | */ |
| 294 | GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11; |
374 | GPIO_InitStruct.Pin = GPIO_PIN_10; |
| - | 375 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
|
| - | 376 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
| - | 377 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
|
| - | 378 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; |
|
| - | 379 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
|
| - | 380 | ||
| - | 381 | GPIO_InitStruct.Pin = GPIO_PIN_11; |
|
| 295 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
382 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| 296 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
383 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 297 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
384 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; |
| 298 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; |
385 | GPIO_InitStruct.Alternate = GPIO_AF7_USART3; |
| 299 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
386 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| 300 | 387 | ||
| 301 | /* Peripheral interrupt init */ |
- | |
| 302 | HAL_NVIC_SetPriority(USART3_IRQn, 0, 0); |
- | |
| 303 | HAL_NVIC_EnableIRQ(USART3_IRQn); |
- | |
| 304 | /* USER CODE BEGIN USART3_MspInit 1 */ |
388 | /* USER CODE BEGIN USART3_MspInit 1 */ |
| 305 | 389 | ||
| 306 | /* USER CODE END USART3_MspInit 1 */ |
390 | /* USER CODE END USART3_MspInit 1 */ |
| 307 | } |
391 | } |
| 308 | 392 | ||
| 309 | } |
393 | } |
| 310 | 394 | ||
| - | 395 | /** |
|
| - | 396 | * @brief UART MSP De-Initialization |
|
| - | 397 | * This function freeze the hardware resources used in this example |
|
| - | 398 | * @param huart: UART handle pointer |
|
| - | 399 | * @retval None |
|
| - | 400 | */ |
|
| 311 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
401 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
| 312 | { |
402 | { |
| 313 | - | ||
| 314 | if(huart->Instance==USART1) |
403 | if(huart->Instance==USART1) |
| 315 | { |
404 | { |
| 316 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
405 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
| 317 | 406 | ||
| 318 | /* USER CODE END USART1_MspDeInit 0 */ |
407 | /* USER CODE END USART1_MspDeInit 0 */ |
| 319 | /* Peripheral clock disable */ |
408 | /* Peripheral clock disable */ |
| 320 | __HAL_RCC_USART1_CLK_DISABLE(); |
409 | __HAL_RCC_USART1_CLK_DISABLE(); |
| 321 | 410 | ||
| 322 | /**USART1 GPIO Configuration |
411 | /**USART1 GPIO Configuration |
| 323 | PA9 ------> USART1_TX |
412 | PA9 ------> USART1_TX |
| 324 | PA10 ------> USART1_RX |
413 | PA10 ------> USART1_RX |
| 325 | */ |
414 | */ |
| 326 | HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin); |
415 | HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin); |
| 327 | 416 | ||
| 328 | /* Peripheral interrupt DeInit*/ |
- | |
| 329 | HAL_NVIC_DisableIRQ(USART1_IRQn); |
- | |
| 330 | - | ||
| 331 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
417 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
| 332 | 418 | ||
| 333 | /* USER CODE END USART1_MspDeInit 1 */ |
419 | /* USER CODE END USART1_MspDeInit 1 */ |
| 334 | } |
420 | } |
| 335 | else if(huart->Instance==USART2) |
421 | else if(huart->Instance==USART2) |
| Line 337... | Line 423... | ||
| 337 | /* USER CODE BEGIN USART2_MspDeInit 0 */ |
423 | /* USER CODE BEGIN USART2_MspDeInit 0 */ |
| 338 | 424 | ||
| 339 | /* USER CODE END USART2_MspDeInit 0 */ |
425 | /* USER CODE END USART2_MspDeInit 0 */ |
| 340 | /* Peripheral clock disable */ |
426 | /* Peripheral clock disable */ |
| 341 | __HAL_RCC_USART2_CLK_DISABLE(); |
427 | __HAL_RCC_USART2_CLK_DISABLE(); |
| 342 | 428 | ||
| 343 | /**USART2 GPIO Configuration |
429 | /**USART2 GPIO Configuration |
| 344 | PA2 ------> USART2_TX |
430 | PA2 ------> USART2_TX |
| 345 | PA3 ------> USART2_RX |
431 | PA3 ------> USART2_RX |
| 346 | */ |
432 | */ |
| 347 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); |
433 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); |
| 348 | 434 | ||
| 349 | /* Peripheral interrupt DeInit*/ |
- | |
| 350 | HAL_NVIC_DisableIRQ(USART2_IRQn); |
- | |
| 351 | - | ||
| 352 | /* USER CODE BEGIN USART2_MspDeInit 1 */ |
435 | /* USER CODE BEGIN USART2_MspDeInit 1 */ |
| 353 | 436 | ||
| 354 | /* USER CODE END USART2_MspDeInit 1 */ |
437 | /* USER CODE END USART2_MspDeInit 1 */ |
| 355 | } |
438 | } |
| 356 | else if(huart->Instance==USART3) |
439 | else if(huart->Instance==USART3) |
| Line 358... | Line 441... | ||
| 358 | /* USER CODE BEGIN USART3_MspDeInit 0 */ |
441 | /* USER CODE BEGIN USART3_MspDeInit 0 */ |
| 359 | 442 | ||
| 360 | /* USER CODE END USART3_MspDeInit 0 */ |
443 | /* USER CODE END USART3_MspDeInit 0 */ |
| 361 | /* Peripheral clock disable */ |
444 | /* Peripheral clock disable */ |
| 362 | __HAL_RCC_USART3_CLK_DISABLE(); |
445 | __HAL_RCC_USART3_CLK_DISABLE(); |
| 363 | 446 | ||
| 364 | /**USART3 GPIO Configuration |
447 | /**USART3 GPIO Configuration |
| 365 | PB10 ------> USART3_TX |
448 | PB10 ------> USART3_TX |
| 366 | PB11 ------> USART3_RX |
449 | PB11 ------> USART3_RX |
| 367 | */ |
450 | */ |
| 368 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); |
451 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); |
| 369 | 452 | ||
| 370 | /* Peripheral interrupt DeInit*/ |
- | |
| 371 | HAL_NVIC_DisableIRQ(USART3_IRQn); |
- | |
| 372 | - | ||
| 373 | /* USER CODE BEGIN USART3_MspDeInit 1 */ |
453 | /* USER CODE BEGIN USART3_MspDeInit 1 */ |
| 374 | 454 | ||
| 375 | /* USER CODE END USART3_MspDeInit 1 */ |
455 | /* USER CODE END USART3_MspDeInit 1 */ |
| 376 | } |
456 | } |
| 377 | 457 | ||
| Line 379... | Line 459... | ||
| 379 | 459 | ||
| 380 | /* USER CODE BEGIN 1 */ |
460 | /* USER CODE BEGIN 1 */ |
| 381 | 461 | ||
| 382 | /* USER CODE END 1 */ |
462 | /* USER CODE END 1 */ |
| 383 | 463 | ||
| 384 | /** |
- | |
| 385 | * @} |
- | |
| 386 | */ |
- | |
| 387 | - | ||
| 388 | /** |
- | |
| 389 | * @} |
- | |
| 390 | */ |
- | |
| 391 | - | ||
| 392 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
464 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |