From ba78bd9ba834260d035a9830726afc34fdad2a15 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 18 Oct 2009 23:32:54 +0200 Subject: import firmware from LEGO v1.05 --- AT91SAM7S256/Source/d_timer.r | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 AT91SAM7S256/Source/d_timer.r (limited to 'AT91SAM7S256/Source/d_timer.r') diff --git a/AT91SAM7S256/Source/d_timer.r b/AT91SAM7S256/Source/d_timer.r new file mode 100644 index 0000000..91e9f7b --- /dev/null +++ b/AT91SAM7S256/Source/d_timer.r @@ -0,0 +1,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 +#include + +#define TIMERInit timeBeginPeriod(1); + +#define TIMERRead(V) (V) = timeGetTime(); + +#define TIMERExit timeEndPeriod(1); + +#endif //_WINDOWS -- cgit v1.2.3