Rev 8 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 9 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | * www.st.com/SLA0044 |
15 | * www.st.com/SLA0044 |
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 | #include "usb_device.h" |
22 | #include "usb_device.h" |
24 | 23 | ||
25 | /* Private includes ----------------------------------------------------------*/ |
24 | /* Private includes ----------------------------------------------------------*/ |
26 | /* USER CODE BEGIN Includes */ |
25 | /* USER CODE BEGIN Includes */ |
27 | #include "leds.h" |
26 | #include "libWS2812/leds.h" |
28 | #include "dmx.h" |
27 | #include "dmx.h" |
29 | /* Includes ------------------------------------------------------------------*/ |
28 | /* Includes ------------------------------------------------------------------*/ |
30 | #include "usbd_cdc_if.h" |
29 | #include "usbd_cdc_if.h" |
31 | 30 | ||
32 | /* USER CODE END Includes */ |
31 | /* USER CODE END Includes */ |
Line 50... | Line 49... | ||
50 | SPI_HandleTypeDef hspi1; |
49 | SPI_HandleTypeDef hspi1; |
51 | DMA_HandleTypeDef hdma_spi1_tx; |
50 | DMA_HandleTypeDef hdma_spi1_tx; |
52 | 51 | ||
53 | UART_HandleTypeDef huart1; |
52 | UART_HandleTypeDef huart1; |
54 | 53 | ||
55 | - | ||
56 | /* USER CODE BEGIN PV */ |
54 | /* USER CODE BEGIN PV */ |
57 | 55 | ||
58 | /* USER CODE END PV */ |
56 | /* USER CODE END PV */ |
59 | 57 | ||
60 | /* Private function prototypes -----------------------------------------------*/ |
58 | /* Private function prototypes -----------------------------------------------*/ |
Line 79... | Line 77... | ||
79 | int main(void) |
77 | int main(void) |
80 | { |
78 | { |
81 | /* USER CODE BEGIN 1 */ |
79 | /* USER CODE BEGIN 1 */ |
82 | 80 | ||
83 | /* USER CODE END 1 */ |
81 | /* USER CODE END 1 */ |
84 | - | ||
85 | 82 | ||
86 | /* MCU Configuration--------------------------------------------------------*/ |
83 | /* MCU Configuration--------------------------------------------------------*/ |
87 | 84 | ||
88 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
85 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
89 | HAL_Init(); |
86 | HAL_Init(); |
Line 141... | Line 138... | ||
141 | { |
138 | { |
142 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
139 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
143 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
140 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
144 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; |
141 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; |
145 | 142 | ||
146 | /** Initializes the CPU, AHB and APB busses clocks |
143 | /** Initializes the RCC Oscillators according to the specified parameters |
- | 144 | * in the RCC_OscInitTypeDef structure. |
|
147 | */ |
145 | */ |
148 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
146 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
149 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
147 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
150 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
148 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; |
151 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
149 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
Line 154... | Line 152... | ||
154 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; |
152 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; |
155 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
153 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
156 | { |
154 | { |
157 | Error_Handler(); |
155 | Error_Handler(); |
158 | } |
156 | } |
159 | /** Initializes the CPU, AHB and APB busses clocks |
157 | /** Initializes the CPU, AHB and APB buses clocks |
160 | */ |
158 | */ |
161 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
159 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
162 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
160 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
163 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
161 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
164 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
162 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
Line 198... | Line 196... | ||
198 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
196 | hspi1.Init.Direction = SPI_DIRECTION_2LINES; |
199 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
197 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT; |
200 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
198 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; |
201 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
199 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; |
202 | hspi1.Init.NSS = SPI_NSS_SOFT; |
200 | hspi1.Init.NSS = SPI_NSS_SOFT; |
203 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; |
201 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; |
204 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; |
202 | hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB; |
205 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
203 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE; |
206 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
204 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; |
207 | hspi1.Init.CRCPolynomial = 10; |
205 | hspi1.Init.CRCPolynomial = 10; |
208 | if (HAL_SPI_Init(&hspi1) != HAL_OK) |
206 | if (HAL_SPI_Init(&hspi1) != HAL_OK) |
Line 246... | Line 244... | ||
246 | 244 | ||
247 | /* USER CODE END USART1_Init 2 */ |
245 | /* USER CODE END USART1_Init 2 */ |
248 | 246 | ||
249 | } |
247 | } |
250 | 248 | ||
251 | /** |
249 | /** |
252 | * Enable DMA controller clock |
250 | * Enable DMA controller clock |
253 | */ |
251 | */ |
254 | static void MX_DMA_Init(void) |
252 | static void MX_DMA_Init(void) |
255 | { |
253 | { |
- | 254 | ||
256 | /* DMA controller clock enable */ |
255 | /* DMA controller clock enable */ |
257 | __HAL_RCC_DMA1_CLK_ENABLE(); |
256 | __HAL_RCC_DMA1_CLK_ENABLE(); |
258 | 257 | ||
259 | /* DMA interrupt init */ |
258 | /* DMA interrupt init */ |
260 | /* DMA1_Channel3_IRQn interrupt configuration */ |
259 | /* DMA1_Channel3_IRQn interrupt configuration */ |
Line 300... | Line 299... | ||
300 | * @param file: pointer to the source file name |
299 | * @param file: pointer to the source file name |
301 | * @param line: assert_param error line source number |
300 | * @param line: assert_param error line source number |
302 | * @retval None |
301 | * @retval None |
303 | */ |
302 | */ |
304 | void assert_failed(uint8_t *file, uint32_t line) |
303 | void assert_failed(uint8_t *file, uint32_t line) |
305 | { |
304 | { |
306 | /* USER CODE BEGIN 6 */ |
305 | /* USER CODE BEGIN 6 */ |
307 | /* User can add his own implementation to report the file name and line number, |
306 | /* User can add his own implementation to report the file name and line number, |
308 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
307 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
309 | /* USER CODE END 6 */ |
308 | /* USER CODE END 6 */ |
310 | } |
309 | } |