Subversion Repositories DashDisplay

Rev

Go to most recent revision | Details | 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
  *
8
  * COPYRIGHT(c) 2017 STMicroelectronics
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
 
131
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
132
{
133
 
134
  GPIO_InitTypeDef GPIO_InitStruct;
135
  if(huart->Instance==USART1)
136
  {
137
  /* USER CODE BEGIN USART1_MspInit 0 */
138
 
139
  /* USER CODE END USART1_MspInit 0 */
140
    /* Peripheral clock enable */
141
    __HAL_RCC_USART1_CLK_ENABLE();
142
 
143
    /**USART1 GPIO Configuration    
144
    PA9     ------> USART1_TX
145
    PA10     ------> USART1_RX
146
    */
147
    GPIO_InitStruct.Pin = PLX_TX_Pin|PLX_RX_Pin;
148
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
149
    GPIO_InitStruct.Pull = GPIO_PULLUP;
150
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
151
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
152
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
153
 
33 mjames 154
    /* Peripheral interrupt init */
155
    HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
156
    HAL_NVIC_EnableIRQ(USART1_IRQn);
30 mjames 157
  /* USER CODE BEGIN USART1_MspInit 1 */
158
 
159
  /* USER CODE END USART1_MspInit 1 */
160
  }
161
  else if(huart->Instance==USART2)
162
  {
163
  /* USER CODE BEGIN USART2_MspInit 0 */
164
 
165
  /* USER CODE END USART2_MspInit 0 */
166
    /* Peripheral clock enable */
167
    __HAL_RCC_USART2_CLK_ENABLE();
168
 
169
    /**USART2 GPIO Configuration    
170
    PA2     ------> USART2_TX
171
    PA3     ------> USART2_RX
172
    */
173
    GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
174
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
175
    GPIO_InitStruct.Pull = GPIO_PULLUP;
176
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
177
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
178
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
179
 
33 mjames 180
    /* Peripheral interrupt init */
181
    HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
182
    HAL_NVIC_EnableIRQ(USART2_IRQn);
30 mjames 183
  /* USER CODE BEGIN USART2_MspInit 1 */
184
 
185
  /* USER CODE END USART2_MspInit 1 */
186
  }
187
  else if(huart->Instance==USART3)
188
  {
189
  /* USER CODE BEGIN USART3_MspInit 0 */
190
 
191
  /* USER CODE END USART3_MspInit 0 */
192
    /* Peripheral clock enable */
193
    __HAL_RCC_USART3_CLK_ENABLE();
194
 
195
    /**USART3 GPIO Configuration    
196
    PB10     ------> USART3_TX
197
    PB11     ------> USART3_RX
198
    */
199
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
200
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
201
    GPIO_InitStruct.Pull = GPIO_PULLUP;
202
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
203
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
204
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
205
 
33 mjames 206
    /* Peripheral interrupt init */
207
    HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
208
    HAL_NVIC_EnableIRQ(USART3_IRQn);
30 mjames 209
  /* USER CODE BEGIN USART3_MspInit 1 */
210
 
211
  /* USER CODE END USART3_MspInit 1 */
212
  }
213
 
214
}
215
 
216
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
217
{
218
 
219
  if(huart->Instance==USART1)
220
  {
221
  /* USER CODE BEGIN USART1_MspDeInit 0 */
222
 
223
  /* USER CODE END USART1_MspDeInit 0 */
224
    /* Peripheral clock disable */
225
    __HAL_RCC_USART1_CLK_DISABLE();
226
 
227
    /**USART1 GPIO Configuration    
228
    PA9     ------> USART1_TX
229
    PA10     ------> USART1_RX
230
    */
231
    HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin);
232
 
33 mjames 233
    /* Peripheral interrupt DeInit*/
234
    HAL_NVIC_DisableIRQ(USART1_IRQn);
235
 
30 mjames 236
  /* USER CODE BEGIN USART1_MspDeInit 1 */
237
 
238
  /* USER CODE END USART1_MspDeInit 1 */
239
  }
240
  else if(huart->Instance==USART2)
241
  {
242
  /* USER CODE BEGIN USART2_MspDeInit 0 */
243
 
244
  /* USER CODE END USART2_MspDeInit 0 */
245
    /* Peripheral clock disable */
246
    __HAL_RCC_USART2_CLK_DISABLE();
247
 
248
    /**USART2 GPIO Configuration    
249
    PA2     ------> USART2_TX
250
    PA3     ------> USART2_RX
251
    */
252
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
253
 
33 mjames 254
    /* Peripheral interrupt DeInit*/
255
    HAL_NVIC_DisableIRQ(USART2_IRQn);
256
 
30 mjames 257
  /* USER CODE BEGIN USART2_MspDeInit 1 */
258
 
259
  /* USER CODE END USART2_MspDeInit 1 */
260
  }
261
  else if(huart->Instance==USART3)
262
  {
263
  /* USER CODE BEGIN USART3_MspDeInit 0 */
264
 
265
  /* USER CODE END USART3_MspDeInit 0 */
266
    /* Peripheral clock disable */
267
    __HAL_RCC_USART3_CLK_DISABLE();
268
 
269
    /**USART3 GPIO Configuration    
270
    PB10     ------> USART3_TX
271
    PB11     ------> USART3_RX
272
    */
273
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
274
 
33 mjames 275
    /* Peripheral interrupt DeInit*/
276
    HAL_NVIC_DisableIRQ(USART3_IRQn);
277
 
30 mjames 278
  /* USER CODE BEGIN USART3_MspDeInit 1 */
279
 
280
  /* USER CODE END USART3_MspDeInit 1 */
281
  }
282
 
283
}
284
 
285
/* USER CODE BEGIN 1 */
286
 
287
/* USER CODE END 1 */
288
 
289
/**
290
  * @}
291
  */
292
 
293
/**
294
  * @}
295
  */
296
 
297
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/