eep_test.c
2.41 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
/*---------------------------------------------------------------------*
Copyright (C) 1997 Nintendo. (Originated by SGI)
$RCSfile: eep_test.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/05/02 03:27:20 $
*---------------------------------------------------------------------*/
#include <ultra64.h>
#include "thread.h"
#include "textlib.h"
extern OSMesgQueue retraceMessageQ;
extern OSMesgQueue pifMesgQueue;
extern u8 err_mes[];
void
eep_test(void)
{
s32 ret = 0;
int i;
u8 long_buffer[EEPROM_MAXBLOCKS * EEPROM_BLOCK_SIZE];
int error;
mes_init(err_mes);
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) {
mes_add("EEPROM long write success \n");
} else {
mes_add("EEPROM 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++;
}
}
if (error == 0) {
mes_add("\tEEPROM long read success \n");
} else {
mes_add("\tEEPROM long read error \n");
}
} else {
mes_add("\tEEPROM long read fail: \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 < EEPROM_MAXBLOCKS ; 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
draw_puts("\t\n");
}