Subversion Repositories DashDisplay

Rev

Rev 2 | Rev 5 | Go to most recent revision | Details | Compare with Previous | 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;
3 mjames 180
  if(huart->Instance==USART1)
2 mjames 181
  {
3 mjames 182
  /* USER CODE BEGIN USART1_MspInit 0 */
183
 
184
  /* USER CODE END USART1_MspInit 0 */
185
    /* Peripheral clock enable */
186
    __HAL_RCC_USART1_CLK_ENABLE();
187
 
188
    /**USART1 GPIO Configuration    
189
    PA9     ------> USART1_TX
190
    PA10     ------> USART1_RX
191
    */
192
    GPIO_InitStruct.Pin = PLX_TX_Pin;
193
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
194
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
195
    HAL_GPIO_Init(PLX_TX_GPIO_Port, &GPIO_InitStruct);
196
 
197
    GPIO_InitStruct.Pin = PLX_RX_Pin;
198
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
199
    GPIO_InitStruct.Pull = GPIO_NOPULL;
200
    HAL_GPIO_Init(PLX_RX_GPIO_Port, &GPIO_InitStruct);
201
 
202
  /* USER CODE BEGIN USART1_MspInit 1 */
203
 
204
  /* USER CODE END USART1_MspInit 1 */
205
  }
206
  else if(huart->Instance==USART2)
207
  {
2 mjames 208
  /* USER CODE BEGIN USART2_MspInit 0 */
209
 
210
  /* USER CODE END USART2_MspInit 0 */
211
    /* Peripheral clock enable */
212
    __HAL_RCC_USART2_CLK_ENABLE();
213
 
214
    /**USART2 GPIO Configuration    
215
    PA2     ------> USART2_TX
216
    PA3     ------> USART2_RX
217
    */
218
    GPIO_InitStruct.Pin = GPIO_PIN_2;
219
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
220
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
221
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
222
 
223
    GPIO_InitStruct.Pin = GPIO_PIN_3;
224
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
225
    GPIO_InitStruct.Pull = GPIO_NOPULL;
226
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
227
 
228
    /* Peripheral interrupt init */
229
    HAL_NVIC_SetPriority(USART2_IRQn, 2, 0);
230
    HAL_NVIC_EnableIRQ(USART2_IRQn);
231
  /* USER CODE BEGIN USART2_MspInit 1 */
232
 
233
  /* USER CODE END USART2_MspInit 1 */
234
  }
235
 
236
}
237
 
3 mjames 238
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
2 mjames 239
{
240
 
3 mjames 241
  if(huart->Instance==USART1)
2 mjames 242
  {
3 mjames 243
  /* USER CODE BEGIN USART1_MspDeInit 0 */
2 mjames 244
 
3 mjames 245
  /* USER CODE END USART1_MspDeInit 0 */
246
    /* Peripheral clock disable */
247
    __HAL_RCC_USART1_CLK_DISABLE();
2 mjames 248
 
3 mjames 249
    /**USART1 GPIO Configuration    
250
    PA9     ------> USART1_TX
251
    PA10     ------> USART1_RX
2 mjames 252
    */
3 mjames 253
    HAL_GPIO_DeInit(GPIOA, PLX_TX_Pin|PLX_RX_Pin);
2 mjames 254
 
3 mjames 255
  /* USER CODE BEGIN USART1_MspDeInit 1 */
2 mjames 256
 
3 mjames 257
  /* USER CODE END USART1_MspDeInit 1 */
2 mjames 258
  }
3 mjames 259
  else if(huart->Instance==USART2)
2 mjames 260
  {
261
  /* USER CODE BEGIN USART2_MspDeInit 0 */
262
 
263
  /* USER CODE END USART2_MspDeInit 0 */
264
    /* Peripheral clock disable */
265
    __HAL_RCC_USART2_CLK_DISABLE();
266
 
267
    /**USART2 GPIO Configuration    
268
    PA2     ------> USART2_TX
269
    PA3     ------> USART2_RX
270
    */
271
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
272
 
273
    /* Peripheral interrupt DeInit*/
274
    HAL_NVIC_DisableIRQ(USART2_IRQn);
275
 
276
  /* USER CODE BEGIN USART2_MspDeInit 1 */
277
 
278
  /* USER CODE END USART2_MspDeInit 1 */
279
  }
280
 
281
}
282
 
283
/* USER CODE BEGIN 1 */
284
 
285
/* USER CODE END 1 */
286
 
287
/**
288
  * @}
289
  */
290
 
291
/**
292
  * @}
293
  */
294
 
295
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/