From ae079c1fc5d990ba55714d4b3a51b19f96edaec4 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 24 四月 2025 16:01:43 +0800 Subject: [PATCH] 改为中断来低电平触发发送当前扫描数据,3s内扫描不到的会退出,串口来55 AA 75 70 64 61 74 65,进入升级模式 --- 01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/system_PANSeries.c | 81 ++++++++++++++++++++++------------------ 1 files changed, 45 insertions(+), 36 deletions(-) diff --git a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/system_PANSeries.c b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/system_PANSeries.c index 155a0a1..e93a20f 100644 --- a/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/system_PANSeries.c +++ b/01_SDK/modules/hal/panchip/panplat/pan1070/bsp/device/Source/system_PANSeries.c @@ -23,7 +23,6 @@ */ const uint32_t PanFlashLineMode = CONFIG_FLASH_LINE_MODE; const bool PanFlashEnhanceEnable = false; -uint32_t vec_remap_adr = 0x20007000; /** * @brief Setup the microcontroller system @@ -35,10 +34,10 @@ void SystemInit(void) { ANA->CPU_ADDR_REMAP_CTRL =0; - + // Speed up flash clock from default 16MHz to 32MHz CLK_SetFlashClkDiv(CLK_FLASH_CLKDIV_1); - // Switch flash to 4-Line mode + // Switch flash line mode FMC_SetFlashMode(FLCTL, PanFlashLineMode, PanFlashEnhanceEnable); // Init I-Cache InitIcache(FLCTL, PanFlashLineMode); @@ -90,32 +89,25 @@ */ void SystemCoreClockUpdate(void) { - -#ifdef FPGA_MODE - //Fixed 32M System Clock on FPGA - SystemCoreClock = FREQ_32MHZ; -#else uint32_t div = 0; uint32_t freq_out = 0; - div = (CLK->CLK_TOP_CTRL_3V & CLK_TOPCTL_AHB_DIV_Msk) >> CLK_TOPCTL_AHB_DIV_Pos; - if(div == 0) - div = 1; - else - div += 1; - if(CLK->CLK_TOP_CTRL_3V & CLK_SYS_SRCSEL_DPLL){ - freq_out = (CLK->DPLL_CTRL & CLK_DPLLCTL_FREQ_OUT_Msk); - if(freq_out == CLK_DPLL_OUT_64M){ - SystemCoreClock = FREQ_64MHZ / div; - } - else{ - SystemCoreClock = FREQ_48MHZ / div; - } - } - else{ - SystemCoreClock = FREQ_32MHZ / div; - } -#endif + div = (CLK->CLK_TOP_CTRL_3V & CLK_TOPCTL_AHB_DIV_Msk) >> CLK_TOPCTL_AHB_DIV_Pos; + if (div == 0) + div = 1; + else + div += 1; + + if (CLK->CLK_TOP_CTRL_3V & CLK_SYS_SRCSEL_DPLL) { + freq_out = (CLK->DPLL_CTRL & CLK_DPLLCTL_FREQ_OUT_Msk); + if(freq_out == CLK_DPLL_OUT_64M){ + SystemCoreClock = FREQ_64MHZ / div; + } else { + SystemCoreClock = FREQ_48MHZ / div; + } + } else { + SystemCoreClock = FREQ_32MHZ / div; + } } static bool HwParamDataVerify(OTP_STRUCT_T *p_opt) @@ -159,15 +151,17 @@ return; } +__WEAK void FMC_ParamsSet(OTP_STRUCT_T *otp) +{ + return; +} + bool SystemHwParamLoader(OTP_STRUCT_T *otp) { /* * NOTE: We should make sure flash enhance mode is disabled before read * data from flash. */ - FMC_GetFlashUniqueId(FLCTL); - FMC_GetFlashJedecId(FLCTL); - FMC_SetFlashCapacity(FLCTL); FMC_ReadInfoArea(FLCTL, 0x0, CMD_DREAD, (uint8_t *)otp, sizeof(OTP_STRUCT_T)); if (!HwParamDataVerify(otp)) @@ -178,6 +172,14 @@ memset(&otp->d8[0x00], 0x00, sizeof(OTP_STRUCT_T)); // clear the global otp structure return false; } + +#if CONFIG_SOC_INCREASE_LPLDOH_CALIB_CODE + otp->m.lph_ldo_trim = (otp->m.lph_ldo_trim + CONFIG_SOC_INCREASE_LPLDOH_CALIB_CODE > 15) ? 15 : otp->m.lph_ldo_trim + CONFIG_SOC_INCREASE_LPLDOH_CALIB_CODE; + if (otp->m.ft_version >= 2) + { + otp->m_v2.lph_ldo_vref_trim = (otp->m_v2.lph_ldo_vref_trim + CONFIG_SOC_INCREASE_LPLDOH_CALIB_CODE > 7) ? 7 : otp->m_v2.lph_ldo_vref_trim + CONFIG_SOC_INCREASE_LPLDOH_CALIB_CODE; + } +#endif // Note: // 1. Clock XTH and XTL may need Board-Level calibration on customers MP stage @@ -231,7 +233,7 @@ } /* - * Storing adc params related calibration. if adc symbol is not linked, + * Storing adc params related calibration. if adc symbol is not linked, * this function would be handled as weak function. */ ADC_SetCalirationParams(otp); @@ -241,6 +243,15 @@ */ PW_ParamsSet(otp); + /* + * Storing ft params for fmc use. + */ + FMC_ParamsSet(otp); + + FMC_GetFlashUniqueId(FLCTL); + FMC_GetFlashJedecId(FLCTL); + FMC_SetFlashCapacity(FLCTL); + #ifdef SYNC_3V_REG_MANUALLY CLK_Wait3vSyncReady(); #endif @@ -249,8 +260,7 @@ } -#if USE_ASSERT - +#if ASSERT_ON /** * @brief Assert Error Message * @@ -262,12 +272,11 @@ * @details The function prints the source file name and line number where * the ASSERT_PARAM() error occurs, and then stops in an infinite loop. */ -void AssertError(uint8_t * file, uint32_t line) +void SYS_AssertError(uint8_t * file, uint32_t line, uint8_t * expr) { - - SYS_DBG(" wrong parameters.\r\n", file, line); + LOG(true, "[SYS ASSERT] Assert Error! expr: \"%s\" (%s: %d)\n", expr, file, line); /* Infinite loop */ - while(1) ; + while(1); } #endif -- Gitblit v1.9.3