home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/nodes.h>
- #include <exec/lists.h>
- #include <exec/memory.h>
- #include <utility/tagitem.h>
- #include <powerup/ppclib/interface.h>
- #include <powerup/ppclib/time.h>
- #include <powerup/gcclib/powerup_protos.h>
-
- double Test=66346667;
-
- int main(void)
- {
- long long Result;
- long long Ticks;
- long long TicksPerSec;
- void *MyTimerObject;
- void *MyTimerJob;
- ULONG b;
- int i;
- struct TagItem MyTags[4];
- ULONG MySignal;
-
- MyTags[0].ti_Tag = PPCTIMERTAG_CPU;
- MyTags[0].ti_Data = TRUE;
- MyTags[1].ti_Tag = TAG_END;
- if (MyTimerObject=PPCCreateTimerObject(MyTags))
- {
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_START,
- NULL);
-
- /* Do something silly
- * to get the context switch delay
- */
- PPCOutput();
-
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_STOP,
- NULL);
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_TICKSPERSEC,
- &TicksPerSec);
-
- PPCprintf("TicksPerSec %Ld\n",TicksPerSec);
-
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_START,
- &Result);
-
- PPCprintf("StartTicks 0x%Lx\n",Result);
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_STOP,
- &Result);
-
- PPCprintf("StopTicks 0x%Lx\n",Result);
-
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_CURRENTTICKS,
- &Result);
- PPCprintf("Current 0x%Lx\n",Result);
-
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFTICKS,
- &Result);
- PPCprintf("DiffTicks %Ld\n",Result);
-
-
- PPCprintf("PPCOutput() context switch took %4g seconds\n",
- (((double) (Result) / (double)TicksPerSec)));
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFMICRO,
- &Result);
- PPCprintf("DiffMicro %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFSECS,
- &Result);
- PPCprintf("DiffSecs %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFMINS,
- &Result);
- PPCprintf("DiffMins %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFHOURS,
- &Result);
- PPCprintf("DiffHours %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFDAYS,
- &Result);
- PPCprintf("DiffDays %Ld\n",Result);
-
-
- PPCprintf("Use 50Hz Timer to wait 4 seconds\n");
-
- if ((MySignal=PPCAllocSignal(-1)) != -1)
- {
- MyTags[0].ti_Tag = PPCTIMERTAG_50HZ;
- MyTags[0].ti_Data = 50*4;
- MyTags[1].ti_Tag = PPCTIMERTAG_SIGNALMASK;
- MyTags[1].ti_Data = 1<<MySignal;
- /* Remove the job out of the timer notify list
- * after the signal
- */
- MyTags[2].ti_Tag = PPCTIMERTAG_AUTOREMOVE;
- MyTags[2].ti_Data = TRUE;
- MyTags[3].ti_Tag = TAG_END;
-
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_START,
- NULL);
-
- if (MyTimerJob=PPCCreateTimerObject(MyTags))
- {
- PPCWait(1<<MySignal);
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_STOP,
- NULL);
-
- PPCprintf("notification received\n");
-
- PPCprintf("Restart 4 second timers\n");
-
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_START,
- NULL);
-
- PPCSetTimerObject(MyTimerJob,
- PPCTIMERTAG_START,
- NULL);
-
- PPCWait(1<<MySignal);
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_STOP,
- NULL);
-
- PPCprintf("notification received\n");
-
- PPCDeleteTimerObject(MyTimerJob);
-
-
- PPCprintf("Use new 50Hz Timer to wait again 4 seconds\n");
-
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_START,
- NULL);
-
- if (MyTimerJob=PPCCreateTimerObject(MyTags))
- {
- PPCWait(1<<MySignal);
- PPCSetTimerObject(MyTimerObject,
- PPCTIMERTAG_STOP,
- NULL);
-
- PPCprintf("notification received\n");
- PPCDeleteTimerObject(MyTimerJob);
- }
-
-
-
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFTICKS,
- &Ticks);
-
- PPCprintf("DiffTicks %Ld\n",Ticks);
- #if 0
- // asm("twi 31,0,0");
- PPCprintf("waited for %g(float) seconds\n",
- ((double) Ticks) / (double) TicksPerSec);
- #else
- PPCprintf("waited for %g %g %g(float) %ld(int) seconds\n",
- (double) 66346667,
- (double) Ticks,
- ((double) Ticks) / (double) TicksPerSec,
- Ticks / TicksPerSec);
- #endif
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFMICRO,
- &Result);
- PPCprintf("DiffMicro %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFSECS,
- &Result);
- PPCprintf("DiffSecs %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFMINS,
- &Result);
- PPCprintf("DiffMins %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFHOURS,
- &Result);
- PPCprintf("DiffHours %Ld\n",Result);
-
-
- PPCGetTimerObject(MyTimerObject,
- PPCTIMERTAG_DIFFDAYS,
- &Result);
- PPCprintf("DiffDays %Ld\n",Result);
-
- }
- PPCFreeSignal(MySignal);
- }
- else
- {
- PPCprintf("Couldn`t alloc Signal\n");
- }
-
- PPCDeleteTimerObject(MyTimerObject);
- }
- }
-
-