diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-24 07:42:33 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-24 10:24:28 +0200 |
commit | d7a9eb90b6117ed71f5870285cd9fd46aab215e5 (patch) | |
tree | 59153fd7c6466e6572f7a9a5733ec9673cf543ae /bsps/arm/shared | |
parent | bsps: Move bspreset.c to bsps (diff) | |
download | rtems-d7a9eb90b6117ed71f5870285cd9fd46aab215e5.tar.bz2 |
bsps: Move armv7m-cpucounter.c to bsps
This patch is a part of the BSP source reorganization.
Update #3285.
Diffstat (limited to 'bsps/arm/shared')
-rw-r--r-- | bsps/arm/shared/cpucounter/cpucounter-armv7m.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bsps/arm/shared/cpucounter/cpucounter-armv7m.c b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c new file mode 100644 index 0000000000..7d2581879f --- /dev/null +++ b/bsps/arm/shared/cpucounter/cpucounter-armv7m.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * 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> + +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) { + #ifdef BSP_ARMV7M_SYSTICK_FREQUENCY + uint64_t freq = BSP_ARMV7M_SYSTICK_FREQUENCY; + #else + volatile ARMV7M_Systick *systick = _ARMV7M_Systick; + uint64_t freq = ARMV7M_SYSTICK_CALIB_TENMS_GET(systick->calib) * 100ULL; + #endif + + rtems_counter_initialize_converter(freq); + } else { + bsp_fatal(BSP_ARM_ARMV7M_CPU_COUNTER_INIT); + } +} + +RTEMS_SYSINIT_ITEM( + armv7m_cpu_counter_initialize, + RTEMS_SYSINIT_BSP_START, + RTEMS_SYSINIT_ORDER_FIRST +); |