Subversion Repositories dashGPS

Rev

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