Subversion Repositories DashDisplay

Rev

Rev 50 | Rev 61 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
50 mjames 1
/* USER CODE BEGIN Header */
30 mjames 2
/**
3
  ******************************************************************************
4
  * File Name          : stm32l1xx_hal_msp.c
50 mjames 5
  * Description        : This file provides code for the MSP Initialization
30 mjames 6
  *                      and de-Initialization codes.
7
  ******************************************************************************
50 mjames 8
  * @attention
30 mjames 9
  *
50 mjames 10
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
11
  * All rights reserved.</center></h2>
30 mjames 12
  *
50 mjames 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
30 mjames 17
  *
18
  ******************************************************************************
19
  */
50 mjames 20
/* USER CODE END Header */
21
 
30 mjames 22
/* Includes ------------------------------------------------------------------*/
50 mjames 23
#include "main.h"
24
/* USER CODE BEGIN Includes */
30 mjames 25
 
50 mjames 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
 
30 mjames 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_COMP_CLK_ENABLE();
71
  __HAL_RCC_SYSCFG_CLK_ENABLE();
50 mjames 72
  __HAL_RCC_PWR_CLK_ENABLE();
30 mjames 73
 
74
  /* System interrupt init*/
75
 
76
  /* USER CODE BEGIN MspInit 1 */
77
 
78
  /* USER CODE END MspInit 1 */
79
}
80
 
50 mjames 81
/**
82
* @brief SPI MSP Initialization
83
* This function configures the hardware resources used in this example
84
* @param hspi: SPI handle pointer
85
* @retval None
86
*/
30 mjames 87
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
88
{
50 mjames 89
  GPIO_InitTypeDef GPIO_InitStruct = {0};
30 mjames 90
  if(hspi->Instance==SPI1)
91
  {
92
  /* USER CODE BEGIN SPI1_MspInit 0 */
93
 
94
  /* USER CODE END SPI1_MspInit 0 */
95
    /* Peripheral clock enable */
96
    __HAL_RCC_SPI1_CLK_ENABLE();
50 mjames 97
 
98
    __HAL_RCC_GPIOA_CLK_ENABLE();
99
    /**SPI1 GPIO Configuration
30 mjames 100
    PA5     ------> SPI1_SCK
50 mjames 101
    PA7     ------> SPI1_MOSI
30 mjames 102
    */
50 mjames 103
    GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MOSI_Pin;
30 mjames 104
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
105
    GPIO_InitStruct.Pull = GPIO_NOPULL;
106
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
107
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
108
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
109
 
110
  /* USER CODE BEGIN SPI1_MspInit 1 */
111
 
112
  /* USER CODE END SPI1_MspInit 1 */
113
  }
114
 
115
}
116
 
50 mjames 117
/**
118
* @brief SPI MSP De-Initialization
119
* This function freeze the hardware resources used in this example
120
* @param hspi: SPI handle pointer
121
* @retval None
122
*/
30 mjames 123
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
124
{
125
  if(hspi->Instance==SPI1)
126
  {
127
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
128
 
129
  /* USER CODE END SPI1_MspDeInit 0 */
130
    /* Peripheral clock disable */
131
    __HAL_RCC_SPI1_CLK_DISABLE();
50 mjames 132
 
133
    /**SPI1 GPIO Configuration
30 mjames 134
    PA5     ------> SPI1_SCK
50 mjames 135
    PA7     ------> SPI1_MOSI
30 mjames 136
    */
50 mjames 137
    HAL_GPIO_DeInit(GPIOA, SPI_SCK_Pin|SPI_MOSI_Pin);
30 mjames 138
 
139
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
140
 
141
  /* USER CODE END SPI1_MspDeInit 1 */
50 mjames 142
  }
30 mjames 143
 
144
}
145
 
50 mjames 146
/**
147
* @brief TIM_Base MSP Initialization
148
* This function configures the hardware resources used in this example
149
* @param htim_base: TIM_Base handle pointer
150
* @retval None
151
*/
152
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
153
{
154
  if(htim_base->Instance==TIM2)
155
  {
156
  /* USER CODE BEGIN TIM2_MspInit 0 */
157
 
158
  /* USER CODE END TIM2_MspInit 0 */
159
    /* Peripheral clock enable */
160
    __HAL_RCC_TIM2_CLK_ENABLE();
161
  /* USER CODE BEGIN TIM2_MspInit 1 */
162
 
163
  /* USER CODE END TIM2_MspInit 1 */
164
  }
165
 
166
}
167
 
168
/**
169
* @brief TIM_Encoder MSP Initialization
170
* This function configures the hardware resources used in this example
171
* @param htim_encoder: TIM_Encoder handle pointer
172
* @retval None
173
*/
44 mjames 174
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder)
175
{
50 mjames 176
  GPIO_InitTypeDef GPIO_InitStruct = {0};
44 mjames 177
  if(htim_encoder->Instance==TIM3)
178
  {
179
  /* USER CODE BEGIN TIM3_MspInit 0 */
180
 
181
  /* USER CODE END TIM3_MspInit 0 */
182
    /* Peripheral clock enable */
183
    __HAL_RCC_TIM3_CLK_ENABLE();
50 mjames 184
 
185
    __HAL_RCC_GPIOC_CLK_ENABLE();
186
    /**TIM3 GPIO Configuration
44 mjames 187
    PC6     ------> TIM3_CH1
50 mjames 188
    PC7     ------> TIM3_CH2
44 mjames 189
    */
190
    GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin;
191
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
192
    GPIO_InitStruct.Pull = GPIO_PULLUP;
193
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
194
    GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
195
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
196
 
197
  /* USER CODE BEGIN TIM3_MspInit 1 */
198
 
199
  /* USER CODE END TIM3_MspInit 1 */
200
  }
201
  else if(htim_encoder->Instance==TIM9)
202
  {
203
  /* USER CODE BEGIN TIM9_MspInit 0 */
204
 
205
  /* USER CODE END TIM9_MspInit 0 */
206
    /* Peripheral clock enable */
207
    __HAL_RCC_TIM9_CLK_ENABLE();
50 mjames 208
 
209
    __HAL_RCC_GPIOB_CLK_ENABLE();
210
    /**TIM9 GPIO Configuration
44 mjames 211
    PB13     ------> TIM9_CH1
50 mjames 212
    PB14     ------> TIM9_CH2
44 mjames 213
    */
214
    GPIO_InitStruct.Pin = SW1_I_Pin|SW1_Q_Pin;
215
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
216
    GPIO_InitStruct.Pull = GPIO_PULLUP;
217
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
218
    GPIO_InitStruct.Alternate = GPIO_AF3_TIM9;
219
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
220
 
221
  /* USER CODE BEGIN TIM9_MspInit 1 */
222
 
223
  /* USER CODE END TIM9_MspInit 1 */
224
  }
225
 
226
}
227
 
50 mjames 228
/**
229
* @brief TIM_Base MSP De-Initialization
230
* This function freeze the hardware resources used in this example
231
* @param htim_base: TIM_Base handle pointer
232
* @retval None
233
*/
234
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
235
{
236
  if(htim_base->Instance==TIM2)
237
  {
238
  /* USER CODE BEGIN TIM2_MspDeInit 0 */
239
 
240
  /* USER CODE END TIM2_MspDeInit 0 */
241
    /* Peripheral clock disable */
242
    __HAL_RCC_TIM2_CLK_DISABLE();
243
  /* USER CODE BEGIN TIM2_MspDeInit 1 */
244
 
245
  /* USER CODE END TIM2_MspDeInit 1 */
246
  }
247
 
248
}
249
 
250
/**
251
* @brief TIM_Encoder MSP De-Initialization
252
* This function freeze the hardware resources used in this example
253
* @param htim_encoder: TIM_Encoder handle pointer
254
* @retval None
255
*/
44 mjames 256
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder)
257
{
258
  if(htim_encoder->Instance==TIM3)
259
  {
260
  /* USER CODE BEGIN TIM3_MspDeInit 0 */
261
 
262
  /* USER CODE END TIM3_MspDeInit 0 */
263
    /* Peripheral clock disable */
264
    __HAL_RCC_TIM3_CLK_DISABLE();
50 mjames 265
 
266
    /**TIM3 GPIO Configuration
44 mjames 267
    PC6     ------> TIM3_CH1
50 mjames 268
    PC7     ------> TIM3_CH2
44 mjames 269
    */
270
    HAL_GPIO_DeInit(GPIOC, SW2_I_Pin|SW2_Q_Pin);
271
 
272
  /* USER CODE BEGIN TIM3_MspDeInit 1 */
273
 
274
  /* USER CODE END TIM3_MspDeInit 1 */
275
  }
276
  else if(htim_encoder->Instance==TIM9)
277
  {
278
  /* USER CODE BEGIN TIM9_MspDeInit 0 */
279
 
280
  /* USER CODE END TIM9_MspDeInit 0 */
281
    /* Peripheral clock disable */
282
    __HAL_RCC_TIM9_CLK_DISABLE();
50 mjames 283
 
284
    /**TIM9 GPIO Configuration
44 mjames 285
    PB13     ------> TIM9_CH1
50 mjames 286
    PB14     ------> TIM9_CH2
44 mjames 287
    */
288
    HAL_GPIO_DeInit(GPIOB, SW1_I_Pin|SW1_Q_Pin);
289
 
290
  /* USER CODE BEGIN TIM9_MspDeInit 1 */
291
 
292
  /* USER CODE END TIM9_MspDeInit 1 */
293
  }
294
 
295
}
296
 
50 mjames 297
/**
298
* @brief UART MSP Initialization
299
* This function configures the hardware resources used in this example
300
* @param huart: UART handle pointer
301
* @retval None
302
*/
30 mjames 303
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
304
{
50 mjames 305
  GPIO_InitTypeDef GPIO_InitStruct = {0};
60 mjames 306
  if(huart->Instance==UART4)
30 mjames 307
  {
60 mjames 308
  /* USER CODE BEGIN UART4_MspInit 0 */
309
 
310
  /* USER CODE END UART4_MspInit 0 */
311
    /* Peripheral clock enable */
312
    __HAL_RCC_UART4_CLK_ENABLE();
313
 
314
    __HAL_RCC_GPIOC_CLK_ENABLE();
315
    /**UART4 GPIO Configuration
316
    PC10     ------> UART4_TX
317
    PC11     ------> UART4_RX
318
    */
319
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
320
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
321
    GPIO_InitStruct.Pull = GPIO_PULLUP;
322
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
323
    GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
324
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
325
 
326
  /* USER CODE BEGIN UART4_MspInit 1 */
327
 
328
  /* USER CODE END UART4_MspInit 1 */
329
  }
330
  else if(huart->Instance==USART1)
331
  {
30 mjames 332
  /* USER CODE BEGIN USART1_MspInit 0 */
333
 
334
  /* USER CODE END USART1_MspInit 0 */
335
    /* Peripheral clock enable */
336
    __HAL_RCC_USART1_CLK_ENABLE();
50 mjames 337
 
338
    __HAL_RCC_GPIOA_CLK_ENABLE();
339
    /**USART1 GPIO Configuration
30 mjames 340
    PA9     ------> USART1_TX
50 mjames 341
    PA10     ------> USART1_RX
30 mjames 342
    */
343
    GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin;
344
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
50 mjames 345
    GPIO_InitStruct.Pull = GPIO_NOPULL;
30 mjames 346
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
347
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
348
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
349
 
350
  /* USER CODE BEGIN USART1_MspInit 1 */
351
 
352
  /* USER CODE END USART1_MspInit 1 */
353
  }
354
  else if(huart->Instance==USART2)
355
  {
356
  /* USER CODE BEGIN USART2_MspInit 0 */
357
 
358
  /* USER CODE END USART2_MspInit 0 */
359
    /* Peripheral clock enable */
360
    __HAL_RCC_USART2_CLK_ENABLE();
50 mjames 361
 
362
    __HAL_RCC_GPIOA_CLK_ENABLE();
363
    /**USART2 GPIO Configuration
30 mjames 364
    PA2     ------> USART2_TX
50 mjames 365
    PA3     ------> USART2_RX
30 mjames 366
    */
50 mjames 367
    GPIO_InitStruct.Pin = GPIO_PIN_2;
30 mjames 368
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
50 mjames 369
    GPIO_InitStruct.Pull = GPIO_NOPULL;
370
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
371
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
372
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
373
 
374
    GPIO_InitStruct.Pin = GPIO_PIN_3;
375
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
30 mjames 376
    GPIO_InitStruct.Pull = GPIO_PULLUP;
377
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
378
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
379
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
380
 
381
  /* USER CODE BEGIN USART2_MspInit 1 */
382
 
383
  /* USER CODE END USART2_MspInit 1 */
384
  }
385
  else if(huart->Instance==USART3)
386
  {
387
  /* USER CODE BEGIN USART3_MspInit 0 */
388
 
389
  /* USER CODE END USART3_MspInit 0 */
390
    /* Peripheral clock enable */
391
    __HAL_RCC_USART3_CLK_ENABLE();
50 mjames 392
 
393
    __HAL_RCC_GPIOB_CLK_ENABLE();
394
    /**USART3 GPIO Configuration
30 mjames 395
    PB10     ------> USART3_TX
50 mjames 396
    PB11     ------> USART3_RX
30 mjames 397
    */
50 mjames 398
    GPIO_InitStruct.Pin = GPIO_PIN_10;
30 mjames 399
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
50 mjames 400
    GPIO_InitStruct.Pull = GPIO_NOPULL;
401
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
402
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
403
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
404
 
405
    GPIO_InitStruct.Pin = GPIO_PIN_11;
406
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
30 mjames 407
    GPIO_InitStruct.Pull = GPIO_PULLUP;
408
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
409
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
410
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
411
 
412
  /* USER CODE BEGIN USART3_MspInit 1 */
413
 
414
  /* USER CODE END USART3_MspInit 1 */
415
  }
416
 
417
}
418
 
50 mjames 419
/**
420
* @brief UART MSP De-Initialization
421
* This function freeze the hardware resources used in this example
422
* @param huart: UART handle pointer
423
* @retval None
424
*/
30 mjames 425
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
426
{
60 mjames 427
  if(huart->Instance==UART4)
30 mjames 428
  {
60 mjames 429
  /* USER CODE BEGIN UART4_MspDeInit 0 */
430
 
431
  /* USER CODE END UART4_MspDeInit 0 */
432
    /* Peripheral clock disable */
433
    __HAL_RCC_UART4_CLK_DISABLE();
434
 
435
    /**UART4 GPIO Configuration
436
    PC10     ------> UART4_TX
437
    PC11     ------> UART4_RX
438
    */
439
    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
440
 
441
  /* USER CODE BEGIN UART4_MspDeInit 1 */
442
 
443
  /* USER CODE END UART4_MspDeInit 1 */
444
  }
445
  else if(huart->Instance==USART1)
446
  {
30 mjames 447
  /* USER CODE BEGIN USART1_MspDeInit 0 */
448
 
449
  /* USER CODE END USART1_MspDeInit 0 */
450
    /* Peripheral clock disable */
451
    __HAL_RCC_USART1_CLK_DISABLE();
50 mjames 452
 
453
    /**USART1 GPIO Configuration
30 mjames 454
    PA9     ------> USART1_TX
50 mjames 455
    PA10     ------> USART1_RX
30 mjames 456
    */
457
    HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin);
458
 
459
  /* USER CODE BEGIN USART1_MspDeInit 1 */
460
 
461
  /* USER CODE END USART1_MspDeInit 1 */
462
  }
463
  else if(huart->Instance==USART2)
464
  {
465
  /* USER CODE BEGIN USART2_MspDeInit 0 */
466
 
467
  /* USER CODE END USART2_MspDeInit 0 */
468
    /* Peripheral clock disable */
469
    __HAL_RCC_USART2_CLK_DISABLE();
50 mjames 470
 
471
    /**USART2 GPIO Configuration
30 mjames 472
    PA2     ------> USART2_TX
50 mjames 473
    PA3     ------> USART2_RX
30 mjames 474
    */
475
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
476
 
477
  /* USER CODE BEGIN USART2_MspDeInit 1 */
478
 
479
  /* USER CODE END USART2_MspDeInit 1 */
480
  }
481
  else if(huart->Instance==USART3)
482
  {
483
  /* USER CODE BEGIN USART3_MspDeInit 0 */
484
 
485
  /* USER CODE END USART3_MspDeInit 0 */
486
    /* Peripheral clock disable */
487
    __HAL_RCC_USART3_CLK_DISABLE();
50 mjames 488
 
489
    /**USART3 GPIO Configuration
30 mjames 490
    PB10     ------> USART3_TX
50 mjames 491
    PB11     ------> USART3_RX
30 mjames 492
    */
493
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
494
 
495
  /* USER CODE BEGIN USART3_MspDeInit 1 */
496
 
497
  /* USER CODE END USART3_MspDeInit 1 */
498
  }
499
 
500
}
501
 
502
/* USER CODE BEGIN 1 */
503
 
504
/* USER CODE END 1 */
505
 
506
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/