Subversion Repositories dashGPS

Rev

Rev 9 | Go to most recent revision | Details | 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
/**
85
* @brief CAN MSP Initialization
86
* This function configures the hardware resources used in this example
87
* @param hcan: CAN handle pointer
88
* @retval None
89
*/
90
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
91
{
92
  GPIO_InitTypeDef GPIO_InitStruct = {0};
93
  if(hcan->Instance==CAN1)
94
  {
95
  /* USER CODE BEGIN CAN1_MspInit 0 */
96
 
97
  /* USER CODE END CAN1_MspInit 0 */
98
    /* Peripheral clock enable */
99
    __HAL_RCC_CAN1_CLK_ENABLE();
100
 
101
    __HAL_RCC_GPIOA_CLK_ENABLE();
102
    /**CAN GPIO Configuration
103
    PA11     ------> CAN_RX
104
    PA12     ------> CAN_TX
105
    */
106
    GPIO_InitStruct.Pin = GPIO_PIN_11;
107
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
108
    GPIO_InitStruct.Pull = GPIO_NOPULL;
109
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
110
 
111
    GPIO_InitStruct.Pin = GPIO_PIN_12;
112
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
113
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
114
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
115
 
116
  /* USER CODE BEGIN CAN1_MspInit 1 */
117
 
118
  /* USER CODE END CAN1_MspInit 1 */
119
  }
120
 
121
}
122
 
123
/**
124
* @brief CAN MSP De-Initialization
125
* This function freeze the hardware resources used in this example
126
* @param hcan: CAN handle pointer
127
* @retval None
128
*/
129
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
130
{
131
  if(hcan->Instance==CAN1)
132
  {
133
  /* USER CODE BEGIN CAN1_MspDeInit 0 */
134
 
135
  /* USER CODE END CAN1_MspDeInit 0 */
136
    /* Peripheral clock disable */
137
    __HAL_RCC_CAN1_CLK_DISABLE();
138
 
139
    /**CAN GPIO Configuration
140
    PA11     ------> CAN_RX
141
    PA12     ------> CAN_TX
142
    */
143
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
144
 
145
  /* USER CODE BEGIN CAN1_MspDeInit 1 */
146
 
147
  /* USER CODE END CAN1_MspDeInit 1 */
148
  }
149
 
150
}
151
 
152
/**
153
* @brief SPI MSP Initialization
154
* This function configures the hardware resources used in this example
155
* @param hspi: SPI handle pointer
156
* @retval None
157
*/
158
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
159
{
160
  GPIO_InitTypeDef GPIO_InitStruct = {0};
161
  if(hspi->Instance==SPI1)
162
  {
163
  /* USER CODE BEGIN SPI1_MspInit 0 */
164
 
165
  /* USER CODE END SPI1_MspInit 0 */
166
    /* Peripheral clock enable */
167
    __HAL_RCC_SPI1_CLK_ENABLE();
168
 
169
    __HAL_RCC_GPIOA_CLK_ENABLE();
170
    /**SPI1 GPIO Configuration
171
    PA5     ------> SPI1_SCK
172
    PA7     ------> SPI1_MOSI
173
    */
174
    GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MOSI_Pin;
175
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
176
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
177
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
178
 
179
  /* USER CODE BEGIN SPI1_MspInit 1 */
180
 
181
  /* USER CODE END SPI1_MspInit 1 */
182
  }
183
 
184
}
185
 
186
/**
187
* @brief SPI MSP De-Initialization
188
* This function freeze the hardware resources used in this example
189
* @param hspi: SPI handle pointer
190
* @retval None
191
*/
192
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
193
{
194
  if(hspi->Instance==SPI1)
195
  {
196
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
197
 
198
  /* USER CODE END SPI1_MspDeInit 0 */
199
    /* Peripheral clock disable */
200
    __HAL_RCC_SPI1_CLK_DISABLE();
201
 
202
    /**SPI1 GPIO Configuration
203
    PA5     ------> SPI1_SCK
204
    PA7     ------> SPI1_MOSI
205
    */
206
    HAL_GPIO_DeInit(GPIOA, SPI_SCK_Pin|SPI_MOSI_Pin);
207
 
208
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
209
 
210
  /* USER CODE END SPI1_MspDeInit 1 */
211
  }
212
 
213
}
214
 
215
/**
216
* @brief TIM_Encoder MSP Initialization
217
* This function configures the hardware resources used in this example
218
* @param htim_encoder: TIM_Encoder handle pointer
219
* @retval None
220
*/
221
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder)
222
{
223
  GPIO_InitTypeDef GPIO_InitStruct = {0};
224
  if(htim_encoder->Instance==TIM4)
225
  {
226
  /* USER CODE BEGIN TIM4_MspInit 0 */
227
 
228
  /* USER CODE END TIM4_MspInit 0 */
229
    /* Peripheral clock enable */
230
    __HAL_RCC_TIM4_CLK_ENABLE();
231
 
232
    __HAL_RCC_GPIOB_CLK_ENABLE();
233
    /**TIM4 GPIO Configuration
234
    PB6     ------> TIM4_CH1
235
    PB7     ------> TIM4_CH2
236
    */
237
    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
238
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
239
    GPIO_InitStruct.Pull = GPIO_NOPULL;
240
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
241
 
242
  /* USER CODE BEGIN TIM4_MspInit 1 */
243
 
244
  /* USER CODE END TIM4_MspInit 1 */
245
  }
246
 
247
}
248
 
249
/**
250
* @brief TIM_Encoder MSP De-Initialization
251
* This function freeze the hardware resources used in this example
252
* @param htim_encoder: TIM_Encoder handle pointer
253
* @retval None
254
*/
255
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder)
256
{
257
  if(htim_encoder->Instance==TIM4)
258
  {
259
  /* USER CODE BEGIN TIM4_MspDeInit 0 */
260
 
261
  /* USER CODE END TIM4_MspDeInit 0 */
262
    /* Peripheral clock disable */
263
    __HAL_RCC_TIM4_CLK_DISABLE();
264
 
265
    /**TIM4 GPIO Configuration
266
    PB6     ------> TIM4_CH1
267
    PB7     ------> TIM4_CH2
268
    */
269
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
270
 
271
  /* USER CODE BEGIN TIM4_MspDeInit 1 */
272
 
273
  /* USER CODE END TIM4_MspDeInit 1 */
274
  }
275
 
276
}
277
 
278
/**
279
* @brief UART MSP Initialization
280
* This function configures the hardware resources used in this example
281
* @param huart: UART handle pointer
282
* @retval None
283
*/
284
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
285
{
286
  GPIO_InitTypeDef GPIO_InitStruct = {0};
287
  if(huart->Instance==USART1)
288
  {
289
  /* USER CODE BEGIN USART1_MspInit 0 */
290
 
291
  /* USER CODE END USART1_MspInit 0 */
292
    /* Peripheral clock enable */
293
    __HAL_RCC_USART1_CLK_ENABLE();
294
 
295
    __HAL_RCC_GPIOA_CLK_ENABLE();
296
    /**USART1 GPIO Configuration
297
    PA9     ------> USART1_TX
298
    PA10     ------> USART1_RX
299
    */
300
    GPIO_InitStruct.Pin = GPIO_PIN_9;
301
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
302
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
303
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
304
 
305
    GPIO_InitStruct.Pin = GPIO_PIN_10;
306
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
307
    GPIO_InitStruct.Pull = GPIO_NOPULL;
308
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
309
 
310
    /* USART1 interrupt Init */
311
    HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
312
    HAL_NVIC_EnableIRQ(USART1_IRQn);
313
  /* USER CODE BEGIN USART1_MspInit 1 */
314
 
315
  /* USER CODE END USART1_MspInit 1 */
316
  }
317
 
318
}
319
 
320
/**
321
* @brief UART MSP De-Initialization
322
* This function freeze the hardware resources used in this example
323
* @param huart: UART handle pointer
324
* @retval None
325
*/
326
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
327
{
328
  if(huart->Instance==USART1)
329
  {
330
  /* USER CODE BEGIN USART1_MspDeInit 0 */
331
 
332
  /* USER CODE END USART1_MspDeInit 0 */
333
    /* Peripheral clock disable */
334
    __HAL_RCC_USART1_CLK_DISABLE();
335
 
336
    /**USART1 GPIO Configuration
337
    PA9     ------> USART1_TX
338
    PA10     ------> USART1_RX
339
    */
340
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
341
 
342
    /* USART1 interrupt DeInit */
343
    HAL_NVIC_DisableIRQ(USART1_IRQn);
344
  /* USER CODE BEGIN USART1_MspDeInit 1 */
345
 
346
  /* USER CODE END USART1_MspDeInit 1 */
347
  }
348
 
349
}
350
 
351
/* USER CODE BEGIN 1 */
352
 
353
/* USER CODE END 1 */
354
 
355
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/