pif.c 1.66 KB
#include <os.h>
#include <rmon.h>
#include <rcp.h>
#include "ostime.h"

#define	NUM_MESSAGE	3

static OSMesgQueue	intMesgQueue;
static OSMesg		intMesgBuf[NUM_MESSAGE];
static OSContStatus	sdata[MAXCONTROLLERS];
static OSContPad	rdata[MAXCONTROLLERS];

int
pif(void)
{
    OSIntMask savedMask, currentMask;
    OSMesg actualMesg, expectedMesg;
    int i;
    int retValue;
    int numFailures = 0;
     u8 pattern;
    int j=0;
    int k=0;
    OSTime t1, t2;
    
    /*
     * Create a single message queue and associate three
     * interrupt events with it.
     */
    osCreateMesgQueue(&intMesgQueue, intMesgBuf, NUM_MESSAGE);
    osSetEventMesg(OS_EVENT_SI, &intMesgQueue, (OSMesg)0x33333333);

    osContInit(&intMesgQueue, &pattern, &sdata[0]);
    for (i = 0;i < MAXCONTROLLERS; i++) {
		rmonPrintf("pattern 0x%x controller %d error 0x%x type 0x%x status 0x%x \n",
		pattern, i, sdata[i].errno, sdata[i].type, sdata[i].status);
    }

    for (k = 1;k <= MAXCONTROLLERS; k++) {
	rmonPrintf(" %d Controllers \n", k);
#ifndef _HW_VERSION_1
	osContSetCh(k);
#endif
	j = 0;
	    while(j++ < 10) {
		    osContStartReadData(&intMesgQueue);
		    (void) osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_BLOCK);
		    osContGetReadData(&rdata[0]);
		    for (i = 0;i < k; i++) {
				rmonPrintf("controller %d error 0x%x button 0x%x stick_x 0x%x stick_y 0x%x\n",
				i, rdata[i].errno,
				rdata[i].button, rdata[i].stick_x, rdata[i].stick_y);
		    }
	    }
	}
    osContReset(&intMesgQueue, &sdata[0]);
    for (i = 0;i < MAXCONTROLLERS; i++) {
	    rmonPrintf("error 0x%x type 0x%x status 0x%x \n",
	    sdata[i].errno,
	    sdata[i].type, sdata[i].status);
    }
    
    return(numFailures);
}