diff options
Diffstat (limited to 'c/src/lib/libbsp/arm/xm-tms570/startup/cpucounterread.c')
-rw-r--r-- | c/src/lib/libbsp/arm/xm-tms570/startup/cpucounterread.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/xm-tms570/startup/cpucounterread.c b/c/src/lib/libbsp/arm/xm-tms570/startup/cpucounterread.c new file mode 100644 index 0000000000..9cefff34ec --- /dev/null +++ b/c/src/lib/libbsp/arm/xm-tms570/startup/cpucounterread.c @@ -0,0 +1,50 @@ +/* + * @file cpucounterread.c + * + * @author Miguel Masmano <mmasmano@fentiss.com> + * + * @copyright + * Copyright 2016 Fent Innovative Software Solutions (FENTISS). + * All rights reserved. + * + * Copyright 2017 embedded brains GmbH. + * + * 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/counter.h> +#include <rtems/sysinit.h> + +#include <libcpu/arm-cp15.h> + +#include <bsp.h> +#include <xm.h> + +CPU_Counter_ticks _CPU_Counter_read(void) +{ +#ifdef XM_TMS570_USE_PMU_FOR_CPU_COUNTER + return arm_cp15_get_performance_monitors_cycle_count(); +#else + xmTime_t cTime; + XM_get_time(XM_HW_CLOCK, &cTime); + + return (CPU_Counter_ticks)cTime; +#endif +} + +static void xm_tms570_cpu_counter_initialize(void) +{ +#ifdef XM_TMS570_USE_PMU_FOR_CPU_COUNTER + rtems_counter_initialize_converter(XM_TMS570_GCLK); +#else + rtems_counter_initialize_converter(1000000); +#endif +} + +RTEMS_SYSINIT_ITEM( + xm_tms570_cpu_counter_initialize, + RTEMS_SYSINIT_BSP_START, + RTEMS_SYSINIT_ORDER_FIRST +); |