1
- // FIXME
2
1
const int programPin=3 ;
3
2
const int readPin=4 ;
4
3
const int enablePin=2 ;
5
4
6
5
const unsigned long romSize=1024 *1024 ;
7
6
8
7
9
- // The pinout from the eprom is different from the snes pinout
10
- int adrPins[20 ]={22 ,// eprom A0 snes A0
11
- 23 ,// eprom A1 snes A1
12
- 24 ,// eprom A2 snes A2
13
- 25 ,// eprom A3 snes A3
14
- 26 ,// eprom A4 snes A4
15
- 27 ,// eprom A5 snes A5
16
- 28 ,// eprom A6 snes A6
17
- 29 ,// eprom A7 snes A7
18
- 30 ,// eprom A8 snes A8
19
- 31 ,// eprom A9 snes A9
20
- 32 ,// eprom A10 snes A10
21
- 33 ,// eprom A11 snes A11
22
- 34 ,// eprom A12 snes A12
23
- 35 ,// eprom A13 snes A13
24
- 36 ,// eprom A14 snes A14
25
- 37 ,// eprom A15 snes A15
26
- 40 ,// 38,//eprom A16 snes A18 *
27
- 41 ,// 39,//eprom A17 snes A19 *
28
- 38 ,// 40,//eprom A18 snes A16 *
29
- 39 ,// 41 //eprom A19 snes A17 *
30
- };
31
-
32
- char dataPins[8 ]={5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 };
33
- /*
34
- Frame Format
35
- program:
36
- |preamble|opt|addr0|addr1|addr2|numbbutes|bytes|checksum|end
37
- read:
38
- |preamble|opt|addr0|addr1|addr2|numbbutes|end
39
-
8
+ // The pinout from the eprom is different from the snes pinout
9
+ int adrPins[20 ]={22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 };
40
10
41
- */
11
+ char dataPins[ 8 ]={ 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 };
42
12
byte inByte=0 ;
43
13
unsigned int secH=0 ,secL=0 ;
44
14
@@ -47,19 +17,15 @@ void setup() {
47
17
pinMode (programPin,OUTPUT);
48
18
pinMode (readPin,OUTPUT);
49
19
pinMode (enablePin,OUTPUT);
50
- // FIXME
51
20
for (int i=0 ;i<20 ;i++){
52
21
pinMode (adrPins[i],OUTPUT);
53
- }
22
+ }
54
23
digitalWrite (programPin,LOW);
55
24
digitalWrite (readPin,LOW);
56
25
digitalWrite (enablePin,HIGH);
57
26
Serial.begin (230400 );
58
27
delay (1000 );
59
28
programMode ();
60
- // setAddress(0);
61
- // programByte(0x78);
62
- // //writeSector(5);
63
29
}
64
30
int index=0 ;
65
31
void loop () {
@@ -101,12 +67,9 @@ void readMode(){
101
67
for (int i=0 ;i<8 ;i++){
102
68
pinMode (dataPins[i],INPUT);
103
69
}
104
- // for(int i=0;i<8;i++){
105
- // digitalWrite(dataPins[i],HIGH);
106
- // }
107
70
digitalWrite (programPin,LOW);
108
71
digitalWrite (readPin,LOW);
109
-
72
+
110
73
}
111
74
void setAddress (uint32_t Addr){
112
75
for (int i=0 ;i<8 ;i++){
@@ -139,9 +102,6 @@ void setData(char Data){
139
102
}
140
103
}
141
104
void programByte (byte Data){
142
- // select address
143
- //
144
- // setAddress(adr);
145
105
setData (Data);
146
106
// Vpp pulse
147
107
delayMicroseconds (4 );
@@ -155,7 +115,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
155
115
unsigned long address=0 ;
156
116
byte CHK=sectorH,CHKreceived;
157
117
CHK^=sectorL;
158
-
118
+
159
119
address=sectorH;
160
120
address=(address<<8 )|sectorL;
161
121
address*=128 ;
@@ -168,7 +128,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
168
128
while (Serial.available ()==0 );
169
129
CHKreceived=Serial.read ();
170
130
programMode ();
171
- // only program the bytes if the checksum is equal to the one received
131
+ // only program the bytes into eprom if the checksum is equal to the one received
172
132
if (CHKreceived==CHK){
173
133
for (int i = 0 ; i < 128 ; i++){
174
134
setAddress (address++);
@@ -177,7 +137,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
177
137
Serial.write (CHK);
178
138
}
179
139
readMode ();
180
-
140
+
181
141
}
182
142
int readROM (){
183
143
unsigned long num=1024 *1024 ;
@@ -195,9 +155,7 @@ int readROM(){
195
155
// checksum^=data;
196
156
}
197
157
digitalWrite (readPin,HIGH);
198
-
158
+
199
159
// Serial.write(checksum);
200
160
// Serial.write(0xAA);
201
161
}
202
-
203
-
0 commit comments