Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 4 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * opensource.org/licenses/BSD-3-Clause |
16 | * |
16 | * |
17 | ****************************************************************************** |
17 | ****************************************************************************** |
18 | */ |
18 | */ |
19 | /* USER CODE END Header */ |
19 | /* USER CODE END Header */ |
20 | - | ||
21 | /* Includes ------------------------------------------------------------------*/ |
20 | /* Includes ------------------------------------------------------------------*/ |
22 | #include "main.h" |
21 | #include "main.h" |
23 | 22 | ||
24 | /* Private includes ----------------------------------------------------------*/ |
23 | /* Private includes ----------------------------------------------------------*/ |
25 | /* USER CODE BEGIN Includes */ |
24 | /* USER CODE BEGIN Includes */ |
26 | - | ||
- | 25 | #include "sendLeds.h" |
|
27 | /* USER CODE END Includes */ |
26 | /* USER CODE END Includes */ |
28 | 27 | ||
29 | /* Private typedef -----------------------------------------------------------*/ |
28 | /* Private typedef -----------------------------------------------------------*/ |
30 | /* USER CODE BEGIN PTD */ |
29 | /* USER CODE BEGIN PTD */ |
31 | 30 | ||
Line 230... | Line 229... | ||
230 | /* USER CODE END 2 */ |
229 | /* USER CODE END 2 */ |
231 | 230 | ||
232 | /* Infinite loop */ |
231 | /* Infinite loop */ |
233 | /* USER CODE BEGIN WHILE */ |
232 | /* USER CODE BEGIN WHILE */ |
234 | while (1) { |
233 | while (1) { |
235 | - | ||
236 | HAL_SPI_Transmit_DMA(&hspi1, SPI_Buffer, NUM_SPI_BYTES); |
234 | sendLeds(); |
237 | - | ||
238 | HAL_Delay(10); |
235 | HAL_Delay(10); |
239 | 236 | ||
240 | /* USER CODE END WHILE */ |
237 | /* USER CODE END WHILE */ |
241 | 238 | ||
242 | /* USER CODE BEGIN 3 */ |
239 | /* USER CODE BEGIN 3 */ |
Line 252... | Line 249... | ||
252 | { |
249 | { |
253 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
250 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
254 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
251 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
255 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; |
252 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; |
256 | 253 | ||
257 | /** Initializes the CPU, AHB and APB busses clocks |
254 | /** Initializes the RCC Oscillators according to the specified parameters |
- | 255 | * in the RCC_OscInitTypeDef structure. |
|
258 | */ |
256 | */ |
259 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14; |
257 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14; |
260 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
258 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
261 | RCC_OscInitStruct.HSI14State = RCC_HSI14_ON; |
259 | RCC_OscInitStruct.HSI14State = RCC_HSI14_ON; |
262 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
260 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
263 | RCC_OscInitStruct.HSI14CalibrationValue = 16; |
261 | RCC_OscInitStruct.HSI14CalibrationValue = 16; |
264 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
262 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
265 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
263 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
266 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL8; |
264 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
267 | RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; |
265 | RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; |
268 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
266 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
269 | { |
267 | { |
270 | Error_Handler(); |
268 | Error_Handler(); |
271 | } |
269 | } |
272 | /** Initializes the CPU, AHB and APB busses clocks |
270 | /** Initializes the CPU, AHB and APB buses clocks |
273 | */ |
271 | */ |
274 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
272 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
275 | |RCC_CLOCKTYPE_PCLK1; |
273 | |RCC_CLOCKTYPE_PCLK1; |
276 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
274 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
277 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
275 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
Line 362... | Line 360... | ||
362 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
360 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
363 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
361 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
364 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
362 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
365 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
363 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
366 | hspi1.Init.NSS = SPI_NSS_SOFT; |
364 | hspi1.Init.NSS = SPI_NSS_SOFT; |
367 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; |
365 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; |
368 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; |
366 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; |
369 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
367 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
370 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
368 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
371 | hspi1.Init.CRCPolynomial = 7; |
369 | hspi1.Init.CRCPolynomial = 7; |
372 | hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; |
370 | hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; |
373 | hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; |
371 | hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; |
374 | if (HAL_SPI_Init(&hspi1) != HAL_OK) |
372 | if (HAL_SPI_Init(&hspi1) != HAL_OK) |
375 | { |
373 | { |
376 | Error_Handler(); |
374 | Error_Handler(); |
377 | } |
375 | } |
378 | /* USER CODE BEGIN SPI1_Init 2 */ |
376 | /* USER CODE BEGIN SPI1_Init 2 */ |
Line 400... | Line 398... | ||
400 | 398 | ||
401 | /* USER CODE END TIM1_Init 1 */ |
399 | /* USER CODE END TIM1_Init 1 */ |
402 | htim1.Instance = TIM1; |
400 | htim1.Instance = TIM1; |
403 | htim1.Init.Prescaler = 0; |
401 | htim1.Init.Prescaler = 0; |
404 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP; |
402 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP; |
405 | htim1.Init.Period = 0; |
403 | htim1.Init.Period = 65535; |
406 | htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
404 | htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; |
407 | htim1.Init.RepetitionCounter = 0; |
405 | htim1.Init.RepetitionCounter = 0; |
408 | htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
406 | htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; |
409 | if (HAL_TIM_Base_Init(&htim1) != HAL_OK) |
407 | if (HAL_TIM_Base_Init(&htim1) != HAL_OK) |
410 | { |
408 | { |
Line 584... | Line 582... | ||
584 | * where the assert_param error has occurred. |
582 | * where the assert_param error has occurred. |
585 | * @param file: pointer to the source file name |
583 | * @param file: pointer to the source file name |
586 | * @param line: assert_param error line source number |
584 | * @param line: assert_param error line source number |
587 | * @retval None |
585 | * @retval None |
588 | */ |
586 | */ |
589 | void assert_failed(char *file, uint32_t line) |
587 | void assert_failed(uint8_t *file, uint32_t line) |
590 | { |
588 | { |
591 | /* USER CODE BEGIN 6 */ |
589 | /* USER CODE BEGIN 6 */ |
592 | /* User can add his own implementation to report the file name and line number, |
590 | /* User can add his own implementation to report the file name and line number, |
593 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
591 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
594 | /* USER CODE END 6 */ |
592 | /* USER CODE END 6 */ |