From 842bb64195f958b050867c50db66fc0aa413dafb Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期六, 27 七月 2024 10:42:56 +0800 Subject: [PATCH] KBus upgrade --- ComLib/Src/BSP.c | 65 ++++++++++++++++++++++++++++++-- 1 files changed, 61 insertions(+), 4 deletions(-) diff --git a/ComLib/Src/BSP.c b/ComLib/Src/BSP.c index c89fcf9..665273d 100644 --- a/ComLib/Src/BSP.c +++ b/ComLib/Src/BSP.c @@ -13,7 +13,7 @@ #include "Globaldef.h" #include "Functions.h" #if (BOARD_TYPE == 14) -#include "fp0.h" +#include "fpx.h" #endif /* @@ -109,8 +109,65 @@ * @retval None */ -void SystemClock_Config(void) +void SystemClock_Config_New(void) { + LL_FLASH_SetLatency(LL_FLASH_LATENCY_1); + + if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_1) + { + Error_Handler(); + } + LL_RCC_HSE_Enable(); + + /* Wait till HSE is ready */ + while(LL_RCC_HSE_IsReady() != 1) + { + + } + LL_RCC_LSI_Enable(); + + /* Wait till LSI is ready */ + while(LL_RCC_LSI_IsReady() != 1) + { + + } +#if (XLAT_FREQ == 12) + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_3, LL_RCC_PLL_MUL_12); +#else + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_2, LL_RCC_PLL_MUL_12); +#endif + LL_RCC_PLL_Enable(); + + /* Wait till PLL is ready */ + while(LL_RCC_PLL_IsReady() != 1) + { + + } + LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); + LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); + + /* Wait till System clock is ready */ + while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) + { + + } + + LL_InitTick(48000000,10000); + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); + + SysTick->CTRL = SysTick_CTRL_ENABLE_Msk + | SysTick_CTRL_TICKINT_Msk; + + LL_SetSystemCoreClock(48000000); + LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK1); + +} + + +void SystemClock_Config(void) +{ RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; @@ -678,8 +735,8 @@ LL_USART_EnableDEMode(USART2); LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_LOW); // LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_HIGH); - LL_USART_SetDEAssertionTime(USART2, 31); - LL_USART_SetDEDeassertionTime(USART2, 31); + LL_USART_SetDEAssertionTime(USART2, 15); + LL_USART_SetDEDeassertionTime(USART2, 15); #else #endif -- Gitblit v1.9.1