User guide
CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 99
#define TIFR_SET_1 0x01
#define TIFR_SET_2 0x02
#define TIFR_SET_ALL (TIFR_SET_1 | TIFR_SET_2)
#define MATCH1_REGISTER 0 //array index
#define MATCH2_REGISTER 1 //array index
Defining the Callback Data Structure
Define the following data structure immediately after the typedef for the instance struct,
outside of the instance struct definition.
Add the following code immediately after the line:
typedef struct sInstanceData tInstanceData;
CODE BEGINS
/*
** Timer callback data structure.
*/
struct sTimerCallbackData
{
tInstanceData *IP;
tWord32 MatchRegisterN;
};
typedef struct sTimerCallbackData tTimerCallbackData;
CODE ENDS
Adding the Callback and Helper Function Prototypes
At the end of the SimpleTimer.h file, immediately before the line:
#endif /* __SimpleTimer_H */
add the following code:
CODE BEGINS
/*
** Callback and helper function prototypes
*/
static void Match(void *p);
static void Unmatch(void *p);
static void SetupNextMatch(tInstanceData *IP, const tInt32 MatchRegisterN);
static void ClearMatchInterrupts(const tInstanceData *IP, const tWord32
Mask);
CODE ENDS
Declaring Instance Data Input and Output Port Handles
When creating the default SimpleTimer.h file, CoMET automatically creates Port handles for
the default Ports. These can be found within the sInstanceData structure.