Subversion Repositories dashGPS

Rev

Rev 11 | 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 Name          : stm32f1xx_hal_msp.c
5
  * Description        : This file provides code for the MSP Initialization
6
  *                      and de-Initialization codes.
7
  ******************************************************************************
8
  * @attention
9
  *
10
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
11
  * All rights reserved.</center></h2>
12
  *
13
  * This software component is licensed by ST under BSD 3-Clause license,
14
  * the "License"; You may not use this file except in compliance with the
15
  * License. You may obtain a copy of the License at:
16
  *                        opensource.org/licenses/BSD-3-Clause
17
  *
18
  ******************************************************************************
19
  */
20
/* USER CODE END Header */
21
 
22
/* Includes ------------------------------------------------------------------*/
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 */
57
 
58
/* USER CODE BEGIN 0 */
59
 
60
/* USER CODE END 0 */
61
/**
62
  * Initializes the Global MSP.
63
  */
64
void HAL_MspInit(void)
65
{
66
  /* USER CODE BEGIN MspInit 0 */
67
 
68
  /* USER CODE END MspInit 0 */
69
 
70
  __HAL_RCC_AFIO_CLK_ENABLE();
71
  __HAL_RCC_PWR_CLK_ENABLE();
72
 
73
  /* System interrupt init*/
74
 
75
  /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
76
  */
77
  __HAL_AFIO_REMAP_SWJ_NOJTAG();
78
 
79
  /* USER CODE BEGIN MspInit 1 */
80
 
81
  /* USER CODE END MspInit 1 */
82
}
83
 
84
/**
11 mjames 85
* @brief I2C MSP Initialization
86
* This function configures the hardware resources used in this example
87
* @param hi2c: I2C handle pointer
88
* @retval None
89
*/
90
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
91
{
92
  GPIO_InitTypeDef GPIO_InitStruct = {0};
93
  if(hi2c->Instance==I2C2)
94
  {
95
  /* USER CODE BEGIN I2C2_MspInit 0 */
96
 
97
  /* USER CODE END I2C2_MspInit 0 */
98
 
99
    __HAL_RCC_GPIOB_CLK_ENABLE();
100
    /**I2C2 GPIO Configuration
101
    PB10     ------> I2C2_SCL
102
    PB11     ------> I2C2_SDA
103
    */
104
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
105
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
106
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
107
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
108
 
109
    /* Peripheral clock enable */
110
    __HAL_RCC_I2C2_CLK_ENABLE();
111
  /* USER CODE BEGIN I2C2_MspInit 1 */
112
 
113
  /* USER CODE END I2C2_MspInit 1 */
114
  }
115
 
116
}
117
 
118
/**
119
* @brief I2C MSP De-Initialization
120
* This function freeze the hardware resources used in this example
121
* @param hi2c: I2C handle pointer
122
* @retval None
123
*/
124
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
125
{
126
  if(hi2c->Instance==I2C2)
127
  {
128
  /* USER CODE BEGIN I2C2_MspDeInit 0 */
129
 
130
  /* USER CODE END I2C2_MspDeInit 0 */
131
    /* Peripheral clock disable */
132
    __HAL_RCC_I2C2_CLK_DISABLE();
133
 
134
    /**I2C2 GPIO Configuration
135
    PB10     ------> I2C2_SCL
136
    PB11     ------> I2C2_SDA
137
    */
138
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
139
 
140
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
141
 
142
  /* USER CODE BEGIN I2C2_MspDeInit 1 */
143
 
144
  /* USER CODE END I2C2_MspDeInit 1 */
145
  }
146
 
147
}
148
 
149
/**
13 mjames 150
* @brief RTC MSP Initialization
151
* This function configures the hardware resources used in this example
152
* @param hrtc: RTC handle pointer
153
* @retval None
154
*/
155
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
156
{
157
  if(hrtc->Instance==RTC)
158
  {
159
  /* USER CODE BEGIN RTC_MspInit 0 */
160
 
161
  /* USER CODE END RTC_MspInit 0 */
162
    HAL_PWR_EnableBkUpAccess();
163
    /* Enable BKP CLK enable for backup registers */
164
    __HAL_RCC_BKP_CLK_ENABLE();
165
    /* Peripheral clock enable */
166
    __HAL_RCC_RTC_ENABLE();
167
  /* USER CODE BEGIN RTC_MspInit 1 */
168
 
169
  /* USER CODE END RTC_MspInit 1 */
170
  }
171
 
172
}
173
 
174
/**
175
* @brief RTC MSP De-Initialization
176
* This function freeze the hardware resources used in this example
177
* @param hrtc: RTC handle pointer
178
* @retval None
179
*/
180
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
181
{
182
  if(hrtc->Instance==RTC)
183
  {
184
  /* USER CODE BEGIN RTC_MspDeInit 0 */
185
 
186
  /* USER CODE END RTC_MspDeInit 0 */
187
    /* Peripheral clock disable */
188
    __HAL_RCC_RTC_DISABLE();
189
  /* USER CODE BEGIN RTC_MspDeInit 1 */
190
 
191
  /* USER CODE END RTC_MspDeInit 1 */
192
  }
193
 
194
}
195
 
196
/**
2 mjames 197
* @brief SPI MSP Initialization
198
* This function configures the hardware resources used in this example
199
* @param hspi: SPI handle pointer
200
* @retval None
201
*/
202
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
203
{
204
  GPIO_InitTypeDef GPIO_InitStruct = {0};
205
  if(hspi->Instance==SPI1)
206
  {
207
  /* USER CODE BEGIN SPI1_MspInit 0 */
208
 
209
  /* USER CODE END SPI1_MspInit 0 */
210
    /* Peripheral clock enable */
211
    __HAL_RCC_SPI1_CLK_ENABLE();
212
 
213
    __HAL_RCC_GPIOA_CLK_ENABLE();
214
    /**SPI1 GPIO Configuration
215
    PA5     ------> SPI1_SCK
216
    PA7     ------> SPI1_MOSI
217
    */
218
    GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MOSI_Pin;
219
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
220
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
221
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
222
 
223
  /* USER CODE BEGIN SPI1_MspInit 1 */
224
 
225
  /* USER CODE END SPI1_MspInit 1 */
226
  }
227
 
228
}
229
 
230
/**
231
* @brief SPI MSP De-Initialization
232
* This function freeze the hardware resources used in this example
233
* @param hspi: SPI handle pointer
234
* @retval None
235
*/
236
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
237
{
238
  if(hspi->Instance==SPI1)
239
  {
240
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
241
 
242
  /* USER CODE END SPI1_MspDeInit 0 */
243
    /* Peripheral clock disable */
244
    __HAL_RCC_SPI1_CLK_DISABLE();
245
 
246
    /**SPI1 GPIO Configuration
247
    PA5     ------> SPI1_SCK
248
    PA7     ------> SPI1_MOSI
249
    */
250
    HAL_GPIO_DeInit(GPIOA, SPI_SCK_Pin|SPI_MOSI_Pin);
251
 
252
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
253
 
254
  /* USER CODE END SPI1_MspDeInit 1 */
255
  }
256
 
257
}
258
 
259
/**
9 mjames 260
* @brief TIM_OC MSP Initialization
261
* This function configures the hardware resources used in this example
262
* @param htim_oc: TIM_OC handle pointer
263
* @retval None
264
*/
265
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc)
266
{
267
  if(htim_oc->Instance==TIM3)
268
  {
269
  /* USER CODE BEGIN TIM3_MspInit 0 */
270
 
271
  /* USER CODE END TIM3_MspInit 0 */
272
    /* Peripheral clock enable */
273
    __HAL_RCC_TIM3_CLK_ENABLE();
274
  /* USER CODE BEGIN TIM3_MspInit 1 */
275
 
276
  /* USER CODE END TIM3_MspInit 1 */
277
  }
278
 
279
}
280
 
281
/**
2 mjames 282
* @brief TIM_Encoder MSP Initialization
283
* This function configures the hardware resources used in this example
284
* @param htim_encoder: TIM_Encoder handle pointer
285
* @retval None
286
*/
287
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder)
288
{
289
  GPIO_InitTypeDef GPIO_InitStruct = {0};
290
  if(htim_encoder->Instance==TIM4)
291
  {
292
  /* USER CODE BEGIN TIM4_MspInit 0 */
293
 
294
  /* USER CODE END TIM4_MspInit 0 */
295
    /* Peripheral clock enable */
296
    __HAL_RCC_TIM4_CLK_ENABLE();
297
 
298
    __HAL_RCC_GPIOB_CLK_ENABLE();
299
    /**TIM4 GPIO Configuration
300
    PB6     ------> TIM4_CH1
301
    PB7     ------> TIM4_CH2
302
    */
303
    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
304
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
305
    GPIO_InitStruct.Pull = GPIO_NOPULL;
306
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
307
 
308
  /* USER CODE BEGIN TIM4_MspInit 1 */
309
 
310
  /* USER CODE END TIM4_MspInit 1 */
311
  }
312
 
313
}
314
 
315
/**
9 mjames 316
* @brief TIM_OC MSP De-Initialization
317
* This function freeze the hardware resources used in this example
318
* @param htim_oc: TIM_OC handle pointer
319
* @retval None
320
*/
321
void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc)
322
{
323
  if(htim_oc->Instance==TIM3)
324
  {
325
  /* USER CODE BEGIN TIM3_MspDeInit 0 */
326
 
327
  /* USER CODE END TIM3_MspDeInit 0 */
328
    /* Peripheral clock disable */
329
    __HAL_RCC_TIM3_CLK_DISABLE();
330
  /* USER CODE BEGIN TIM3_MspDeInit 1 */
331
 
332
  /* USER CODE END TIM3_MspDeInit 1 */
333
  }
334
 
335
}
336
 
337
/**
2 mjames 338
* @brief TIM_Encoder MSP De-Initialization
339
* This function freeze the hardware resources used in this example
340
* @param htim_encoder: TIM_Encoder handle pointer
341
* @retval None
342
*/
343
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder)
344
{
345
  if(htim_encoder->Instance==TIM4)
346
  {
347
  /* USER CODE BEGIN TIM4_MspDeInit 0 */
348
 
349
  /* USER CODE END TIM4_MspDeInit 0 */
350
    /* Peripheral clock disable */
351
    __HAL_RCC_TIM4_CLK_DISABLE();
352
 
353
    /**TIM4 GPIO Configuration
354
    PB6     ------> TIM4_CH1
355
    PB7     ------> TIM4_CH2
356
    */
357
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
358
 
359
  /* USER CODE BEGIN TIM4_MspDeInit 1 */
360
 
361
  /* USER CODE END TIM4_MspDeInit 1 */
362
  }
363
 
364
}
365
 
366
/**
367
* @brief UART MSP Initialization
368
* This function configures the hardware resources used in this example
369
* @param huart: UART handle pointer
370
* @retval None
371
*/
372
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
373
{
374
  GPIO_InitTypeDef GPIO_InitStruct = {0};
375
  if(huart->Instance==USART1)
376
  {
377
  /* USER CODE BEGIN USART1_MspInit 0 */
378
 
379
  /* USER CODE END USART1_MspInit 0 */
380
    /* Peripheral clock enable */
381
    __HAL_RCC_USART1_CLK_ENABLE();
382
 
383
    __HAL_RCC_GPIOA_CLK_ENABLE();
384
    /**USART1 GPIO Configuration
385
    PA9     ------> USART1_TX
386
    PA10     ------> USART1_RX
387
    */
388
    GPIO_InitStruct.Pin = GPIO_PIN_9;
389
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
390
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
391
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
392
 
393
    GPIO_InitStruct.Pin = GPIO_PIN_10;
394
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
395
    GPIO_InitStruct.Pull = GPIO_NOPULL;
396
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
397
 
398
    /* USART1 interrupt Init */
399
    HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
400
    HAL_NVIC_EnableIRQ(USART1_IRQn);
401
  /* USER CODE BEGIN USART1_MspInit 1 */
402
 
403
  /* USER CODE END USART1_MspInit 1 */
404
  }
405
 
406
}
407
 
408
/**
409
* @brief UART MSP De-Initialization
410
* This function freeze the hardware resources used in this example
411
* @param huart: UART handle pointer
412
* @retval None
413
*/
414
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
415
{
416
  if(huart->Instance==USART1)
417
  {
418
  /* USER CODE BEGIN USART1_MspDeInit 0 */
419
 
420
  /* USER CODE END USART1_MspDeInit 0 */
421
    /* Peripheral clock disable */
422
    __HAL_RCC_USART1_CLK_DISABLE();
423
 
424
    /**USART1 GPIO Configuration
425
    PA9     ------> USART1_TX
426
    PA10     ------> USART1_RX
427
    */
428
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
429
 
430
    /* USART1 interrupt DeInit */
431
    HAL_NVIC_DisableIRQ(USART1_IRQn);
432
  /* USER CODE BEGIN USART1_MspDeInit 1 */
433
 
434
  /* USER CODE END USART1_MspDeInit 1 */
435
  }
436
 
437
}
438
 
439
/* USER CODE BEGIN 1 */
440
 
441
/* USER CODE END 1 */
442
 
443
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/