From 762fa62ccaebadb7fa486da634c27b02960112b1 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 22 May 2018 08:52:13 +0200 Subject: 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. --- bsps/arm/shared/cpucounter/cpucounter-armv7m.c | 37 +++----------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'bsps/arm/shared/cpucounter/cpucounter-armv7m.c') 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 -#include -#include - -#include -#include +#include 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 -); -- cgit v1.2.3