kerneltest/e32test/system/d_tick.cpp
changeset 133 2a0ada0a1bf8
parent 0 a41df078684a
--- a/kerneltest/e32test/system/d_tick.cpp	Mon May 10 11:40:53 2010 +0100
+++ b/kerneltest/e32test/system/d_tick.cpp	Wed May 12 10:34:10 2010 +0100
@@ -37,6 +37,8 @@
 #include <rvemuboard.h>
 #elif defined(__NE1_TB__)
 #include <upd35001_timer.h>
+#elif defined(__MRAP__)
+#include <rap.h>
 #endif
 #include <kernel/kern_priv.h>
 #include "d_tick.h"
@@ -78,6 +80,11 @@
 inline TCounter TIMER()
 	{ return NETimer::Timer(2).iTimerCount; }
 #endif
+#ifdef __MRAP__
+inline TCounter TIMER()
+	{ TRap::SetRegister32(1, KRapRegRTC001_TRIGGER);
+	return  TRap::Register32(KRapRegRTC001_LONGCOUNT); }
+#endif
 #if defined(__EPOC32__) && defined(__CPU_X86)
 TCounter TIMER();
 void SetUpTimerChannel2();
@@ -90,6 +97,12 @@
 	return c.QuadPart;
 	}
 #endif
+#if defined(__MRAP__)
+inline TDelta TimeDelta(TCounter initial, TCounter final)
+	{ return final-initial; }				// RAP RTC timer counts up
+inline TInt LongTimeDelta(TCounter initial, TCounter final, TUint, TUint)
+	{ return final-initial; }				// RAP RTC timer counts up
+#endif
 
 #if defined(__MISA__) || defined(__MCOT__)
 inline TDelta TimeDelta(TCounter initial, TCounter final)
@@ -211,6 +224,15 @@
 	x /= TUint64(f);
 	return (TUint)x;
 #endif
+#if defined(__MRAP__)
+    // RTC runs with 32.768 kHz -> one tick is 
+    const TUint KRTCClockHz = 32768;
+    Int64 ticks(aTicks);
+    ticks*=(1000000);
+	ticks+=KRTCClockHz/2;		// 32.768 kHz tick
+	ticks/=KRTCClockHz;
+	return (TInt)ticks;
+#endif
 #if defined(__MAWD__) || defined(__MEIG__)
 	return aTicks*500;					// 2kHz tick
 #endif
@@ -589,6 +611,9 @@
 #if defined(__NE1_TB__)
 	// nothing to do since we use fast counter
 #endif
+#if defined(__MRAP__)
+	// nothing to do here RTC runs with 32.768 kHz
+#endif
 #ifdef __MAWD__
 	// Set up timer 1 as free running 2kHz clock
 	TWind::SetBuzzerControl(0);		// disable buzzer