kerneltest/e32test/system/d_tick.cpp
changeset 152 657f875b013e
parent 0 a41df078684a
equal deleted inserted replaced
139:95f71bcdcdb7 152:657f875b013e
    35 #include "nk_priv.h"
    35 #include "nk_priv.h"
    36 #elif defined(__RVEMUBOARD__)
    36 #elif defined(__RVEMUBOARD__)
    37 #include <rvemuboard.h>
    37 #include <rvemuboard.h>
    38 #elif defined(__NE1_TB__)
    38 #elif defined(__NE1_TB__)
    39 #include <upd35001_timer.h>
    39 #include <upd35001_timer.h>
       
    40 #elif defined(__MRAP__)
       
    41 #include <rap.h>
    40 #endif
    42 #endif
    41 #include <kernel/kern_priv.h>
    43 #include <kernel/kern_priv.h>
    42 #include "d_tick.h"
    44 #include "d_tick.h"
    43 #include "../misc/prbs.h"
    45 #include "../misc/prbs.h"
    44 
    46 
    76 #endif
    78 #endif
    77 #if defined(__NE1_TB__)
    79 #if defined(__NE1_TB__)
    78 inline TCounter TIMER()
    80 inline TCounter TIMER()
    79 	{ return NETimer::Timer(2).iTimerCount; }
    81 	{ return NETimer::Timer(2).iTimerCount; }
    80 #endif
    82 #endif
       
    83 #ifdef __MRAP__
       
    84 inline TCounter TIMER()
       
    85 	{ TRap::SetRegister32(1, KRapRegRTC001_TRIGGER);
       
    86 	return  TRap::Register32(KRapRegRTC001_LONGCOUNT); }
       
    87 #endif
    81 #if defined(__EPOC32__) && defined(__CPU_X86)
    88 #if defined(__EPOC32__) && defined(__CPU_X86)
    82 TCounter TIMER();
    89 TCounter TIMER();
    83 void SetUpTimerChannel2();
    90 void SetUpTimerChannel2();
    84 #endif
    91 #endif
    85 #ifdef __WINS__
    92 #ifdef __WINS__
    87 	{
    94 	{
    88 	LARGE_INTEGER c;
    95 	LARGE_INTEGER c;
    89 	QueryPerformanceCounter(&c);
    96 	QueryPerformanceCounter(&c);
    90 	return c.QuadPart;
    97 	return c.QuadPart;
    91 	}
    98 	}
       
    99 #endif
       
   100 #if defined(__MRAP__)
       
   101 inline TDelta TimeDelta(TCounter initial, TCounter final)
       
   102 	{ return final-initial; }				// RAP RTC timer counts up
       
   103 inline TInt LongTimeDelta(TCounter initial, TCounter final, TUint, TUint)
       
   104 	{ return final-initial; }				// RAP RTC timer counts up
    92 #endif
   105 #endif
    93 
   106 
    94 #if defined(__MISA__) || defined(__MCOT__)
   107 #if defined(__MISA__) || defined(__MCOT__)
    95 inline TDelta TimeDelta(TCounter initial, TCounter final)
   108 inline TDelta TimeDelta(TCounter initial, TCounter final)
    96 	{ return final-initial; }				// SA1100 timer counts up
   109 	{ return final-initial; }				// SA1100 timer counts up
   208 	TUint64 x = I64LIT(1000000);
   221 	TUint64 x = I64LIT(1000000);
   209 	x *= TUint64(aTicks);
   222 	x *= TUint64(aTicks);
   210 	x += TUint64(f>>1);
   223 	x += TUint64(f>>1);
   211 	x /= TUint64(f);
   224 	x /= TUint64(f);
   212 	return (TUint)x;
   225 	return (TUint)x;
       
   226 #endif
       
   227 #if defined(__MRAP__)
       
   228     // RTC runs with 32.768 kHz -> one tick is 
       
   229     const TUint KRTCClockHz = 32768;
       
   230     Int64 ticks(aTicks);
       
   231     ticks*=(1000000);
       
   232 	ticks+=KRTCClockHz/2;		// 32.768 kHz tick
       
   233 	ticks/=KRTCClockHz;
       
   234 	return (TInt)ticks;
   213 #endif
   235 #endif
   214 #if defined(__MAWD__) || defined(__MEIG__)
   236 #if defined(__MAWD__) || defined(__MEIG__)
   215 	return aTicks*500;					// 2kHz tick
   237 	return aTicks*500;					// 2kHz tick
   216 #endif
   238 #endif
   217 #if defined(__EPOC32__) && defined(__CPU_X86)
   239 #if defined(__EPOC32__) && defined(__CPU_X86)
   587 	TRvEmuBoard::EnableTimer(KHwCounterTimer1, TRvEmuBoard::EEnable);
   609 	TRvEmuBoard::EnableTimer(KHwCounterTimer1, TRvEmuBoard::EEnable);
   588 #endif
   610 #endif
   589 #if defined(__NE1_TB__)
   611 #if defined(__NE1_TB__)
   590 	// nothing to do since we use fast counter
   612 	// nothing to do since we use fast counter
   591 #endif
   613 #endif
       
   614 #if defined(__MRAP__)
       
   615 	// nothing to do here RTC runs with 32.768 kHz
       
   616 #endif
   592 #ifdef __MAWD__
   617 #ifdef __MAWD__
   593 	// Set up timer 1 as free running 2kHz clock
   618 	// Set up timer 1 as free running 2kHz clock
   594 	TWind::SetBuzzerControl(0);		// disable buzzer
   619 	TWind::SetBuzzerControl(0);		// disable buzzer
   595 	TWind::SetTimer1Control(KWindTimer1ControlTimerEnable);
   620 	TWind::SetTimer1Control(KWindTimer1ControlTimerEnable);
   596 	TWind::SetTimer1Load(0);
   621 	TWind::SetTimer1Load(0);