summaryrefslogtreecommitdiff
path: root/AT91SAM7S256/Source/d_timer.r
blob: 91e9f7bc56ae69032884270dcb2e53419a577989 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Date init       14.12.2004
//
// Revision date   $Date:: 16-05-06 10:18                                    $
//
// Filename        $Workfile:: d_timer.r                                     $
//
// Version         $Revision:: 11                                            $
//
// Archive         $Archive:: /LMS2006/Sys01/Main/Firmware/Source/d_timer.r  $
//
// Platform        C
//


#ifdef    SAM7S256


#define   MS_1_TIME         ((OSC/16)/1000)

static    ULONG TimerValue;
static    ULONG Timer1mS;

/* PIT timer is used as main timer - timer interval is 1mS */

#define   TIMERInit                     TimerValue = ((*AT91C_PITC_PIIR) & AT91C_PITC_CPIV);\
                                        Timer1mS   = 0

#define   TIMERRead(V)                  if (MS_1_TIME < ((((*AT91C_PITC_PIIR) & AT91C_PITC_CPIV) - TimerValue) & AT91C_PITC_CPIV))\
                                        {\
                                          TimerValue += MS_1_TIME;\
                                          TimerValue &= AT91C_PITC_CPIV;\
                                          Timer1mS++;\
                                        }\
                                        V = Timer1mS

#define   TIMERExit



#endif //SAM7S256



#ifdef    _WINDOWS

#include <windows.h>
#include <mmsystem.h>

#define TIMERInit     timeBeginPeriod(1);

#define TIMERRead(V)  (V) = timeGetTime();

#define TIMERExit     timeEndPeriod(1);

#endif //_WINDOWS