main.c
3.43 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include <ultra64.h>
#include "thread.h"
#include "textlib.h"
extern u16 *bitmap_buf;
extern u16 bitmap_buf1[];
extern u16 bitmap_buf2[];
OSPfs pfs0;
#define NUM_MESSAGE 1
OSMesgQueue pifMesgQueue;
OSMesg dummyMessage, pifMesgBuf[NUM_MESSAGE];
static OSContStatus sdata[MAXCONTROLLERS];
extern OSMesgQueue retraceMessageQ;
void
mainproc(void *arg)
{
int error = 0;
s32 ret = 0;
u8 p;
int i;
u8 test_buffer[EEPROM_BLOCK_SIZE];
u8 long_buffer[EEPROM_MAXBLOCKS * EEPROM_BLOCK_SIZE];
static OSContPad rdata[MAXCONTROLLERS];
osCreateMesgQueue(&pifMesgQueue, pifMesgBuf, NUM_MESSAGE);
osSetEventMesg(OS_EVENT_SI, &pifMesgQueue, dummyMessage);
osContInit(&pifMesgQueue, &p, &sdata[0]);
init_draw();
draw_char('n');
while (1) {
u8 no;
ret = osEepromProbe(&pifMesgQueue);
if (p)
osContStartReadData(&pifMesgQueue);
setcolor(0xa0,0xf0,0x80);
if (ret) {
draw_puts("\f\n\n\n\n\t");
draw_puts(" probe success\n");
#ifdef jean
for(no = 0 ; no < EEPROM_MAXBLOCKS ; no++) {
for (i = 0 ; i < EEPROM_BLOCK_SIZE; i++)
test_buffer[i] = no;
ret = osEepromWrite(&pifMesgQueue, no,
test_buffer);
if (ret == 0) {
setcolor(0xa0,0x20,0x80);
draw_puts("\t\t\twrite success: ");
draw_ushort(no);
draw_char('\n');
} else {
setcolor(0xa0,0x20,0x80);
draw_puts("\t\t\twrite fail: ");
draw_ushort(no);
draw_char('\n');
}
}
for(no = 0 ; no < 10 ; no++) {
int error = 0;
ret = 0;
ret = osEepromRead(&pifMesgQueue, no,
test_buffer);
if (ret == 0) {
error = 0;
for (i = 0 ; i < EEPROM_BLOCK_SIZE; i++){
if (test_buffer[i] != no) {
error++;
}
}
setcolor(0xa0,0x20,0x80);
if (error == 0) {
draw_puts("\t\t\t\t\t\tread success: ");
draw_ushort(no);
draw_char('\n');
} else {
draw_puts("\t\t\t\t\t\tread error: ");
draw_ushort(no);
draw_char('\n');
}
} else {
setcolor(0xa0,0x20,0x80);
draw_puts("\t\t\t\t\t\t\read fail: ");
draw_ushort(no);
draw_char('\n');
}
}
#endif
for (i = 0; i < EEPROM_BLOCK_SIZE * EEPROM_MAXBLOCKS; i++) {
long_buffer[i] = i & 0xff;
}
ret = osEepromLongWrite(&pifMesgQueue, 0, long_buffer, EEPROM_BLOCK_SIZE * EEPROM_MAXBLOCKS);
if (ret == 0) {
setcolor(0xa0,0x20,0x80);
draw_puts("\t long write success \n");
} else {
setcolor(0xa0,0x20,0x80);
draw_puts("\t long write fail: \n");
}
ret = osEepromLongRead(&pifMesgQueue, 0, long_buffer,EEPROM_BLOCK_SIZE * EEPROM_MAXBLOCKS);
if (ret == 0) {
error = 0;
for (i = 0; i < EEPROM_BLOCK_SIZE * EEPROM_MAXBLOCKS; i++) {
if (long_buffer[i] != (i & 0xff)) {
error++;
}
}
setcolor(0xa0,0x20,0x80);
if (error == 0)
draw_puts("\t long read success \n");
else
draw_puts("\t long read error \n");
} else {
setcolor(0xa0,0x20,0x80);
draw_puts("\t long read fail: \n");
}
} else{
draw_puts("\f\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t");
draw_puts(" probe fail\n");
v_sync_double_buffer(&retraceMessageQ);
draw_puts("\f\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t");
draw_puts(" probe fail\n");
}
if (p) {
osRecvMesg(&pifMesgQueue, NULL, OS_MESG_BLOCK);
osContGetReadData(&rdata[0]);
draw_puts("\f\n\tbutton: ");
draw_ushort(rdata[0].button);
}
v_sync_double_buffer(&retraceMessageQ);
clear_draw();
}
for (;;);
}