Rev 4 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /* USER CODE BEGIN Header */ |
| 2 | /** |
||
| 3 | ****************************************************************************** |
||
| 4 | * @file stm32f1xx_hal_msp.c |
||
| 5 | * @brief This file provides code for the MSP Initialization |
||
| 6 | * and de-Initialization codes. |
||
| 7 | ****************************************************************************** |
||
| 8 | * @attention |
||
| 9 | * |
||
| 10 | * Copyright (c) 2022 STMicroelectronics. |
||
| 11 | * All rights reserved. |
||
| 12 | * |
||
| 13 | * This software is licensed under terms that can be found in the LICENSE file |
||
| 14 | * in the root directory of this software component. |
||
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS. |
||
| 16 | * |
||
| 17 | ****************************************************************************** |
||
| 18 | */ |
||
| 19 | /* USER CODE END Header */ |
||
| 20 | |||
| 21 | /* Includes ------------------------------------------------------------------*/ |
||
| 22 | #include "main.h" |
||
| 23 | /* USER CODE BEGIN Includes */ |
||
| 24 | |||
| 25 | /* USER CODE END Includes */ |
||
| 26 | |||
| 27 | /* Private typedef -----------------------------------------------------------*/ |
||
| 28 | /* USER CODE BEGIN TD */ |
||
| 29 | |||
| 30 | /* USER CODE END TD */ |
||
| 31 | |||
| 32 | /* Private define ------------------------------------------------------------*/ |
||
| 33 | /* USER CODE BEGIN Define */ |
||
| 34 | |||
| 35 | /* USER CODE END Define */ |
||
| 36 | |||
| 37 | /* Private macro -------------------------------------------------------------*/ |
||
| 38 | /* USER CODE BEGIN Macro */ |
||
| 39 | |||
| 40 | /* USER CODE END Macro */ |
||
| 41 | |||
| 42 | /* Private variables ---------------------------------------------------------*/ |
||
| 43 | /* USER CODE BEGIN PV */ |
||
| 44 | |||
| 45 | /* USER CODE END PV */ |
||
| 46 | |||
| 47 | /* Private function prototypes -----------------------------------------------*/ |
||
| 48 | /* USER CODE BEGIN PFP */ |
||
| 49 | |||
| 50 | /* USER CODE END PFP */ |
||
| 51 | |||
| 52 | /* External functions --------------------------------------------------------*/ |
||
| 53 | /* USER CODE BEGIN ExternalFunctions */ |
||
| 54 | |||
| 55 | /* USER CODE END ExternalFunctions */ |
||
| 56 | |||
| 57 | /* USER CODE BEGIN 0 */ |
||
| 58 | |||
| 59 | /* USER CODE END 0 */ |
||
| 60 | /** |
||
| 61 | * Initializes the Global MSP. |
||
| 62 | */ |
||
| 63 | void HAL_MspInit(void) |
||
| 64 | { |
||
| 65 | /* USER CODE BEGIN MspInit 0 */ |
||
| 66 | |||
| 67 | /* USER CODE END MspInit 0 */ |
||
| 68 | |||
| 69 | __HAL_RCC_AFIO_CLK_ENABLE(); |
||
| 70 | __HAL_RCC_PWR_CLK_ENABLE(); |
||
| 71 | |||
| 72 | /* System interrupt init*/ |
||
| 73 | |||
| 74 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled |
||
| 75 | */ |
||
| 76 | __HAL_AFIO_REMAP_SWJ_NOJTAG(); |
||
| 77 | |||
| 78 | /* USER CODE BEGIN MspInit 1 */ |
||
| 79 | |||
| 80 | /* USER CODE END MspInit 1 */ |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 4 | mjames | 84 | * @brief I2C MSP Initialization |
| 85 | * This function configures the hardware resources used in this example |
||
| 86 | * @param hi2c: I2C handle pointer |
||
| 87 | * @retval None |
||
| 88 | */ |
||
| 89 | void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) |
||
| 90 | { |
||
| 91 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
||
| 92 | if(hi2c->Instance==I2C1) |
||
| 93 | { |
||
| 94 | /* USER CODE BEGIN I2C1_MspInit 0 */ |
||
| 95 | |||
| 96 | /* USER CODE END I2C1_MspInit 0 */ |
||
| 97 | |||
| 98 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
||
| 99 | /**I2C1 GPIO Configuration |
||
| 100 | PB6 ------> I2C1_SCL |
||
| 101 | PB7 ------> I2C1_SDA |
||
| 102 | */ |
||
| 103 | GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; |
||
| 104 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; |
||
| 8 | mjames | 105 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 4 | mjames | 106 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| 107 | |||
| 108 | /* Peripheral clock enable */ |
||
| 109 | __HAL_RCC_I2C1_CLK_ENABLE(); |
||
| 110 | /* USER CODE BEGIN I2C1_MspInit 1 */ |
||
| 111 | |||
| 112 | /* USER CODE END I2C1_MspInit 1 */ |
||
| 113 | } |
||
| 114 | |||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @brief I2C MSP De-Initialization |
||
| 119 | * This function freeze the hardware resources used in this example |
||
| 120 | * @param hi2c: I2C handle pointer |
||
| 121 | * @retval None |
||
| 122 | */ |
||
| 123 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) |
||
| 124 | { |
||
| 125 | if(hi2c->Instance==I2C1) |
||
| 126 | { |
||
| 127 | /* USER CODE BEGIN I2C1_MspDeInit 0 */ |
||
| 128 | |||
| 129 | /* USER CODE END I2C1_MspDeInit 0 */ |
||
| 130 | /* Peripheral clock disable */ |
||
| 131 | __HAL_RCC_I2C1_CLK_DISABLE(); |
||
| 132 | |||
| 133 | /**I2C1 GPIO Configuration |
||
| 134 | PB6 ------> I2C1_SCL |
||
| 135 | PB7 ------> I2C1_SDA |
||
| 136 | */ |
||
| 137 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6); |
||
| 138 | |||
| 139 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7); |
||
| 140 | |||
| 141 | /* USER CODE BEGIN I2C1_MspDeInit 1 */ |
||
| 142 | |||
| 143 | /* USER CODE END I2C1_MspDeInit 1 */ |
||
| 144 | } |
||
| 145 | |||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 2 | mjames | 149 | * @brief SPI MSP Initialization |
| 150 | * This function configures the hardware resources used in this example |
||
| 151 | * @param hspi: SPI handle pointer |
||
| 152 | * @retval None |
||
| 153 | */ |
||
| 154 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) |
||
| 155 | { |
||
| 156 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
||
| 157 | if(hspi->Instance==SPI1) |
||
| 158 | { |
||
| 159 | /* USER CODE BEGIN SPI1_MspInit 0 */ |
||
| 160 | |||
| 161 | /* USER CODE END SPI1_MspInit 0 */ |
||
| 162 | /* Peripheral clock enable */ |
||
| 163 | __HAL_RCC_SPI1_CLK_ENABLE(); |
||
| 164 | |||
| 165 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
||
| 166 | /**SPI1 GPIO Configuration |
||
| 167 | PA5 ------> SPI1_SCK |
||
| 168 | PA7 ------> SPI1_MOSI |
||
| 169 | */ |
||
| 170 | GPIO_InitStruct.Pin = SPI_CLK_Pin|SPI_MOSI_Pin; |
||
| 171 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
||
| 172 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; |
||
| 173 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
||
| 174 | |||
| 175 | /* USER CODE BEGIN SPI1_MspInit 1 */ |
||
| 176 | |||
| 177 | /* USER CODE END SPI1_MspInit 1 */ |
||
| 178 | } |
||
| 179 | |||
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @brief SPI MSP De-Initialization |
||
| 184 | * This function freeze the hardware resources used in this example |
||
| 185 | * @param hspi: SPI handle pointer |
||
| 186 | * @retval None |
||
| 187 | */ |
||
| 188 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) |
||
| 189 | { |
||
| 190 | if(hspi->Instance==SPI1) |
||
| 191 | { |
||
| 192 | /* USER CODE BEGIN SPI1_MspDeInit 0 */ |
||
| 193 | |||
| 194 | /* USER CODE END SPI1_MspDeInit 0 */ |
||
| 195 | /* Peripheral clock disable */ |
||
| 196 | __HAL_RCC_SPI1_CLK_DISABLE(); |
||
| 197 | |||
| 198 | /**SPI1 GPIO Configuration |
||
| 199 | PA5 ------> SPI1_SCK |
||
| 200 | PA7 ------> SPI1_MOSI |
||
| 201 | */ |
||
| 202 | HAL_GPIO_DeInit(GPIOA, SPI_CLK_Pin|SPI_MOSI_Pin); |
||
| 203 | |||
| 204 | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
||
| 205 | |||
| 206 | /* USER CODE END SPI1_MspDeInit 1 */ |
||
| 207 | } |
||
| 208 | |||
| 209 | } |
||
| 210 | |||
| 211 | /* USER CODE BEGIN 1 */ |
||
| 212 | |||
| 213 | /* USER CODE END 1 */ |