From ffe8d06bd3a5796cdfa33c979c1ec57b65703f08 Mon Sep 17 00:00:00 2001 From: zhouji <956133287@qq.com> Date: Wed, 5 May 2021 23:13:10 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?cortex-a=20generic=20timer=E9=A2=91=E7=8E=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libcpu/arm/cortex-a/gtimer.c | 8 ++++++++ libcpu/arm/cortex-a/gtimer.h | 1 + 2 files changed, 9 insertions(+) diff --git a/libcpu/arm/cortex-a/gtimer.c b/libcpu/arm/cortex-a/gtimer.c index b193a1593d..b35acc6e6f 100644 --- a/libcpu/arm/cortex-a/gtimer.c +++ b/libcpu/arm/cortex-a/gtimer.c @@ -110,6 +110,14 @@ void gtimer_set_counter_frequency(rt_uint32_t value) __asm__ volatile ("isb 0xF":::"memory"); } +/** Get the frequency the timer shall run at. + * return timer frequency in Hz. + */ +rt_uint32_t gtimer_get_counter_frequency(void) +{ + return(__get_cntfrq()); +} + /** Sets the reset value of the timer. * param value: The value the timer is loaded with. */ diff --git a/libcpu/arm/cortex-a/gtimer.h b/libcpu/arm/cortex-a/gtimer.h index 160d0cefde..ec5d54127e 100644 --- a/libcpu/arm/cortex-a/gtimer.h +++ b/libcpu/arm/cortex-a/gtimer.h @@ -14,6 +14,7 @@ #include void gtimer_set_counter_frequency(rt_uint32_t value); +rt_uint32_t gtimer_get_counter_frequency(void); void gtimer_set_load_value(rt_uint32_t value); rt_uint32_t gtimer_get_current_value(void); rt_uint64_t gtimer_get_current_physical_value(void); -- GitLab