timer3.c
2.16 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <os.h>
#include <R4300.h>
#include <rcp.h>
#include "rmon.h"
#include "osprof.h"
#define INTERVAL OS_USEC_TO_CYCLES(100)
/*
* Timer
*
* Tests for:
* osGetTime
* osSetTime
* osSetTimer
* osStopTimer
*
* Assumed working:
* osCreateMesgQueue
* osRecvMesg
*
* Description:
*
* Setup interval timer and check that the message is
* delivered when timer expire
* Call osGetTime to check that we do get message in specified
* interval time
*/
static OSTimer mytimer;
static OSMesgQueue timerMesgQueue;
static OSMesg timerMesgBuf;
int
timer3(void)
{
int i=0;
int j;
OSTime t1, t2;
int numFailures = 0;
OSMesg actualMesg;
int retValue;
OSTime t;
osCreateMesgQueue(&timerMesgQueue, &timerMesgBuf, 2);
osSetTimer(&mytimer, 0, INTERVAL, &timerMesgQueue, &timerMesgBuf);
while (i++ < 15) {
t1 = osGetTime();
(void)osRecvMesg(&timerMesgQueue, &actualMesg, OS_MESG_BLOCK);
t2 = osGetTime();
if ((t2 - t1) > (OS_CYCLES_TO_NSEC(INTERVAL)+500)) {
rmonPrintf("timer3: miss interval timer. t2 0x%x t1 0x%x\n",
t2, t1);
numFailures++;
}
if (&timerMesgBuf != actualMesg) {
rmonPrintf("timer3: expected message 0x%x, actual 0x%x\n",
&timerMesgBuf, actualMesg);
numFailures++;
}
}
retValue = osStopTimer(&mytimer);
if (retValue) {
rmonPrintf("timer3: osStopTimer failed\n");
numFailures++;
}
for(t = 0xffffff00, j = 0; j < 20; j++, t = t + 0xfffff) {
osSetTime(t);
osSetTimer(&mytimer, 0, INTERVAL, &timerMesgQueue, &timerMesgBuf);
while (i++ < 15) {
t1 = osGetTime();
(void)osRecvMesg(&timerMesgQueue, &actualMesg, OS_MESG_BLOCK);
t2 = osGetTime();
if ((t2 - t1) > (OS_CYCLES_TO_NSEC(INTERVAL)+500)) {
rmonPrintf("timer3: miss interval timer. t2 0x%x t1 0x%x\n",
t2, t1);
numFailures++;
}
if (&timerMesgBuf != actualMesg) {
rmonPrintf("timer3: expected message 0x%x, actual 0x%x\n",
&timerMesgBuf, actualMesg);
numFailures++;
}
}
retValue = osStopTimer(&mytimer);
if (retValue) {
rmonPrintf("timer3: osStopTimer failed\n");
numFailures++;
}
}
return(numFailures);
}