summaryrefslogtreecommitdiffstats
path: root/bsps/arm/shared/cpucounter/cpucounter-armv7m.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-05-22 08:52:13 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-15 13:12:05 +0200
commit762fa62ccaebadb7fa486da634c27b02960112b1 (patch)
treeeb762741aa291dd46578667e1533a71dcfc955b3 /bsps/arm/shared/cpucounter/cpucounter-armv7m.c
parentAdd _CPU_Counter_frequency() (diff)
downloadrtems-762fa62ccaebadb7fa486da634c27b02960112b1.tar.bz2
arm: Simplify CPU counter support
Use the standard ARMv7-M systick module for the ARMv7-M CPU counter instead of DWT counter since the DWT counter is affected by power saving states. Use an inline function for _CPU_Counter_difference() for all ARM BSPs. Update #3456.
Diffstat (limited to 'bsps/arm/shared/cpucounter/cpucounter-armv7m.c')
-rw-r--r--bsps/arm/shared/cpucounter/cpucounter-armv7m.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/bsps/arm/shared/cpucounter/cpucounter-armv7m.c b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c
index b7593602ed..bb7cdc441b 100644
--- a/bsps/arm/shared/cpucounter/cpucounter-armv7m.c
+++ b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2016, 2018 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -12,43 +12,14 @@
* http://www.rtems.org/license/LICENSE.
*/
-#include <rtems/score/armv7m.h>
-#include <rtems/counter.h>
-#include <rtems/sysinit.h>
-
-#include <bsp.h>
-#include <bsp/fatal.h>
+#include <bsp/clock-armv7m.h>
uint32_t _CPU_Counter_frequency(void)
{
-#ifdef BSP_ARMV7M_SYSTICK_FREQUENCY
- return = BSP_ARMV7M_SYSTICK_FREQUENCY;
-#else
- volatile ARMV7M_Systick *systick = _ARMV7M_Systick;
- return ARMV7M_SYSTICK_CALIB_TENMS_GET(systick->calib) * 100;
-#endif
+ return _ARMV7M_Clock_frequency();
}
CPU_Counter_ticks _CPU_Counter_read(void)
{
- volatile ARMV7M_DWT *dwt = _ARMV7M_DWT;
-
- return dwt->cyccnt;
-}
-
-static void armv7m_cpu_counter_initialize(void)
-{
- bool cyccnt_enabled;
-
- cyccnt_enabled = _ARMV7M_DWT_Enable_CYCCNT();
-
- if (!cyccnt_enabled) {
- bsp_fatal(BSP_ARM_ARMV7M_CPU_COUNTER_INIT);
- }
+ return _ARMV7M_Clock_counter(&_ARMV7M_TC);
}
-
-RTEMS_SYSINIT_ITEM(
- armv7m_cpu_counter_initialize,
- RTEMS_SYSINIT_CPU_COUNTER,
- RTEMS_SYSINIT_ORDER_FIRST
-);