Rev 4 | Rev 9 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 8 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | /* USER CODE BEGIN PM */ |
38 | /* USER CODE BEGIN PM */ |
39 | 39 | ||
40 | /* USER CODE END PM */ |
40 | /* USER CODE END PM */ |
41 | 41 | ||
42 | /* Private variables ---------------------------------------------------------*/ |
42 | /* Private variables ---------------------------------------------------------*/ |
43 | I2C_HandleTypeDef hi2c1; |
43 | I2C_HandleTypeDef hi2c1; |
44 | 44 | ||
45 | SPI_HandleTypeDef hspi1; |
45 | SPI_HandleTypeDef hspi1; |
46 | 46 | ||
47 | /* USER CODE BEGIN PV */ |
47 | /* USER CODE BEGIN PV */ |
48 | 48 | ||
Line 61... | Line 61... | ||
61 | /* USER CODE BEGIN 0 */ |
61 | /* USER CODE BEGIN 0 */ |
62 | 62 | ||
63 | /* USER CODE END 0 */ |
63 | /* USER CODE END 0 */ |
64 | 64 | ||
65 | /** |
65 | /** |
66 | * @brief The application entry point. |
66 | * @brief The application entry point. |
67 | * @retval int |
67 | * @retval int |
68 | */ |
68 | */ |
69 | int main(void) |
69 | int main(void) |
70 | { |
70 | { |
71 | /* USER CODE BEGIN 1 */ |
71 | /* USER CODE BEGIN 1 */ |
72 | 72 | ||
73 | /* USER CODE END 1 */ |
73 | /* USER CODE END 1 */ |
74 | 74 | ||
75 | /* MCU Configuration--------------------------------------------------------*/ |
75 | /* MCU Configuration--------------------------------------------------------*/ |
Line 127... | Line 127... | ||
127 | } |
127 | } |
128 | /* USER CODE END 3 */ |
128 | /* USER CODE END 3 */ |
129 | } |
129 | } |
130 | 130 | ||
131 | /** |
131 | /** |
132 | * @brief System Clock Configuration |
132 | * @brief System Clock Configuration |
133 | * @retval None |
133 | * @retval None |
134 | */ |
134 | */ |
135 | void SystemClock_Config(void) |
135 | void SystemClock_Config(void) |
136 | { |
136 | { |
137 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
137 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
138 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
138 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
139 | 139 | ||
140 | /** Initializes the RCC Oscillators according to the specified parameters |
140 | /** Initializes the RCC Oscillators according to the specified parameters |
141 | * in the RCC_OscInitTypeDef structure. |
141 | * in the RCC_OscInitTypeDef structure. |
142 | */ |
142 | */ |
143 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
143 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
144 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
144 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
145 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
145 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
146 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
146 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
147 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
147 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
Line 151... | Line 151... | ||
151 | { |
151 | { |
152 | Error_Handler(); |
152 | Error_Handler(); |
153 | } |
153 | } |
154 | 154 | ||
155 | /** Initializes the CPU, AHB and APB buses clocks |
155 | /** Initializes the CPU, AHB and APB buses clocks |
156 | */ |
156 | */ |
157 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
157 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
- | 158 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
|
158 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
159 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
159 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
160 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
160 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
161 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; |
161 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
162 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
162 | 163 | ||
Line 165... | Line 166... | ||
165 | Error_Handler(); |
166 | Error_Handler(); |
166 | } |
167 | } |
167 | } |
168 | } |
168 | 169 | ||
169 | /** |
170 | /** |
170 | * @brief I2C1 Initialization Function |
171 | * @brief I2C1 Initialization Function |
171 | * @param None |
172 | * @param None |
172 | * @retval None |
173 | * @retval None |
173 | */ |
174 | */ |
174 | static void MX_I2C1_Init(void) |
175 | static void MX_I2C1_Init(void) |
175 | { |
176 | { |
176 | 177 | ||
177 | /* USER CODE BEGIN I2C1_Init 0 */ |
178 | /* USER CODE BEGIN I2C1_Init 0 */ |
178 | 179 | ||
Line 195... | Line 196... | ||
195 | Error_Handler(); |
196 | Error_Handler(); |
196 | } |
197 | } |
197 | /* USER CODE BEGIN I2C1_Init 2 */ |
198 | /* USER CODE BEGIN I2C1_Init 2 */ |
198 | 199 | ||
199 | /* USER CODE END I2C1_Init 2 */ |
200 | /* USER CODE END I2C1_Init 2 */ |
- | 201 | ||
200 | } |
202 | } |
201 | 203 | ||
202 | /** |
204 | /** |
203 | * @brief SPI1 Initialization Function |
205 | * @brief SPI1 Initialization Function |
204 | * @param None |
206 | * @param None |
205 | * @retval None |
207 | * @retval None |
206 | */ |
208 | */ |
207 | static void MX_SPI1_Init(void) |
209 | static void MX_SPI1_Init(void) |
208 | { |
210 | { |
209 | 211 | ||
210 | /* USER CODE BEGIN SPI1_Init 0 */ |
212 | /* USER CODE BEGIN SPI1_Init 0 */ |
211 | 213 | ||
Line 232... | Line 234... | ||
232 | Error_Handler(); |
234 | Error_Handler(); |
233 | } |
235 | } |
234 | /* USER CODE BEGIN SPI1_Init 2 */ |
236 | /* USER CODE BEGIN SPI1_Init 2 */ |
235 | 237 | ||
236 | /* USER CODE END SPI1_Init 2 */ |
238 | /* USER CODE END SPI1_Init 2 */ |
- | 239 | ||
237 | } |
240 | } |
238 | 241 | ||
239 | /** |
242 | /** |
240 | * @brief GPIO Initialization Function |
243 | * @brief GPIO Initialization Function |
241 | * @param None |
244 | * @param None |
242 | * @retval None |
245 | * @retval None |
243 | */ |
246 | */ |
244 | static void MX_GPIO_Init(void) |
247 | static void MX_GPIO_Init(void) |
245 | { |
248 | { |
246 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
249 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
247 | 250 | ||
248 | /* GPIO Ports Clock Enable */ |
251 | /* GPIO Ports Clock Enable */ |
249 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
252 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
250 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
253 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
251 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
254 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
252 | 255 | ||
253 | /*Configure GPIO pin Output Level */ |
256 | /*Configure GPIO pin Output Level */ |
254 | HAL_GPIO_WritePin(GPIOA, SPI_NSS1_Pin | SPI_RESET_Pin, GPIO_PIN_RESET); |
257 | HAL_GPIO_WritePin(GPIOA, SPI_NSS1_Pin|SPI_RESET_Pin, GPIO_PIN_RESET); |
255 | 258 | ||
256 | /*Configure GPIO pin Output Level */ |
259 | /*Configure GPIO pin Output Level */ |
257 | HAL_GPIO_WritePin(SPI_CD_GPIO_Port, SPI_CD_Pin, GPIO_PIN_RESET); |
260 | HAL_GPIO_WritePin(SPI_CD_GPIO_Port, SPI_CD_Pin, GPIO_PIN_RESET); |
258 | 261 | ||
259 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_RESET_Pin */ |
262 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_RESET_Pin */ |
260 | GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_RESET_Pin; |
263 | GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI_RESET_Pin; |
261 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
264 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
262 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
265 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
263 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
266 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
264 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
267 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
265 | 268 | ||
Line 267... | Line 270... | ||
267 | GPIO_InitStruct.Pin = SPI_CD_Pin; |
270 | GPIO_InitStruct.Pin = SPI_CD_Pin; |
268 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
271 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
269 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
272 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
270 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
273 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
271 | HAL_GPIO_Init(SPI_CD_GPIO_Port, &GPIO_InitStruct); |
274 | HAL_GPIO_Init(SPI_CD_GPIO_Port, &GPIO_InitStruct); |
- | 275 | ||
272 | } |
276 | } |
273 | 277 | ||
274 | /* USER CODE BEGIN 4 */ |
278 | /* USER CODE BEGIN 4 */ |
275 | 279 | ||
276 | /* USER CODE END 4 */ |
280 | /* USER CODE END 4 */ |
277 | 281 | ||
278 | /** |
282 | /** |
279 | * @brief This function is executed in case of error occurrence. |
283 | * @brief This function is executed in case of error occurrence. |
280 | * @retval None |
284 | * @retval None |
281 | */ |
285 | */ |
282 | void Error_Handler(void) |
286 | void Error_Handler(void) |
283 | { |
287 | { |
284 | /* USER CODE BEGIN Error_Handler_Debug */ |
288 | /* USER CODE BEGIN Error_Handler_Debug */ |
285 | /* User can add his own implementation to report the HAL error return state */ |
289 | /* User can add his own implementation to report the HAL error return state */ |
286 | __disable_irq(); |
290 | __disable_irq(); |
Line 288... | Line 292... | ||
288 | { |
292 | { |
289 | } |
293 | } |
290 | /* USER CODE END Error_Handler_Debug */ |
294 | /* USER CODE END Error_Handler_Debug */ |
291 | } |
295 | } |
292 | 296 | ||
293 | #ifdef USE_FULL_ASSERT |
297 | #ifdef USE_FULL_ASSERT |
294 | /** |
298 | /** |
295 | * @brief Reports the name of the source file and the source line number |
299 | * @brief Reports the name of the source file and the source line number |
296 | * where the assert_param error has occurred. |
300 | * where the assert_param error has occurred. |
297 | * @param file: pointer to the source file name |
301 | * @param file: pointer to the source file name |
298 | * @param line: assert_param error line source number |
302 | * @param line: assert_param error line source number |
299 | * @retval None |
303 | * @retval None |
300 | */ |
304 | */ |
301 | void assert_failed(uint8_t *file, uint32_t line) |
305 | void assert_failed(uint8_t *file, uint32_t line) |
302 | { |
306 | { |
303 | /* USER CODE BEGIN 6 */ |
307 | /* USER CODE BEGIN 6 */ |
304 | /* User can add his own implementation to report the file name and line number, |
308 | /* User can add his own implementation to report the file name and line number, |
305 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
309 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |