From 06f9bbcbe7087849983ae57b70789af298cdc638 Mon Sep 17 00:00:00 2001 From: Doug Brown Date: Sun, 6 Aug 2023 20:35:27 -0700 Subject: [PATCH] Strip out unnecessary clock and UART code The default values for SystemCoreClock, CyclesPerUs, and PllClock work fine for my purposes of running from the 48 MHz HIRC. Remove unnecessary initialization code. This is especially useful for the bootloader where flash space is at a premium. Also strip out unneeded UART setup code. --- hal/m258ke/nuvoton/system_M251.c | 57 -------------------------------- hal/m258ke/nuvoton/system_M251.h | 15 --------- 2 files changed, 72 deletions(-) diff --git a/hal/m258ke/nuvoton/system_M251.c b/hal/m258ke/nuvoton/system_M251.c index 61ec78a..9de7c5e 100644 --- a/hal/m258ke/nuvoton/system_M251.c +++ b/hal/m258ke/nuvoton/system_M251.c @@ -27,44 +27,6 @@ uint32_t CyclesPerUs = (__HSI / 1000000); /*!< Cycles per micro second uint32_t PllClock = __HSI; /*!< PLL Output Clock Frequency */ const uint32_t gau32ClkSrcTbl[8] = {__HXT, __LXT, 0UL, __LIRC, 0UL, __MIRC, 0UL, __HIRC}; - -/** - * @brief Update the Variable SystemCoreClock - * - * @details This function is used to update the variable SystemCoreClock - * and must be called whenever the core clock is changed. - */ -void SystemCoreClockUpdate(void) -{ - uint32_t u32Freq, u32ClkSrc; - uint32_t u32HclkDiv; - - u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLKSEL_Msk; - - /* Update PLL Clock */ - PllClock = CLK_GetPLLClockFreq(); - - if (u32ClkSrc != CLK_CLKSEL0_HCLKSEL_PLL) - { - /* Use the clock sources directly */ - u32Freq = gau32ClkSrcTbl[u32ClkSrc]; - } - else - { - /* Use PLL clock */ - u32Freq = PllClock; - } - - u32HclkDiv = (CLK->CLKDIV0 & CLK_CLKDIV0_HCLKDIV_Msk) + 1; - - /* Update System Core Clock */ - SystemCoreClock = u32Freq / u32HclkDiv; - - CyclesPerUs = (SystemCoreClock + 500000) / 1000000; -} - - - /** * @brief System Initialization * @@ -112,22 +74,3 @@ void AssertError(uint8_t *file, uint32_t line) while (1) ; } #endif - -/** - * @brief Set UART0 Default MPF - * - * @details The initialization of uart0 default multi function pin. - */ -#if defined( __ICCARM__ ) - __WEAK -#else - __attribute__((weak)) -#endif -void Uart0DefaultMPF(void) -{ - - /* Set GPB multi-function pins for UART0 RXD and TXD */ - SYS->GPB_MFPH = (SYS->GPB_MFPH & ~SYS_GPB_MFPH_PB12MFP_Msk) | SYS_GPB_MFPH_PB12MFP_UART0_RXD; - SYS->GPB_MFPH = (SYS->GPB_MFPH & ~SYS_GPB_MFPH_PB13MFP_Msk) | SYS_GPB_MFPH_PB13MFP_UART0_TXD; - -} diff --git a/hal/m258ke/nuvoton/system_M251.h b/hal/m258ke/nuvoton/system_M251.h index 14b17ea..17603cc 100644 --- a/hal/m258ke/nuvoton/system_M251.h +++ b/hal/m258ke/nuvoton/system_M251.h @@ -47,21 +47,6 @@ extern uint32_t PllClock; /*!< PLL Output Clock Frequency */ */ extern void SystemInit(void); -/** - * @brief Update the Variable SystemCoreClock - * - * @details This function is used to update the variable SystemCoreClock - * and must be called whenever the core clock is changed. - */ -extern void SystemCoreClockUpdate(void); - -/** - * @brief Set UART0 Default MPF - * - * @details The initialization of uart0 default multi function pin. - */ -extern void Uart0DefaultMPF(void); - /** * @brief Check if debug message finished *