From d02d49a044d01d210e39627922c4cb0e86c4d8d6 Mon Sep 17 00:00:00 2001 From: aliyun3243248791 Date: Fri, 8 May 2026 04:11:36 +0000 Subject: [PATCH] Merge #3400 into fd272 from refs/changes/3400/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 时间重置问题修改 * refs/changes/3400/head: (1 commits squashed) - 时间重置问题修改 Signed-off-by: 薛文强 Merged-by: 薛文强 CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/3400 --- .../flashboot/brandy/boot_ulp/boot_ulp.c | 4 +- .../brandy/porting/button/button_porting.c | 38 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c index 7e454b75e..feb77887a 100644 --- a/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c +++ b/code/sdk/bootloader/flashboot/brandy/boot_ulp/boot_ulp.c @@ -28,7 +28,7 @@ static uint32_t g_clock_ulp_ssb = 3276800; calendar_regs_t *g_calendar_reg = SSB_CALENDAR_BASE_ADDR; -#if 0 +#if 1 static uint64_t uapi_ulp_systick_get_count(void) { uint64_t count = 0; @@ -59,6 +59,8 @@ calendar_regs_t *g_calendar_reg = SSB_CALENDAR_BASE_ADDR; count |= (uint64_t)readw(ULP_SYSTICK_VAL1) << 16U; count |= (uint64_t)readw(ULP_SYSTICK_VAL0); writew(ULP_LOCK_REG, 0x0); + PRINT("[ULP_SYSTICK] uapi_ulp_systick_get_count: count=0x%016llx dec=%llu\r\n", + (unsigned long long)count, (unsigned long long)count); osal_irq_restore(irq_sts); return count; } diff --git a/code/sdk/drivers/chips/brandy/porting/button/button_porting.c b/code/sdk/drivers/chips/brandy/porting/button/button_porting.c index 98f2ae4d0..bdfb32f4f 100644 --- a/code/sdk/drivers/chips/brandy/porting/button/button_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/button/button_porting.c @@ -74,27 +74,25 @@ errcode_t uapi_power_set_mode(power_mode_t pdmode) uint64_t uapi_ulp_systick_get_count(void) { + #define ULP_SYSTICK_GET_DELAY_US 60UL uint64_t count = 0; - static uint64_t s_last_count = 0; - uint16_t v0 = readw(ULP_SYSTICK_VAL0); - uint16_t v1 = readw(ULP_SYSTICK_VAL1); - uint16_t v2 = readw(ULP_SYSTICK_VAL2); - uint16_t v3 = readw(ULP_SYSTICK_VAL3); - - count = ((uint64_t)v3 << 48U) | - ((uint64_t)v2 << 32U) | - ((uint64_t)v1 << 16U) | - ((uint64_t)v0); - - PRINT("[ULP_CNT][drv ] v3=0x%04x v2=0x%04x v1=0x%04x v0=0x%04x count=0x%016llx (%llu)\r\n", - v3, v2, v1, v0, (unsigned long long)count, (unsigned long long)count); - - if (s_last_count != 0 && count < s_last_count) { - PRINT("[ULP_CNT][WARN][drv ] rollback! last=0x%016llx now=0x%016llx\r\n", - (unsigned long long)s_last_count, (unsigned long long)count); - } - s_last_count = count; - + unsigned int irq_sts = osal_irq_lock(); + + uint64_t before = readw(0x5702c510); + before = before | 0x01; + writew(0x5702c510,before); + // writew(ULP_LOCK_REG, 0x1); + + uapi_tcxo_delay_us(ULP_SYSTICK_GET_DELAY_US); + + count = (uint64_t)readw(ULP_SYSTICK_VAL3) << 48U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL2) << 32U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL1) << 16U; + count |= (uint64_t)readw(ULP_SYSTICK_VAL0); + writew(0x5702c510, 0x0); + PRINT("[ULP_SYSTICK] uapi_ulp_systick_get_count: count=0x%016llx dec=%llu\r\n", + (unsigned long long)count, (unsigned long long)count); + osal_irq_restore(irq_sts); return count; } -- 2.17.1