/********************************************************************** * * * FILE NAME: profiler.h * * * * DESCRIPTION: This file contains the structures and definitions * * needed to include and use the profiler in your * * existing program. * * * * DETAILS: * * Include this file in your main.c and call * * profileInitialize to start the timer that will accumulate * * the profile stats. * * * ************************************************************************/ /********************************************************************* Revision History 1.0 [no date] Initial Version 1.1 2006-11-16 Added extensive comments and removed an erroneous pad in the PROFILER structure. *********************************************************************/ #ifndef _PROFILER_H #define _PROFILER_H // Define the functions within this library that can be called // by the parent process void profileInitialize ( void ); // Define the constants used in this library. #define PROF_MAX_PTS 14 // Number of address points to accumulate. #define PROF_MAX_TOL 32 // The range of addresses that will be attributed to a specific address point #define PROF_DELAY 2000 // This is the initial delay (in ms) to wait before accumulating data. // Define the port number and output pins used by this libary. If they conflict with // the parent process, they can easily be changed here and will be picked up by the // library on the next compile. #define PROFILER_PORT p10 #define PROFILER_PORT_DIR pd10 #define PROFILER_PORT_PIN_IRQ p10_2 #define PROFILER_PORT_PIN_OUT p10_3 // Define the timer used by this library. If this timer conflicts with the parent process, // it can be changed here and will be picked up by the library on the next compile. #define PROFILER_TIMER_REG tb0mr #define PROFILER_TIMER tb0 #define PROFILER_TIMER_IC tb0ic #define PROFILER_TIMER_START tb0s // This is the global structure used to store the accumulated address information // and frequency. Upon reporting the information stored, it is cleared. typedef struct { unsigned long Samples; // Total number of samples accumulated. unsigned long Delay; // Counter for the initial data accumulation delay. unsigned int Points; // Total number of distinct data points accumulated. unsigned int Sort; // Counter to periodically sort (by frequency of occurrence) the accumulated data points struct { unsigned long addr; // Program counter contents prior to the interrupt to the data accumulation function. unsigned long cnt; // Counter for the number of times the addr +/- the tolerance was encountered. } Point[PROF_MAX_PTS]; } PROFILER; #endif