Browse Source

[update] 增加获取cortex-a generic timer频率接口

zhouji 4 years ago
parent
commit
ffe8d06bd3
2 changed files with 9 additions and 0 deletions
  1. 8 0
      libcpu/arm/cortex-a/gtimer.c
  2. 1 0
      libcpu/arm/cortex-a/gtimer.h

+ 8 - 0
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.
  */

+ 1 - 0
libcpu/arm/cortex-a/gtimer.h

@@ -14,6 +14,7 @@
 #include <rtdef.h>
 
 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);