Subversion Repositories DashDisplay

Rev

Rev 33 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 mjames 1
/**
2
  ******************************************************************************
3
  * File Name          : stm32l1xx_hal_msp.c
4
  * Description        : This file provides code for the MSP Initialization
5
  *                      and de-Initialization codes.
6
  ******************************************************************************
7
  *
44 mjames 8
  * COPYRIGHT(c) 2018 STMicroelectronics
30 mjames 9
  *
10
  * Redistribution and use in source and binary forms, with or without modification,
11
  * are permitted provided that the following conditions are met:
12
  *   1. Redistributions of source code must retain the above copyright notice,
13
  *      this list of conditions and the following disclaimer.
14
  *   2. Redistributions in binary form must reproduce the above copyright notice,
15
  *      this list of conditions and the following disclaimer in the documentation
16
  *      and/or other materials provided with the distribution.
17
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
18
  *      may be used to endorse or promote products derived from this software
19
  *      without specific prior written permission.
20
  *
21
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
  *
32
  ******************************************************************************
33
  */
34
/* Includes ------------------------------------------------------------------*/
35
#include "stm32l1xx_hal.h"
36
 
37
extern void Error_Handler(void);
38
/* USER CODE BEGIN 0 */
39
 
40
/* USER CODE END 0 */
41
 
42
/**
43
  * Initializes the Global MSP.
44
  */
45
void HAL_MspInit(void)
46
{
47
  /* USER CODE BEGIN MspInit 0 */
48
 
49
  /* USER CODE END MspInit 0 */
50
 
51
  __HAL_RCC_COMP_CLK_ENABLE();
52
  __HAL_RCC_SYSCFG_CLK_ENABLE();
53
 
54
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
55
 
56
  /* System interrupt init*/
57
  /* MemoryManagement_IRQn interrupt configuration */
58
  HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
59
  /* BusFault_IRQn interrupt configuration */
60
  HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
61
  /* UsageFault_IRQn interrupt configuration */
62
  HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
63
  /* SVC_IRQn interrupt configuration */
64
  HAL_NVIC_SetPriority(SVC_IRQn, 0, 0);
65
  /* DebugMonitor_IRQn interrupt configuration */
66
  HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
67
  /* PendSV_IRQn interrupt configuration */
68
  HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
69
  /* SysTick_IRQn interrupt configuration */
70
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
71
 
72
  /* USER CODE BEGIN MspInit 1 */
73
 
74
  /* USER CODE END MspInit 1 */
75
}
76
 
77
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
78
{
79
 
80
  GPIO_InitTypeDef GPIO_InitStruct;
81
  if(hspi->Instance==SPI1)
82
  {
83
  /* USER CODE BEGIN SPI1_MspInit 0 */
84
 
85
  /* USER CODE END SPI1_MspInit 0 */
86
    /* Peripheral clock enable */
87
    __HAL_RCC_SPI1_CLK_ENABLE();
88
 
89
    /**SPI1 GPIO Configuration    
90
    PA5     ------> SPI1_SCK
91
    PA7     ------> SPI1_MOSI
92
    */
93
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
94
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
95
    GPIO_InitStruct.Pull = GPIO_NOPULL;
96
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
97
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
98
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
99
 
100
  /* USER CODE BEGIN SPI1_MspInit 1 */
101
 
102
  /* USER CODE END SPI1_MspInit 1 */
103
  }
104
 
105
}
106
 
107
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
108
{
109
 
110
  if(hspi->Instance==SPI1)
111
  {
112
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
113
 
114
  /* USER CODE END SPI1_MspDeInit 0 */
115
    /* Peripheral clock disable */
116
    __HAL_RCC_SPI1_CLK_DISABLE();
117
 
118
    /**SPI1 GPIO Configuration    
119
    PA5     ------> SPI1_SCK
120
    PA7     ------> SPI1_MOSI
121
    */
122
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7);
123
 
124
  }
125
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
126
 
127
  /* USER CODE END SPI1_MspDeInit 1 */
128
 
129
}
130
 
44 mjames 131
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder)
132
{
133
 
134
  GPIO_InitTypeDef GPIO_InitStruct;
135
  if(htim_encoder->Instance==TIM3)
136
  {
137
  /* USER CODE BEGIN TIM3_MspInit 0 */
138
 
139
  /* USER CODE END TIM3_MspInit 0 */
140
    /* Peripheral clock enable */
141
    __HAL_RCC_TIM3_CLK_ENABLE();
142
 
143
    /**TIM3 GPIO Configuration    
144
    PC6     ------> TIM3_CH1
145
    PC7     ------> TIM3_CH2
146
    */
147
    GPIO_InitStruct.Pin = SW2_I_Pin|SW2_Q_Pin;
148
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
149
    GPIO_InitStruct.Pull = GPIO_PULLUP;
150
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
151
    GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
152
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
153
 
154
  /* USER CODE BEGIN TIM3_MspInit 1 */
155
 
156
  /* USER CODE END TIM3_MspInit 1 */
157
  }
158
  else if(htim_encoder->Instance==TIM9)
159
  {
160
  /* USER CODE BEGIN TIM9_MspInit 0 */
161
 
162
  /* USER CODE END TIM9_MspInit 0 */
163
    /* Peripheral clock enable */
164
    __HAL_RCC_TIM9_CLK_ENABLE();
165
 
166
    /**TIM9 GPIO Configuration    
167
    PB13     ------> TIM9_CH1
168
    PB14     ------> TIM9_CH2
169
    */
170
    GPIO_InitStruct.Pin = SW1_I_Pin|SW1_Q_Pin;
171
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
172
    GPIO_InitStruct.Pull = GPIO_PULLUP;
173
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
174
    GPIO_InitStruct.Alternate = GPIO_AF3_TIM9;
175
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
176
 
177
  /* USER CODE BEGIN TIM9_MspInit 1 */
178
 
179
  /* USER CODE END TIM9_MspInit 1 */
180
  }
181
 
182
}
183
 
184
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder)
185
{
186
 
187
  if(htim_encoder->Instance==TIM3)
188
  {
189
  /* USER CODE BEGIN TIM3_MspDeInit 0 */
190
 
191
  /* USER CODE END TIM3_MspDeInit 0 */
192
    /* Peripheral clock disable */
193
    __HAL_RCC_TIM3_CLK_DISABLE();
194
 
195
    /**TIM3 GPIO Configuration    
196
    PC6     ------> TIM3_CH1
197
    PC7     ------> TIM3_CH2
198
    */
199
    HAL_GPIO_DeInit(GPIOC, SW2_I_Pin|SW2_Q_Pin);
200
 
201
  /* USER CODE BEGIN TIM3_MspDeInit 1 */
202
 
203
  /* USER CODE END TIM3_MspDeInit 1 */
204
  }
205
  else if(htim_encoder->Instance==TIM9)
206
  {
207
  /* USER CODE BEGIN TIM9_MspDeInit 0 */
208
 
209
  /* USER CODE END TIM9_MspDeInit 0 */
210
    /* Peripheral clock disable */
211
    __HAL_RCC_TIM9_CLK_DISABLE();
212
 
213
    /**TIM9 GPIO Configuration    
214
    PB13     ------> TIM9_CH1
215
    PB14     ------> TIM9_CH2
216
    */
217
    HAL_GPIO_DeInit(GPIOB, SW1_I_Pin|SW1_Q_Pin);
218
 
219
  /* USER CODE BEGIN TIM9_MspDeInit 1 */
220
 
221
  /* USER CODE END TIM9_MspDeInit 1 */
222
  }
223
 
224
}
225
 
30 mjames 226
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
227
{
228
 
229
  GPIO_InitTypeDef GPIO_InitStruct;
230
  if(huart->Instance==USART1)
231
  {
232
  /* USER CODE BEGIN USART1_MspInit 0 */
233
 
234
  /* USER CODE END USART1_MspInit 0 */
235
    /* Peripheral clock enable */
236
    __HAL_RCC_USART1_CLK_ENABLE();
237
 
238
    /**USART1 GPIO Configuration    
239
    PA9     ------> USART1_TX
240
    PA10     ------> USART1_RX
241
    */
242
    GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin;
243
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
244
    GPIO_InitStruct.Pull = GPIO_PULLUP;
245
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
246
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
247
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
248
 
33 mjames 249
    /* Peripheral interrupt init */
250
    HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
251
    HAL_NVIC_EnableIRQ(USART1_IRQn);
30 mjames 252
  /* USER CODE BEGIN USART1_MspInit 1 */
253
 
254
  /* USER CODE END USART1_MspInit 1 */
255
  }
256
  else if(huart->Instance==USART2)
257
  {
258
  /* USER CODE BEGIN USART2_MspInit 0 */
259
 
260
  /* USER CODE END USART2_MspInit 0 */
261
    /* Peripheral clock enable */
262
    __HAL_RCC_USART2_CLK_ENABLE();
263
 
264
    /**USART2 GPIO Configuration    
265
    PA2     ------> USART2_TX
266
    PA3     ------> USART2_RX
267
    */
268
    GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
269
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
270
    GPIO_InitStruct.Pull = GPIO_PULLUP;
271
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
272
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
273
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
274
 
33 mjames 275
    /* Peripheral interrupt init */
276
    HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
277
    HAL_NVIC_EnableIRQ(USART2_IRQn);
30 mjames 278
  /* USER CODE BEGIN USART2_MspInit 1 */
279
 
280
  /* USER CODE END USART2_MspInit 1 */
281
  }
282
  else if(huart->Instance==USART3)
283
  {
284
  /* USER CODE BEGIN USART3_MspInit 0 */
285
 
286
  /* USER CODE END USART3_MspInit 0 */
287
    /* Peripheral clock enable */
288
    __HAL_RCC_USART3_CLK_ENABLE();
289
 
290
    /**USART3 GPIO Configuration    
291
    PB10     ------> USART3_TX
292
    PB11     ------> USART3_RX
293
    */
294
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
295
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
296
    GPIO_InitStruct.Pull = GPIO_PULLUP;
297
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
298
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
299
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
300
 
33 mjames 301
    /* Peripheral interrupt init */
302
    HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
303
    HAL_NVIC_EnableIRQ(USART3_IRQn);
30 mjames 304
  /* USER CODE BEGIN USART3_MspInit 1 */
305
 
306
  /* USER CODE END USART3_MspInit 1 */
307
  }
308
 
309
}
310
 
311
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
312
{
313
 
314
  if(huart->Instance==USART1)
315
  {
316
  /* USER CODE BEGIN USART1_MspDeInit 0 */
317
 
318
  /* USER CODE END USART1_MspDeInit 0 */
319
    /* Peripheral clock disable */
320
    __HAL_RCC_USART1_CLK_DISABLE();
321
 
322
    /**USART1 GPIO Configuration    
323
    PA9     ------> USART1_TX
324
    PA10     ------> USART1_RX
325
    */
326
    HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin);
327
 
33 mjames 328
    /* Peripheral interrupt DeInit*/
329
    HAL_NVIC_DisableIRQ(USART1_IRQn);
330
 
30 mjames 331
  /* USER CODE BEGIN USART1_MspDeInit 1 */
332
 
333
  /* USER CODE END USART1_MspDeInit 1 */
334
  }
335
  else if(huart->Instance==USART2)
336
  {
337
  /* USER CODE BEGIN USART2_MspDeInit 0 */
338
 
339
  /* USER CODE END USART2_MspDeInit 0 */
340
    /* Peripheral clock disable */
341
    __HAL_RCC_USART2_CLK_DISABLE();
342
 
343
    /**USART2 GPIO Configuration    
344
    PA2     ------> USART2_TX
345
    PA3     ------> USART2_RX
346
    */
347
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
348
 
33 mjames 349
    /* Peripheral interrupt DeInit*/
350
    HAL_NVIC_DisableIRQ(USART2_IRQn);
351
 
30 mjames 352
  /* USER CODE BEGIN USART2_MspDeInit 1 */
353
 
354
  /* USER CODE END USART2_MspDeInit 1 */
355
  }
356
  else if(huart->Instance==USART3)
357
  {
358
  /* USER CODE BEGIN USART3_MspDeInit 0 */
359
 
360
  /* USER CODE END USART3_MspDeInit 0 */
361
    /* Peripheral clock disable */
362
    __HAL_RCC_USART3_CLK_DISABLE();
363
 
364
    /**USART3 GPIO Configuration    
365
    PB10     ------> USART3_TX
366
    PB11     ------> USART3_RX
367
    */
368
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
369
 
33 mjames 370
    /* Peripheral interrupt DeInit*/
371
    HAL_NVIC_DisableIRQ(USART3_IRQn);
372
 
30 mjames 373
  /* USER CODE BEGIN USART3_MspDeInit 1 */
374
 
375
  /* USER CODE END USART3_MspDeInit 1 */
376
  }
377
 
378
}
379
 
380
/* USER CODE BEGIN 1 */
381
 
382
/* USER CODE END 1 */
383
 
384
/**
385
  * @}
386
  */
387
 
388
/**
389
  * @}
390
  */
391
 
392
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/