| | |
| | | RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
| | | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
| | | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
| | | |
| | | #if (XLAT_FREQ == 12) |
| | | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
|
| | | #else
|
| | | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
| | | #endif
|
| | | |
| | | RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
|
| | | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
| | | {
|
| | |
| | |
|
| | | /**Configure Regular Channel
|
| | | */
|
| | | LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_TEMPSENSOR|LL_ADC_CHANNEL_VREFINT);
|
| | | LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_0|LL_ADC_CHANNEL_1);
|
| | |
|
| | | LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR|LL_ADC_PATH_INTERNAL_VREFINT);
|
| | |
|
| | |
| | |
|
| | | LL_ADC_REG_SetSequencerScanDirection(ADC1, LL_ADC_REG_SEQ_SCAN_DIR_FORWARD);
|
| | |
|
| | | LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_71CYCLES_5);
|
| | | LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_28CYCLES_5);
|
| | |
|
| | | LL_ADC_EnableIT_EOC(ADC1);
|
| | |
|
| | |
| | |
|
| | | LL_SPI_EnableNSSPulseMgt(SPI1);
|
| | | /* USER CODE BEGIN SPI1_Init 2 */
|
| | |
|
| | | LL_SPI_Enable(SPI1);
|
| | | /* USER CODE END SPI1_Init 2 */
|
| | | }
|
| | |
|
| | | /* SPI2 init function */
|
| | | void MX_SPI2_Init(void)
|
| | | {
|
| | |
|
| | | LL_SPI_InitTypeDef SPI_InitStruct = {0};
|
| | |
|
| | | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
| | |
|
| | | /* Peripheral clock enable */
|
| | | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI2);
|
| | | |
| | | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
| | | /**SPI2 GPIO Configuration |
| | | PB13 ------> SPI2_SCK
|
| | | PB14 ------> SPI2_MISO
|
| | | PB15 ------> SPI2_MOSI |
| | | */
|
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_13;
|
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
| | |
|
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
|
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
| | |
|
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_15;
|
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
| | |
|
| | | /* SPI2 interrupt Init */
|
| | | //NVIC_SetPriority(SPI2_IRQn, 0);
|
| | | //NVIC_EnableIRQ(SPI2_IRQn);
|
| | | /* USER CODE BEGIN SPI2_Init 1 */
|
| | |
|
| | | /* USER CODE END SPI2_Init 1 */
|
| | |
|
| | | /* SPI2 parameter configuration*/
|
| | | SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
| | | SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
|
| | | SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
| | | SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; //LL_SPI_POLARITY_HIGH;//LL_SPI_POLARITY_LOW;
|
| | | SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; //LL_SPI_PHASE_1EDGE;
|
| | | SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
| | | SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
|
| | | SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
|
| | | SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
| | | SPI_InitStruct.CRCPoly = 7;
|
| | | LL_SPI_Init(SPI2, &SPI_InitStruct);
|
| | | LL_SPI_SetStandard(SPI2, LL_SPI_PROTOCOL_MOTOROLA);
|
| | | LL_SPI_EnableNSSPulseMgt(SPI2);
|
| | | /* USER CODE BEGIN SP21_Init 2 */
|
| | | LL_SPI_Enable(SPI2);
|
| | | /* USER CODE END SPI2_Init 2 */
|
| | | }
|
| | |
|
| | |
|
| | | /* USART1 init function */
|
| | | void MX_USART1_UART_Init(void)
|
| | |
| | | LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10|
|
| | | LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
| | | }
|
| | | else
|
| | | else if ( GetBoardType() == 11 )
|
| | | { |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
| | | LL_GPIO_PIN_2|LL_GPIO_PIN_10|
|
| | | LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
| | | } else |
| | | {
|
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
| | | LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10|
|