Appiko
profiler_timer.h
1 
31 #ifndef CODEBASE_PERIPHERAL_MODULES_PROFILER_TIMER_H_
32 #define CODEBASE_PERIPHERAL_MODULES_PROFILER_TIMER_H_
33 
34 #include <stdint.h>
35 #include "stdbool.h"
36 #include "nrf.h"
37 #include "log.h"
38 
39 #if SYS_CFG_PRESENT == 1
40 #include "sys_config.h"
41 #endif
42 #ifndef TIMER_USED_PROFILE_TIMER
43 #define TIMER_USED_PROFILE_TIMER 0
44 #endif
45 
47 #define PROFILER_TIMER CONCAT_2(NRF_TIMER,TIMER_USED_PROFILE_TIMER)
48 
52 #define PRINT_TIME do{ PROFILER_TIMER->TASKS_CAPTURE[3] = 1; \
53  printfcomma(PROFILER_TIMER->CC[3]/16); \
54  log_printf("us\n"); }while(0)
55 
61 #define PROFILE_START do{ PROFILER_TIMER->TASKS_CAPTURE[2] = 1; }while(0)
62 
63 #define PROFILE_STOP do{ PROFILER_TIMER->TASKS_CAPTURE[3] = 1; \
64  printfcomma((PROFILER_TIMER->CC[3] - PROFILER_TIMER->CC[2])/16); \
65  log_printf(".%03d",(int)((((PROFILER_TIMER->CC[3] - PROFILER_TIMER->CC[2]) & 0x0F)*125)/2)); \
66  log_printf("us\n"); }while(0)
67 
70 void profiler_timer_init(void);
71 
76 void printfcomma(uint32_t num);
77 
84 inline uint32_t read_time_us(void)
85 {
86  PROFILER_TIMER->TASKS_CAPTURE[3] = 1;
87  return (PROFILER_TIMER->CC[3] / 16);
88 }
89 
94 bool profiler_timer_is_on(void);
95 
100 
101 #endif /* CODEBASE_PERIPHERAL_MODULES_PROFILER_TIMER_H_ */
102 
void profiler_timer_init(void)
void profiler_timer_deinit()
Fully stop the profiling timer to save power. profiler_timer_init needs to be called again before usi...
#define PROFILER_TIMER
void printfcomma(uint32_t num)
bool profiler_timer_is_on(void)
uint32_t read_time_us(void)