Subversion Repositories LedShow

Rev

Rev 2 | Details | Compare with Previous | 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) 2019 STMicroelectronics.
11
  * All rights reserved.</center></h2>
12
  *
13
  * This software component is licensed by ST under Ultimate Liberty license
14
  * SLA0044, the "License"; You may not use this file except in compliance with
15
  * the License. You may obtain a copy of the License at:
16
  *                             www.st.com/SLA0044
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
extern DMA_HandleTypeDef hdma_spi1_tx;
28
 
29
/* Private typedef -----------------------------------------------------------*/
30
/* USER CODE BEGIN TD */
31
 
32
/* USER CODE END TD */
33
 
34
/* Private define ------------------------------------------------------------*/
35
/* USER CODE BEGIN Define */
36
 
37
/* USER CODE END Define */
38
 
39
/* Private macro -------------------------------------------------------------*/
40
/* USER CODE BEGIN Macro */
41
 
42
/* USER CODE END Macro */
43
 
44
/* Private variables ---------------------------------------------------------*/
45
/* USER CODE BEGIN PV */
46
 
47
/* USER CODE END PV */
48
 
49
/* Private function prototypes -----------------------------------------------*/
50
/* USER CODE BEGIN PFP */
51
 
52
/* USER CODE END PFP */
53
 
54
/* External functions --------------------------------------------------------*/
55
/* USER CODE BEGIN ExternalFunctions */
56
 
57
/* USER CODE END ExternalFunctions */
58
 
59
/* USER CODE BEGIN 0 */
60
 
61
/* USER CODE END 0 */
62
/**
63
  * Initializes the Global MSP.
64
  */
65
void HAL_MspInit(void)
66
{
67
  /* USER CODE BEGIN MspInit 0 */
68
 
69
  /* USER CODE END MspInit 0 */
70
 
71
  __HAL_RCC_AFIO_CLK_ENABLE();
72
  __HAL_RCC_PWR_CLK_ENABLE();
73
 
74
  /* System interrupt init*/
75
 
9 mjames 76
  /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
2 mjames 77
  */
78
  __HAL_AFIO_REMAP_SWJ_NOJTAG();
79
 
80
  /* USER CODE BEGIN MspInit 1 */
81
 
82
  /* USER CODE END MspInit 1 */
83
}
84
 
85
/**
86
* @brief SPI MSP Initialization
87
* This function configures the hardware resources used in this example
88
* @param hspi: SPI handle pointer
89
* @retval None
90
*/
91
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
92
{
93
  GPIO_InitTypeDef GPIO_InitStruct = {0};
94
  if(hspi->Instance==SPI1)
95
  {
96
  /* USER CODE BEGIN SPI1_MspInit 0 */
97
 
98
  /* USER CODE END SPI1_MspInit 0 */
99
    /* Peripheral clock enable */
100
    __HAL_RCC_SPI1_CLK_ENABLE();
9 mjames 101
 
2 mjames 102
    __HAL_RCC_GPIOA_CLK_ENABLE();
9 mjames 103
    /**SPI1 GPIO Configuration
2 mjames 104
    PA5     ------> SPI1_SCK
9 mjames 105
    PA7     ------> SPI1_MOSI
2 mjames 106
    */
107
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
108
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
109
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
110
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
111
 
112
    /* SPI1 DMA Init */
113
    /* SPI1_TX Init */
114
    hdma_spi1_tx.Instance = DMA1_Channel3;
115
    hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
116
    hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
117
    hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE;
118
    hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
119
    hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
120
    hdma_spi1_tx.Init.Mode = DMA_NORMAL;
121
    hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW;
122
    if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK)
123
    {
124
      Error_Handler();
125
    }
126
 
127
    __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx);
128
 
129
  /* USER CODE BEGIN SPI1_MspInit 1 */
130
 
131
  /* USER CODE END SPI1_MspInit 1 */
132
  }
133
 
134
}
135
 
136
/**
137
* @brief SPI MSP De-Initialization
138
* This function freeze the hardware resources used in this example
139
* @param hspi: SPI handle pointer
140
* @retval None
141
*/
142
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
143
{
144
  if(hspi->Instance==SPI1)
145
  {
146
  /* USER CODE BEGIN SPI1_MspDeInit 0 */
147
 
148
  /* USER CODE END SPI1_MspDeInit 0 */
149
    /* Peripheral clock disable */
150
    __HAL_RCC_SPI1_CLK_DISABLE();
9 mjames 151
 
152
    /**SPI1 GPIO Configuration
2 mjames 153
    PA5     ------> SPI1_SCK
9 mjames 154
    PA7     ------> SPI1_MOSI
2 mjames 155
    */
156
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7);
157
 
158
    /* SPI1 DMA DeInit */
159
    HAL_DMA_DeInit(hspi->hdmatx);
160
  /* USER CODE BEGIN SPI1_MspDeInit 1 */
161
 
162
  /* USER CODE END SPI1_MspDeInit 1 */
163
  }
164
 
165
}
166
 
167
/**
168
* @brief UART MSP Initialization
169
* This function configures the hardware resources used in this example
170
* @param huart: UART handle pointer
171
* @retval None
172
*/
173
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
174
{
175
  GPIO_InitTypeDef GPIO_InitStruct = {0};
176
  if(huart->Instance==USART1)
177
  {
178
  /* USER CODE BEGIN USART1_MspInit 0 */
179
 
180
  /* USER CODE END USART1_MspInit 0 */
181
    /* Peripheral clock enable */
182
    __HAL_RCC_USART1_CLK_ENABLE();
9 mjames 183
 
2 mjames 184
    __HAL_RCC_GPIOA_CLK_ENABLE();
9 mjames 185
    /**USART1 GPIO Configuration
2 mjames 186
    PA9     ------> USART1_TX
9 mjames 187
    PA10     ------> USART1_RX
2 mjames 188
    */
189
    GPIO_InitStruct.Pin = GPIO_PIN_9;
190
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
191
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
192
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
193
 
194
    GPIO_InitStruct.Pin = GPIO_PIN_10;
195
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
196
    GPIO_InitStruct.Pull = GPIO_NOPULL;
197
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
198
 
199
  /* USER CODE BEGIN USART1_MspInit 1 */
200
 
201
  /* USER CODE END USART1_MspInit 1 */
202
  }
203
 
204
}
205
 
206
/**
207
* @brief UART MSP De-Initialization
208
* This function freeze the hardware resources used in this example
209
* @param huart: UART handle pointer
210
* @retval None
211
*/
212
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
213
{
214
  if(huart->Instance==USART1)
215
  {
216
  /* USER CODE BEGIN USART1_MspDeInit 0 */
217
 
218
  /* USER CODE END USART1_MspDeInit 0 */
219
    /* Peripheral clock disable */
220
    __HAL_RCC_USART1_CLK_DISABLE();
9 mjames 221
 
222
    /**USART1 GPIO Configuration
2 mjames 223
    PA9     ------> USART1_TX
9 mjames 224
    PA10     ------> USART1_RX
2 mjames 225
    */
226
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
227
 
228
  /* USER CODE BEGIN USART1_MspDeInit 1 */
229
 
230
  /* USER CODE END USART1_MspDeInit 1 */
231
  }
232
 
233
}
234
 
235
/* USER CODE BEGIN 1 */
236
 
237
/* USER CODE END 1 */
238
 
239
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/