sppport stm32h743-atk-apollo pcf8574 and uart2(485)

This commit is contained in:
whj4674672 2020-04-09 16:48:01 +08:00
parent baa3145bfe
commit 32d13e389b
9 changed files with 247 additions and 73 deletions

View File

@ -41,10 +41,11 @@
| **板载外设** | **支持情况** | **备注** |
| :----------------- | :----------: | :------------------------------------- |
| USB 转串口 | 支持 | |
| COM2 | 支持 | |
| QSPI Flash | 支持 | |
| 以太网 | 暂不支持 | |
| SD卡 | 暂不支持 | |
| CAN | 暂不支持 | |
| CAN-FD | 暂不支持 | |
| SDRAM | 支持 | |
| LCD | 支持 | |
| MPU9250六轴传感器 | 暂不支持 | |
@ -52,7 +53,7 @@
| GPIO | 支持 | PA0, PA1... PK15 ---> PIN: 0, 1...176 |
| UART | 支持 | |
| SPI | 支持 | SPI2 |
| I2C | 暂不支持 | |
| I2C | 支持 | PCF8574 |
| SDIO | 暂不支持 | |
| RTC | 支持 | |
| PWM | 暂不支持 | |

View File

@ -26,6 +26,7 @@ Mcu.IP1=DEBUG
Mcu.IP10=SPI2
Mcu.IP11=SYS
Mcu.IP12=USART1
Mcu.IP13=USART2
Mcu.IP2=DMA2D
Mcu.IP3=FMC
Mcu.IP4=IWDG1
@ -34,7 +35,7 @@ Mcu.IP6=NVIC
Mcu.IP7=QUADSPI
Mcu.IP8=RCC
Mcu.IP9=RTC
Mcu.IPNb=13
Mcu.IPNb=14
Mcu.Name=STM32H743IITx
Mcu.Package=LQFP176
Mcu.Pin0=PC13
@ -51,74 +52,76 @@ Mcu.Pin18=PC0
Mcu.Pin19=PC2_C
Mcu.Pin2=PC15-OSC32_OUT (OSC32_OUT)
Mcu.Pin20=PC3_C
Mcu.Pin21=PB2
Mcu.Pin22=PF11
Mcu.Pin23=PF12
Mcu.Pin24=PF13
Mcu.Pin25=PF14
Mcu.Pin26=PF15
Mcu.Pin27=PG0
Mcu.Pin28=PG1
Mcu.Pin29=PE7
Mcu.Pin21=PA2
Mcu.Pin22=PA3
Mcu.Pin23=PB2
Mcu.Pin24=PF11
Mcu.Pin25=PF12
Mcu.Pin26=PF13
Mcu.Pin27=PF14
Mcu.Pin28=PF15
Mcu.Pin29=PG0
Mcu.Pin3=PI9
Mcu.Pin30=PE8
Mcu.Pin31=PE9
Mcu.Pin32=PE10
Mcu.Pin33=PE11
Mcu.Pin34=PE12
Mcu.Pin35=PE13
Mcu.Pin36=PE14
Mcu.Pin37=PE15
Mcu.Pin38=PH9
Mcu.Pin39=PH10
Mcu.Pin30=PG1
Mcu.Pin31=PE7
Mcu.Pin32=PE8
Mcu.Pin33=PE9
Mcu.Pin34=PE10
Mcu.Pin35=PE11
Mcu.Pin36=PE12
Mcu.Pin37=PE13
Mcu.Pin38=PE14
Mcu.Pin39=PE15
Mcu.Pin4=PI10
Mcu.Pin40=PH11
Mcu.Pin41=PH12
Mcu.Pin42=PB13
Mcu.Pin43=PB14
Mcu.Pin44=PB15
Mcu.Pin45=PD8
Mcu.Pin46=PD9
Mcu.Pin47=PD10
Mcu.Pin48=PD14
Mcu.Pin49=PD15
Mcu.Pin40=PH9
Mcu.Pin41=PH10
Mcu.Pin42=PH11
Mcu.Pin43=PH12
Mcu.Pin44=PB13
Mcu.Pin45=PB14
Mcu.Pin46=PB15
Mcu.Pin47=PD8
Mcu.Pin48=PD9
Mcu.Pin49=PD10
Mcu.Pin5=PF0
Mcu.Pin50=PG2
Mcu.Pin51=PG4
Mcu.Pin52=PG5
Mcu.Pin53=PG6
Mcu.Pin54=PG7
Mcu.Pin55=PG8
Mcu.Pin56=PA9
Mcu.Pin57=PA10
Mcu.Pin58=PA13 (JTMS/SWDIO)
Mcu.Pin59=PH13
Mcu.Pin50=PD14
Mcu.Pin51=PD15
Mcu.Pin52=PG2
Mcu.Pin53=PG4
Mcu.Pin54=PG5
Mcu.Pin55=PG6
Mcu.Pin56=PG7
Mcu.Pin57=PG8
Mcu.Pin58=PA9
Mcu.Pin59=PA10
Mcu.Pin6=PF1
Mcu.Pin60=PH14
Mcu.Pin61=PH15
Mcu.Pin62=PI0
Mcu.Pin63=PI1
Mcu.Pin64=PI2
Mcu.Pin65=PA14 (JTCK/SWCLK)
Mcu.Pin66=PD0
Mcu.Pin67=PD1
Mcu.Pin68=PG11
Mcu.Pin69=PG15
Mcu.Pin60=PA13 (JTMS/SWDIO)
Mcu.Pin61=PH13
Mcu.Pin62=PH14
Mcu.Pin63=PH15
Mcu.Pin64=PI0
Mcu.Pin65=PI1
Mcu.Pin66=PI2
Mcu.Pin67=PA14 (JTCK/SWCLK)
Mcu.Pin68=PD0
Mcu.Pin69=PD1
Mcu.Pin7=PF2
Mcu.Pin70=PB6
Mcu.Pin71=PE0
Mcu.Pin72=PE1
Mcu.Pin73=PI4
Mcu.Pin74=PI5
Mcu.Pin75=PI6
Mcu.Pin76=PI7
Mcu.Pin77=VP_DMA2D_VS_DMA2D
Mcu.Pin78=VP_IWDG1_VS_IWDG
Mcu.Pin79=VP_RTC_VS_RTC_Activate
Mcu.Pin70=PG11
Mcu.Pin71=PG15
Mcu.Pin72=PB6
Mcu.Pin73=PE0
Mcu.Pin74=PE1
Mcu.Pin75=PI4
Mcu.Pin76=PI5
Mcu.Pin77=PI6
Mcu.Pin78=PI7
Mcu.Pin79=VP_DMA2D_VS_DMA2D
Mcu.Pin8=PF3
Mcu.Pin80=VP_SYS_VS_Systick
Mcu.Pin80=VP_IWDG1_VS_IWDG
Mcu.Pin81=VP_RTC_VS_RTC_Activate
Mcu.Pin82=VP_SYS_VS_Systick
Mcu.Pin9=PF4
Mcu.PinsNb=81
Mcu.PinsNb=83
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32H743IITx
@ -126,6 +129,7 @@ MxCube.Version=5.3.0
MxDb.Version=DB.5.0.30
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@ -134,6 +138,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
PA10.Locked=true
PA10.Mode=Asynchronous
@ -142,6 +147,10 @@ PA13\ (JTMS/SWDIO).Mode=Serial_Wire
PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO
PA14\ (JTCK/SWCLK).Mode=Serial_Wire
PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK
PA2.Mode=Asynchronous
PA2.Signal=USART2_TX
PA3.Mode=Asynchronous
PA3.Signal=USART2_RX
PA9.Locked=true
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
@ -301,7 +310,7 @@ PI7.Signal=LTDC_B7
PI9.Mode=RGB565
PI9.Signal=LTDC_VSYNC
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.AskForMigrate=false
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
@ -327,7 +336,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_DMA2D_Init-DMA2D-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_IWDG1_Init-IWDG1-false-HAL-true,10-MX_QUADSPI_Init-QUADSPI-false-HAL-true,11-MX_SPI2_Init-SPI2-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_DMA2D_Init-DMA2D-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_RTC_Init-RTC-false-HAL-true,9-MX_IWDG1_Init-IWDG1-false-HAL-true,10-MX_QUADSPI_Init-QUADSPI-false-HAL-true,11-MX_SPI2_Init-SPI2-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true
RCC.ADCFreq_Value=50390625
RCC.AHB12Freq_Value=200000000
RCC.AHB4Freq_Value=200000000
@ -493,6 +502,8 @@ SPI2.Mode=SPI_MODE_MASTER
SPI2.VirtualType=VM_MASTER
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
USART2.IPParameters=VirtualMode-Asynchronous
USART2.VirtualMode-Asynchronous=VM_ASYNC
VP_DMA2D_VS_DMA2D.Mode=DMA2D_Activate
VP_DMA2D_VS_DMA2D.Signal=DMA2D_VS_DMA2D
VP_IWDG1_VS_IWDG.Mode=IWDG_Activate

View File

@ -151,7 +151,7 @@
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
#define USE_RTOS 0U
#define USE_SD_TRANSCEIVER 1U /*!< use uSD Transceiver */
#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */

View File

@ -72,6 +72,7 @@ void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */

View File

@ -76,6 +76,7 @@ RTC_HandleTypeDef hrtc;
SPI_HandleTypeDef hspi2;
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;
SDRAM_HandleTypeDef hsdram1;
@ -94,6 +95,7 @@ static void MX_RTC_Init(void);
static void MX_IWDG1_Init(void);
static void MX_QUADSPI_Init(void);
static void MX_SPI2_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@ -146,6 +148,7 @@ int main(void)
MX_IWDG1_Init();
MX_QUADSPI_Init();
MX_SPI2_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -225,8 +228,9 @@ void SystemClock_Config(void)
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_LTDC
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_SPI2
|RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC;
|RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_USART1
|RCC_PERIPHCLK_SPI2|RCC_PERIPHCLK_QSPI
|RCC_PERIPHCLK_FMC;
PeriphClkInitStruct.PLL3.PLL3M = 5;
PeriphClkInitStruct.PLL3.PLL3N = 160;
PeriphClkInitStruct.PLL3.PLL3P = 2;
@ -238,6 +242,7 @@ void SystemClock_Config(void)
PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK;
PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK;
PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
@ -558,6 +563,54 @@ static void MX_USART1_UART_Init(void)
}
/**
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
static void MX_USART2_UART_Init(void)
{
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart2, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}
/* FMC initialization function */
static void MX_FMC_Init(void)
{
@ -618,11 +671,11 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
}

View File

@ -382,6 +382,7 @@ void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi)
*/
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hrtc->Instance==RTC)
{
/* USER CODE BEGIN RTC_MspInit 0 */
@ -389,6 +390,13 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
/* USER CODE END RTC_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_RTC_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**RTC GPIO Configuration
PC13 ------> RTC_OUT_CALIB
*/
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
@ -411,6 +419,12 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
/* USER CODE END RTC_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_RTC_DISABLE();
/**RTC GPIO Configuration
PC13 ------> RTC_OUT_CALIB
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_13);
/* USER CODE BEGIN RTC_MspDeInit 1 */
/* USER CODE END RTC_MspDeInit 1 */
@ -521,6 +535,33 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
/* USER CODE END USART1_MspInit 1 */
}
else if(huart->Instance==USART2)
{
/* USER CODE BEGIN USART2_MspInit 0 */
/* USER CODE END USART2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USART2 interrupt Init */
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
/* USER CODE BEGIN USART2_MspInit 1 */
/* USER CODE END USART2_MspInit 1 */
}
}
@ -552,6 +593,26 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
/* USER CODE END USART1_MspDeInit 1 */
}
else if(huart->Instance==USART2)
{
/* USER CODE BEGIN USART2_MspDeInit 0 */
/* USER CODE END USART2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART2_CLK_DISABLE();
/**USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
/* USART2 interrupt DeInit */
HAL_NVIC_DisableIRQ(USART2_IRQn);
/* USER CODE BEGIN USART2_MspDeInit 1 */
/* USER CODE END USART2_MspDeInit 1 */
}
}

View File

@ -72,6 +72,7 @@
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
@ -226,6 +227,20 @@ void USART1_IRQHandler(void)
/* USER CODE END USART1_IRQn 1 */
}
/**
* @brief This function handles USART2 global interrupt.
*/
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */
/* USER CODE END USART2_IRQn 0 */
HAL_UART_IRQHandler(&huart2);
/* USER CODE BEGIN USART2_IRQn 1 */
/* USER CODE END USART2_IRQn 1 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@ -8,7 +8,15 @@ config SOC_STM32H743II
default y
menu "Onboard Peripheral Drivers"
config BSP_USING_COM2
bool "Enable COM2(485)"
select BSP_USING_UART
select BSP_USING_UART2
select BSP_USING_I2C1
select PKG_USING_PCF8574
default n
config BSP_USING_SDRAM
bool "Enable SDRAM"
select BSP_USING_FMC
@ -44,6 +52,10 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_UART1
bool "Enable UART1"
default y
config BSP_USING_UART2
bool "Enable UART2"
default n
endif
config BSP_USING_FMC
@ -70,6 +82,24 @@ menu "On-chip Peripheral Drivers"
select RT_USING_SPI
default n
menuconfig BSP_USING_I2C1
bool "Enable I2C1 BUS (software simulation)"
default n
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C1
comment "Notice: PH4 --> 116; PH5 --> 117"
config BSP_I2C1_SCL_PIN
int "i2c1 scl pin number"
range 1 176
default 116
config BSP_I2C1_SDA_PIN
int "I2C1 sda pin number"
range 1 176
default 117
endif
menuconfig BSP_USING_ONCHIP_RTC
bool "Enable RTC"
select RT_USING_RTC

View File

@ -70,8 +70,9 @@ void SystemClock_Config(void)
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_LTDC
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_SPI2
|RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC;
|RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_USART1
|RCC_PERIPHCLK_SPI2|RCC_PERIPHCLK_QSPI
|RCC_PERIPHCLK_FMC;
PeriphClkInitStruct.PLL3.PLL3M = 5;
PeriphClkInitStruct.PLL3.PLL3N = 160;
PeriphClkInitStruct.PLL3.PLL3P = 2;
@ -83,6 +84,7 @@ void SystemClock_Config(void)
PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK;
PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK;
PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)