Appiko
profiler_timer.c
1 
19 #include "profiler_timer.h"
20 
22 {
23  PROFILER_TIMER->TASKS_STOP = 1; // Stop timer.
24  PROFILER_TIMER->MODE = TIMER_MODE_MODE_Timer; // Set the timer in Timer Mode.
25  PROFILER_TIMER->PRESCALER = 0; // Prescaler 0 produces 16 MHz.
26  PROFILER_TIMER->BITMODE = TIMER_BITMODE_BITMODE_32Bit; // 32 bit mode.
27  PROFILER_TIMER->TASKS_CLEAR = 1; // clear the task first to be usable for later.
28 
29  PROFILER_TIMER->TASKS_START = 1; // Start timer.
30 }
31 
33 {
34  PROFILER_TIMER->BITMODE = TIMER_BITMODE_BITMODE_16Bit; // 32 bit mode.
35 
36  PROFILER_TIMER->TASKS_STOP = 1; // Stop timer.
37  PROFILER_TIMER->TASKS_SHUTDOWN = 1; // Fully stop timer.
38 }
39 
41 {
42  return (PROFILER_TIMER->BITMODE == TIMER_BITMODE_BITMODE_16Bit)? false : true;
43 }
44 
45 void printfcomma(uint32_t num)
46 {
47  if (num < 1000)
48  {
49  log_printf("%d", (int) num);
50  return;
51  }
52  printfcomma(num / 1000);
53  log_printf(",%03d", (int) num % 1000);
54 }
55 
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)