From a13cac70096c0693622321f399fd2eb43a4bccfc Mon Sep 17 00:00:00 2001 From: Claus Michael Olsen Date: Wed, 7 Oct 2015 19:13:11 -0500 Subject: Added PK_TRACE_TIMER_OUTPUT flag to enable disabling of the 2 sec periodic PK trace timer dump by defining PK_TRACE_TIMER_OUTPUT to 0 in, say, global_app_cfg.h in the application dir. - Further, updated PK_{MILLI,MICRO,NANO}SECONDS() macros to use more appropriately sized constants because currently it's much too easy to cause overrun for even small numbers passed to these macros. Also, ditched division ops all together in MILLI and MICRO macros and now using shift operators instead of division in the NANO macro. This saves code space. Change-Id: I47758ac1f735bf4918413a6de28390c9e46d38dc Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21029 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert Reviewed-by: Gregory S. Still --- pk/kernel/pk_api.h | 14 ++++++++------ pk/trace/pk_trace_core.c | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'pk') diff --git a/pk/kernel/pk_api.h b/pk/kernel/pk_api.h index 75515b8b..e1d49d86 100644 --- a/pk/kernel/pk_api.h +++ b/pk/kernel/pk_api.h @@ -300,10 +300,12 @@ /// This is the unscaled timebase frequency in Hz. #ifdef APPCFG_USE_EXT_TIMEBASE -#define PK_BASE_FREQ_HZ 25000000 +#define PK_BASE_FREQ_HZ (uint32_t)25000000 #else -#define PK_BASE_FREQ_HZ 400000000 +#define PK_BASE_FREQ_HZ (uint32_t)400000000 #endif /* APPCFG_USE_EXT_TIMEBASE */ +#define PK_BASE_FREQ_KHZ (PK_BASE_FREQ_HZ / 1000) +#define PK_BASE_FREQ_MHZ (PK_BASE_FREQ_HZ / 1000000) /// Scale a time interval to be _closer_ to what was actually requested /// base on the actual timebase frequency. @@ -313,7 +315,7 @@ /// ignored. The application can redefine this macro. #ifndef PK_SECONDS -#define PK_SECONDS(s) ((PkInterval)(PK_BASE_FREQ_HZ * (PkInterval)(s))) +#define PK_SECONDS(s) ((PkInterval)(PK_BASE_FREQ_HZ * (s))) #endif /// Convert a time in integral milliseconds to a time interval - overflows are @@ -321,7 +323,7 @@ /// assumed. The application can redefine this macro. #ifndef PK_MILLISECONDS -#define PK_MILLISECONDS(m) ((PkInterval)((PK_BASE_FREQ_HZ * (PkInterval)(m)) / 1000)) +#define PK_MILLISECONDS(m) ( (PkInterval)(PK_BASE_FREQ_KHZ * (m)) ) #endif /// Convert a time in integral microseconds to a time interval - overflows are @@ -329,7 +331,7 @@ /// assumed. The application can redefine this macro. #ifndef PK_MICROSECONDS -#define PK_MICROSECONDS(u) ((PkInterval)((PK_BASE_FREQ_HZ * (PkInterval)(u)) / 1000000)) +#define PK_MICROSECONDS(u) ( (PkInterval)(PK_BASE_FREQ_MHZ * (u)) ) #endif /// Convert a time in integral nanoseconds to a time interval - overflows are @@ -337,7 +339,7 @@ /// assumed. The application can redefine this macro. #ifndef PK_NANOSECONDS -#define PK_NANOSECONDS(n) ((PkInterval)((PK_BASE_FREQ_HZ * (PkInterval)(n)) / 1000000000)) +#define PK_NANOSECONDS(n) ( (PkInterval)( ( ((PK_BASE_FREQ_MHZ<<10)/1000) * (n) ) >> 10) ) #endif diff --git a/pk/trace/pk_trace_core.c b/pk/trace/pk_trace_core.c index 93072bd8..429679db 100644 --- a/pk/trace/pk_trace_core.c +++ b/pk/trace/pk_trace_core.c @@ -91,12 +91,15 @@ void pk_trace_tiny(uint32_t i_parm) // This function is called periodically in order to ensure that the max ticks // between trace entries is no more than what will fit inside a 32bit value. +#ifndef PK_TRACE_TIMER_OUTPUT +#define PK_TRACE_TIMER_OUTPUT 1 +#endif void pk_trace_timer_callback(void* arg) { - +#if PK_TRACE_TIMER_OUTPUT // guarantee at least one trace before the lower 32bit timebase flips PK_TRACE("PERIODIC TIMESTAMPING TRACE"); - +#endif // restart the timer pk_timer_schedule(&g_pk_trace_timer, PK_TRACE_TIMER_PERIOD); -- cgit v1.2.1