aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/Source/d_timer.c
blob: cba73d03eda2cd2c206e51fd2c1423c87b62a958 (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
57
58
59
60
61
62
//
// Date init       14.12.2004
//
// Revision date   $Date: 23-04-08 11:15 $
//
// Filename        $Workfile:: d_timer.c                                     $
//
// Version         $Revision: 2 $
//
// Archive         $Archive:: /LMS2006/Sys01/Main_V02/Firmware/Source/d_time $
//
// Platform        C
//


#include  "stdconst.h"
#include  "m_sched.h"
#include  "d_timer.h"
#include  "d_timer.r"


void      dTimerInit(void)
{
  TIMERInit;
}


ULONG     dTimerRead(void)
{
  ULONG   V;

  TIMERReadAlt(V)
  return (V);
}

ULONG     dTimerReadNoPoll(void)
{
  return (Timer1mS);
}

ULONG     dTimerReadHiRes(void)
{

//  return ((*AT91C_PITC_PIIR)/3); following code is equivalent and about five times faster, see Hacker's Delight or exact division
  ULONG tmp= ((*AT91C_PITC_PIIR)*2863311531);
  if(tmp > 2863311531)
    return tmp - 2863311531;
  else if(tmp > 1431655766)
    return tmp - 1431655766;
  else
    return tmp;
}

ULONG dTimerGetNextMSTickCnt(void) {
  return NextTimerValue;
}

void      dTimerExit(void)
{
  TIMERExit;
}