F439_CPP_MPL3115A2_Project_01 1.0
STM32F439 MPL3115A2 pressure and temperature tutorial
Loading...
Searching...
No Matches
stm32f4xx_hal_msp.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
19/* USER CODE END Header */
20
21/* Includes ------------------------------------------------------------------*/
22#include "main.h"
23/* USER CODE BEGIN Includes */
24#include <stdio.h>
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 */
63void HAL_MspInit(void)
64{
65
66 /* USER CODE BEGIN MspInit 0 */
67
68 /* USER CODE END MspInit 0 */
69
70 __HAL_RCC_SYSCFG_CLK_ENABLE();
71 __HAL_RCC_PWR_CLK_ENABLE();
72
73 /* System interrupt init*/
74
75 /* USER CODE BEGIN MspInit 1 */
76
77 /* USER CODE END MspInit 1 */
78}
79
86void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
87{
88 GPIO_InitTypeDef GPIO_InitStruct = {0};
89 if(hi2c->Instance==I2C1)
90 {
91 /* USER CODE BEGIN I2C1_MspInit 0 */
92
93 /* USER CODE END I2C1_MspInit 0 */
94
95 __HAL_RCC_GPIOB_CLK_ENABLE();
100 GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
101 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
102 GPIO_InitStruct.Pull = GPIO_NOPULL;
103 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
104 GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
105 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
106
107 /* Peripheral clock enable */
108 __HAL_RCC_I2C1_CLK_ENABLE();
109 /* USER CODE BEGIN I2C1_MspInit 1 */
110
111 /* USER CODE END I2C1_MspInit 1 */
112
113 }
114
115}
116
123void 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
137 HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
138
139 HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
140
141 /* USER CODE BEGIN I2C1_MspDeInit 1 */
142
143 /* USER CODE END I2C1_MspDeInit 1 */
144 }
145
146}
147
154void HAL_UART_MspInit(UART_HandleTypeDef* huart)
155{
156 GPIO_InitTypeDef GPIO_InitStruct = {0};
157 if(huart->Instance==USART1)
158 {
159 /* USER CODE BEGIN USART1_MspInit 0 */
160
161 /* USER CODE END USART1_MspInit 0 */
162 /* Peripheral clock enable */
163 __HAL_RCC_USART1_CLK_ENABLE();
164
165 __HAL_RCC_GPIOA_CLK_ENABLE();
170 GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
171 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
172 GPIO_InitStruct.Pull = GPIO_NOPULL;
173 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
174 GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
175 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
176
177 /* USER CODE BEGIN USART1_MspInit 1 */
178
179 /* USER CODE END USART1_MspInit 1 */
180
181 }
182
183}
184
191void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
192{
193 if(huart->Instance==USART1)
194 {
195 /* USER CODE BEGIN USART1_MspDeInit 0 */
196
197 /* USER CODE END USART1_MspDeInit 0 */
198 /* Peripheral clock disable */
199 __HAL_RCC_USART1_CLK_DISABLE();
200
205 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
206
207 /* USER CODE BEGIN USART1_MspDeInit 1 */
208
209 /* USER CODE END USART1_MspDeInit 1 */
210 }
211
212}
213
214/* USER CODE BEGIN 1 */
215
216/* USER CODE END 1 */
: Common application definitions for the MPL3115A2 tutorial.
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
I2C MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
UART MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
I2C MSP Initialization This function configures the hardware resources used in this example.
void HAL_MspInit(void)