Subversion Repositories DashDisplay

Rev

Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * File Name          : stm32f1xx_hal_msp.c
4
  * Description        : This file provides code for the MSP Initialization
5
  *                      and de-Initialization codes.
6
  ******************************************************************************
7
  *
8
  * COPYRIGHT(c) 2016 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 "stm32f1xx_hal.h"
36
 
37
/* USER CODE BEGIN 0 */
38
 
39
/* USER CODE END 0 */
40
 
41
/**
42
  * Initializes the Global MSP.
43
  */
44
void HAL_MspInit(void)
45
{
46
  /* USER CODE BEGIN MspInit 0 */
47
 
48
  /* USER CODE END MspInit 0 */
49
 
50
  __HAL_RCC_AFIO_CLK_ENABLE();
51
 
52
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
53
 
54
  /* System interrupt init*/
55
  /* MemoryManagement_IRQn interrupt configuration */
56
  HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
57
  /* BusFault_IRQn interrupt configuration */
58
  HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
59
  /* UsageFault_IRQn interrupt configuration */
60
  HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
61
  /* DebugMonitor_IRQn interrupt configuration */
62
  HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
63
  /* SysTick_IRQn interrupt configuration */
64
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
65
 
66
    /**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
67
    */
68
  __HAL_AFIO_REMAP_SWJ_NOJTAG();
69
 
70
  /* USER CODE BEGIN MspInit 1 */
71
 
72
  /* USER CODE END MspInit 1 */
73
}
74
 
75
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
76
{
77
 
78
  GPIO_InitTypeDef GPIO_InitStruct;
79
  if(hadc->Instance==ADC1)
80
  {
81
  /* USER CODE BEGIN ADC1_MspInit 0 */
82
 
83
  /* USER CODE END ADC1_MspInit 0 */
84
    /* Peripheral clock enable */
85
    __HAL_RCC_ADC1_CLK_ENABLE();
86
 
87
    /**ADC1 GPIO Configuration    
88
    PA0-WKUP     ------> ADC1_IN0
89
    */
90
    GPIO_InitStruct.Pin = GPIO_PIN_0;
91
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
92
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
93
 
94
  /* USER CODE BEGIN ADC1_MspInit 1 */
95
 
96
  /* USER CODE END ADC1_MspInit 1 */
97
  }
98
 
99
}
100
 
101
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
102
{
103
 
104
  if(hadc->Instance==ADC1)
105
  {
106
  /* USER CODE BEGIN ADC1_MspDeInit 0 */
107
 
108
  /* USER CODE END ADC1_MspDeInit 0 */
109
    /* Peripheral clock disable */
110
    __HAL_RCC_ADC1_CLK_DISABLE();
111
 
112
    /**ADC1 GPIO Configuration    
113
    PA0-WKUP     ------> ADC1_IN0
114
    */
115
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
116
 
117
  }
118
  /* USER CODE BEGIN ADC1_MspDeInit 1 */
119
 
120
  /* USER CODE END ADC1_MspDeInit 1 */
121
 
122
}
123
 
124
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
125
{
126
 
127
  GPIO_InitTypeDef GPIO_InitStruct;
128
  if(hspi->Instance==SPI1)
129
  {
130
  /* USER CODE BEGIN SPI1_MspInit 0 */
131
 
132
  /* USER CODE END SPI1_MspInit 0 */
133
    /* Peripheral clock enable */
134
    __HAL_RCC_SPI1_CLK_ENABLE();
135
 
136
    /**SPI1 GPIO Configuration    
137
    PA5     ------> SPI1_SCK
138
    PA7     ------> SPI1_MOSI
139
    */
140
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
141
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
142
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
143
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
144
 
145
  /* USER CODE BEGIN SPI1_MspInit 1 */
146
 
147
  /* USER CODE END SPI1_MspInit 1 */
148
  }
149
 
150
}
151
 
152
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
153
{
154
 
155
  if(hspi->Instance==SPI1)
156
  {
157
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
158
 
159
  /* USER CODE END SPI1_MspDeInit 0 */
160
    /* Peripheral clock disable */
161
    __HAL_RCC_SPI1_CLK_DISABLE();
162
 
163
    /**SPI1 GPIO Configuration    
164
    PA5     ------> SPI1_SCK
165
    PA7     ------> SPI1_MOSI
166
    */
167
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7);
168
 
169
  }
170
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
171
 
172
  /* USER CODE END SPI1_MspDeInit 1 */
173
 
174
}
175
 
176
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
177
{
178
 
179
  GPIO_InitTypeDef GPIO_InitStruct;
180
  if(huart->Instance==USART2)
181
  {
182
  /* USER CODE BEGIN USART2_MspInit 0 */
183
 
184
  /* USER CODE END USART2_MspInit 0 */
185
    /* Peripheral clock enable */
186
    __HAL_RCC_USART2_CLK_ENABLE();
187
 
188
    /**USART2 GPIO Configuration    
189
    PA2     ------> USART2_TX
190
    PA3     ------> USART2_RX
191
    */
192
    GPIO_InitStruct.Pin = GPIO_PIN_2;
193
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
194
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
195
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
196
 
197
    GPIO_InitStruct.Pin = GPIO_PIN_3;
198
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
199
    GPIO_InitStruct.Pull = GPIO_NOPULL;
200
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
201
 
202
    /* Peripheral interrupt init */
203
    HAL_NVIC_SetPriority(USART2_IRQn, 2, 0);
204
    HAL_NVIC_EnableIRQ(USART2_IRQn);
205
  /* USER CODE BEGIN USART2_MspInit 1 */
206
 
207
  /* USER CODE END USART2_MspInit 1 */
208
  }
209
 
210
}
211
 
212
void HAL_IRDA_MspInit(IRDA_HandleTypeDef* hirda)
213
{
214
 
215
  GPIO_InitTypeDef GPIO_InitStruct;
216
  if(hirda->Instance==USART3)
217
  {
218
  /* USER CODE BEGIN USART3_MspInit 0 */
219
 
220
  /* USER CODE END USART3_MspInit 0 */
221
    /* Peripheral clock enable */
222
    __HAL_RCC_USART3_CLK_ENABLE();
223
 
224
    /**USART3 GPIO Configuration    
225
    PB10     ------> USART3_TX
226
    PB11     ------> USART3_RX
227
    */
228
    GPIO_InitStruct.Pin = GPIO_PIN_10;
229
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
230
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
231
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
232
 
233
    GPIO_InitStruct.Pin = GPIO_PIN_11;
234
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
235
    GPIO_InitStruct.Pull = GPIO_NOPULL;
236
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
237
 
238
    /* Peripheral interrupt init */
239
    HAL_NVIC_SetPriority(USART3_IRQn, 2, 0);
240
    HAL_NVIC_EnableIRQ(USART3_IRQn);
241
  /* USER CODE BEGIN USART3_MspInit 1 */
242
 
243
  /* USER CODE END USART3_MspInit 1 */
244
  }
245
 
246
}
247
 
248
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
249
{
250
 
251
  if(huart->Instance==USART2)
252
  {
253
  /* USER CODE BEGIN USART2_MspDeInit 0 */
254
 
255
  /* USER CODE END USART2_MspDeInit 0 */
256
    /* Peripheral clock disable */
257
    __HAL_RCC_USART2_CLK_DISABLE();
258
 
259
    /**USART2 GPIO Configuration    
260
    PA2     ------> USART2_TX
261
    PA3     ------> USART2_RX
262
    */
263
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
264
 
265
    /* Peripheral interrupt DeInit*/
266
    HAL_NVIC_DisableIRQ(USART2_IRQn);
267
 
268
  }
269
  /* USER CODE BEGIN USART2_MspDeInit 1 */
270
 
271
  /* USER CODE END USART2_MspDeInit 1 */
272
 
273
}
274
 
275
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef* hirda)
276
{
277
 
278
  if(hirda->Instance==USART3)
279
  {
280
  /* USER CODE BEGIN USART3_MspDeInit 0 */
281
 
282
  /* USER CODE END USART3_MspDeInit 0 */
283
    /* Peripheral clock disable */
284
    __HAL_RCC_USART3_CLK_DISABLE();
285
 
286
    /**USART3 GPIO Configuration    
287
    PB10     ------> USART3_TX
288
    PB11     ------> USART3_RX
289
    */
290
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
291
 
292
    /* Peripheral interrupt DeInit*/
293
    HAL_NVIC_DisableIRQ(USART3_IRQn);
294
 
295
  }
296
  /* USER CODE BEGIN USART3_MspDeInit 1 */
297
 
298
  /* USER CODE END USART3_MspDeInit 1 */
299
 
300
}
301
 
302
/* USER CODE BEGIN 1 */
303
 
304
/* USER CODE END 1 */
305
 
306
/**
307
  * @}
308
  */
309
 
310
/**
311
  * @}
312
  */
313
 
314
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/