Rev 3 | Rev 7 | 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 : stm32f1xx_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 "stm32f1xx_hal.h" |
||
| 36 | |||
| 5 | mjames | 37 | extern void Error_Handler(void); |
| 2 | mjames | 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_AFIO_CLK_ENABLE(); |
||
| 52 | |||
| 53 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
||
| 54 | |||
| 55 | /* System interrupt init*/ |
||
| 56 | /* MemoryManagement_IRQn interrupt configuration */ |
||
| 57 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); |
||
| 58 | /* BusFault_IRQn interrupt configuration */ |
||
| 59 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); |
||
| 60 | /* UsageFault_IRQn interrupt configuration */ |
||
| 61 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); |
||
| 5 | mjames | 62 | /* SVCall_IRQn interrupt configuration */ |
| 63 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); |
||
| 2 | mjames | 64 | /* DebugMonitor_IRQn interrupt configuration */ |
| 65 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); |
||
| 5 | mjames | 66 | /* PendSV_IRQn interrupt configuration */ |
| 67 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); |
||
| 2 | mjames | 68 | /* SysTick_IRQn interrupt configuration */ |
| 69 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); |
||
| 70 | |||
| 71 | /**NOJTAG: JTAG-DP Disabled and SW-DP Enabled |
||
| 72 | */ |
||
| 73 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); |
||
| 74 | |||
| 75 | /* USER CODE BEGIN MspInit 1 */ |
||
| 76 | |||
| 77 | /* USER CODE END MspInit 1 */ |
||
| 78 | } |
||
| 79 | |||
| 80 | void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
||
| 81 | { |
||
| 82 | |||
| 83 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 84 | if(hadc->Instance==ADC1) |
||
| 85 | { |
||
| 86 | /* USER CODE BEGIN ADC1_MspInit 0 */ |
||
| 87 | |||
| 88 | /* USER CODE END ADC1_MspInit 0 */ |
||
| 89 | /* Peripheral clock enable */ |
||
| 90 | __HAL_RCC_ADC1_CLK_ENABLE(); |
||
| 91 | |||
| 92 | /**ADC1 GPIO Configuration |
||
| 93 | PA0-WKUP ------> ADC1_IN0 |
||
| 94 | */ |
||
| 95 | GPIO_InitStruct.Pin = GPIO_PIN_0; |
||
| 96 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
||
| 97 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 98 | |||
| 99 | /* USER CODE BEGIN ADC1_MspInit 1 */ |
||
| 100 | |||
| 101 | /* USER CODE END ADC1_MspInit 1 */ |
||
| 102 | } |
||
| 103 | |||
| 104 | } |
||
| 105 | |||
| 106 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
||
| 107 | { |
||
| 108 | |||
| 109 | if(hadc->Instance==ADC1) |
||
| 110 | { |
||
| 111 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ |
||
| 112 | |||
| 113 | /* USER CODE END ADC1_MspDeInit 0 */ |
||
| 114 | /* Peripheral clock disable */ |
||
| 115 | __HAL_RCC_ADC1_CLK_DISABLE(); |
||
| 116 | |||
| 117 | /**ADC1 GPIO Configuration |
||
| 118 | PA0-WKUP ------> ADC1_IN0 |
||
| 119 | */ |
||
| 120 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0); |
||
| 121 | |||
| 122 | } |
||
| 123 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ |
||
| 124 | |||
| 125 | /* USER CODE END ADC1_MspDeInit 1 */ |
||
| 126 | |||
| 127 | } |
||
| 128 | |||
| 129 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
||
| 130 | { |
||
| 131 | |||
| 132 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 133 | if(hspi->Instance==SPI1) |
||
| 134 | { |
||
| 135 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
||
| 136 | |||
| 137 | /* USER CODE END SPI1_MspInit 0 */ |
||
| 138 | /* Peripheral clock enable */ |
||
| 139 | __HAL_RCC_SPI1_CLK_ENABLE(); |
||
| 140 | |||
| 141 | /**SPI1 GPIO Configuration |
||
| 142 | PA5 ------> SPI1_SCK |
||
| 143 | PA7 ------> SPI1_MOSI |
||
| 144 | */ |
||
| 145 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7; |
||
| 146 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 147 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; |
||
| 148 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 149 | |||
| 150 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
| 151 | |||
| 152 | /* USER CODE END SPI1_MspInit 1 */ |
||
| 153 | } |
||
| 154 | |||
| 155 | } |
||
| 156 | |||
| 157 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
| 158 | { |
||
| 159 | |||
| 160 | if(hspi->Instance==SPI1) |
||
| 161 | { |
||
| 162 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
| 163 | |||
| 164 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
| 165 | /* Peripheral clock disable */ |
||
| 166 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
| 167 | |||
| 168 | /**SPI1 GPIO Configuration |
||
| 169 | PA5 ------> SPI1_SCK |
||
| 170 | PA7 ------> SPI1_MOSI |
||
| 171 | */ |
||
| 172 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7); |
||
| 173 | |||
| 174 | } |
||
| 175 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
| 176 | |||
| 177 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
| 178 | |||
| 179 | } |
||
| 180 | |||
| 181 | void HAL_UART_MspInit(UART_HandleTypeDef* huart) |
||
| 182 | { |
||
| 183 | |||
| 184 | GPIO_InitTypeDef GPIO_InitStruct; |
||
| 3 | mjames | 185 | if(huart->Instance==USART1) |
| 2 | mjames | 186 | { |
| 3 | mjames | 187 | /* USER CODE BEGIN USART1_MspInit 0 */ |
| 188 | |||
| 189 | /* USER CODE END USART1_MspInit 0 */ |
||
| 190 | /* Peripheral clock enable */ |
||
| 191 | __HAL_RCC_USART1_CLK_ENABLE(); |
||
| 192 | |||
| 193 | /**USART1 GPIO Configuration |
||
| 194 | PA9 ------> USART1_TX |
||
| 195 | PA10 ------> USART1_RX |
||
| 196 | */ |
||
| 197 | GPIO_InitStruct.Pin = PLX_TX_Pin; |
||
| 198 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 199 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; |
||
| 200 | HAL_GPIO_Init(PLX_TX_GPIO_Port, &GPIO_InitStruct); |
||
| 201 | |||
| 202 | GPIO_InitStruct.Pin = PLX_RX_Pin; |
||
| 203 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
||
| 204 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 205 | HAL_GPIO_Init(PLX_RX_GPIO_Port, &GPIO_InitStruct); |
||
| 206 | |||
| 207 | /* USER CODE BEGIN USART1_MspInit 1 */ |
||
| 208 | |||
| 209 | /* USER CODE END USART1_MspInit 1 */ |
||
| 210 | } |
||
| 211 | else if(huart->Instance==USART2) |
||
| 212 | { |
||
| 2 | mjames | 213 | /* USER CODE BEGIN USART2_MspInit 0 */ |
| 214 | |||
| 215 | /* USER CODE END USART2_MspInit 0 */ |
||
| 216 | /* Peripheral clock enable */ |
||
| 217 | __HAL_RCC_USART2_CLK_ENABLE(); |
||
| 218 | |||
| 219 | /**USART2 GPIO Configuration |
||
| 220 | PA2 ------> USART2_TX |
||
| 221 | PA3 ------> USART2_RX |
||
| 222 | */ |
||
| 223 | GPIO_InitStruct.Pin = GPIO_PIN_2; |
||
| 224 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 5 | mjames | 225 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; |
| 2 | mjames | 226 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| 227 | |||
| 228 | GPIO_InitStruct.Pin = GPIO_PIN_3; |
||
| 229 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
||
| 230 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
||
| 231 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 232 | |||
| 233 | /* Peripheral interrupt init */ |
||
| 234 | HAL_NVIC_SetPriority(USART2_IRQn, 2, 0); |
||
| 235 | HAL_NVIC_EnableIRQ(USART2_IRQn); |
||
| 236 | /* USER CODE BEGIN USART2_MspInit 1 */ |
||
| 237 | |||
| 238 | /* USER CODE END USART2_MspInit 1 */ |
||
| 239 | } |
||
| 240 | |||
| 241 | } |
||
| 242 | |||
| 3 | mjames | 243 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) |
| 2 | mjames | 244 | { |
| 245 | |||
| 3 | mjames | 246 | if(huart->Instance==USART1) |
| 2 | mjames | 247 | { |
| 3 | mjames | 248 | /* USER CODE BEGIN USART1_MspDeInit 0 */ |
| 2 | mjames | 249 | |
| 3 | mjames | 250 | /* USER CODE END USART1_MspDeInit 0 */ |
| 251 | /* Peripheral clock disable */ |
||
| 252 | __HAL_RCC_USART1_CLK_DISABLE(); |
||
| 2 | mjames | 253 | |
| 3 | mjames | 254 | /**USART1 GPIO Configuration |
| 255 | PA9 ------> USART1_TX |
||
| 256 | PA10 ------> USART1_RX |
||
| 2 | mjames | 257 | */ |
| 3 | mjames | 258 | HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin); |
| 2 | mjames | 259 | |
| 3 | mjames | 260 | /* USER CODE BEGIN USART1_MspDeInit 1 */ |
| 2 | mjames | 261 | |
| 3 | mjames | 262 | /* USER CODE END USART1_MspDeInit 1 */ |
| 2 | mjames | 263 | } |
| 3 | mjames | 264 | else if(huart->Instance==USART2) |
| 2 | mjames | 265 | { |
| 266 | /* USER CODE BEGIN USART2_MspDeInit 0 */ |
||
| 267 | |||
| 268 | /* USER CODE END USART2_MspDeInit 0 */ |
||
| 269 | /* Peripheral clock disable */ |
||
| 270 | __HAL_RCC_USART2_CLK_DISABLE(); |
||
| 271 | |||
| 272 | /**USART2 GPIO Configuration |
||
| 273 | PA2 ------> USART2_TX |
||
| 274 | PA3 ------> USART2_RX |
||
| 275 | */ |
||
| 276 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); |
||
| 277 | |||
| 278 | /* Peripheral interrupt DeInit*/ |
||
| 279 | HAL_NVIC_DisableIRQ(USART2_IRQn); |
||
| 280 | |||
| 281 | /* USER CODE BEGIN USART2_MspDeInit 1 */ |
||
| 282 | |||
| 283 | /* USER CODE END USART2_MspDeInit 1 */ |
||
| 284 | } |
||
| 285 | |||
| 286 | } |
||
| 287 | |||
| 288 | /* USER CODE BEGIN 1 */ |
||
| 289 | |||
| 290 | /* USER CODE END 1 */ |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @} |
||
| 294 | */ |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @} |
||
| 298 | */ |
||
| 299 | |||
| 300 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |