rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
profiling.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 /*
17  * Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
18  * Created: 2011-09-29
19  * Time-stamp: <2011-09-29 14:18:07 (hauspie)>
20  */
24 #ifndef __RFLPC_PROFILING_H__
25 #define __RFLPC_PROFILING_H__
26 
31 #ifdef RFLPC_CONFIG_ENABLE_PROFILING
32 
33 #include "drivers/timer.h"
34 
35 #ifndef RFLPC_PROFILE_PRESCALE
36 
38  #define RFLPC_PROFILE_PRESCALE (rflpc_clock_get_system_clock() / 1000000)
39 #endif
40 
48 #define RFLPC_PROFILE_INIT(timer) do {rflpc_timer_enable(timer); rflpc_timer_set_clock(timer, RFLPC_CCLK); rflpc_timer_set_pre_scale_register(timer,RFLPC_PROFILE_PRESCALE); rflpc_timer_start(timer); } while(0)
49 
53 #define RFLPC_PROFILE_DECLARE_COUNTER(counter) volatile uint32_t rflpc_profile_total_##counter; volatile uint32_t rflpc_profile_start_##counter;
54 
58 #define RFLPC_PROFILE_DECLARE_EXTERN_COUNTER(counter) extern volatile uint32_t rflpc_profile_total_##counter;extern volatile uint32_t rflpc_profile_start_##counter;
59 
61 #define RFLPC_PROFILE_START_COUNTER(counter,timer) do { rflpc_profile_start_##counter = rflpc_timer_get_counter(timer);} while(0)
62 
64 #define RFLPC_PROFILE_STOP_COUNTER(counter,timer) do { rflpc_profile_total_##counter += rflpc_timer_get_counter(timer) - rflpc_profile_start_##counter;} while(0)
65 
67 #define RFLPC_PROFILE_GET_TOTAL(counter) rflpc_profile_total_##counter
68 
69 #endif
70 
71 #endif
TIMER0/1/2/3 device driver.