Skip to content

Commit 73c458b

Browse files
committed
fixed pinout
1 parent ec89c8f commit 73c458b

File tree

2 files changed

+9
-61
lines changed

2 files changed

+9
-61
lines changed

Arduino sketch/eprom/eprom.ino

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,14 @@
1-
//FIXME
21
const int programPin=3;
32
const int readPin=4;
43
const int enablePin=2;
54

65
const unsigned long romSize=1024*1024;
76

87

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};
4010

41-
*/
11+
char dataPins[8]={5,6,7,8,9,10,11,12};
4212
byte inByte=0;
4313
unsigned int secH=0,secL=0;
4414

@@ -47,19 +17,15 @@ void setup() {
4717
pinMode(programPin,OUTPUT);
4818
pinMode(readPin,OUTPUT);
4919
pinMode(enablePin,OUTPUT);
50-
//FIXME
5120
for(int i=0;i<20;i++){
5221
pinMode(adrPins[i],OUTPUT);
53-
}
22+
}
5423
digitalWrite(programPin,LOW);
5524
digitalWrite(readPin,LOW);
5625
digitalWrite(enablePin,HIGH);
5726
Serial.begin(230400);
5827
delay(1000);
5928
programMode();
60-
// setAddress(0);
61-
// programByte(0x78);
62-
// //writeSector(5);
6329
}
6430
int index=0;
6531
void loop() {
@@ -101,12 +67,9 @@ void readMode(){
10167
for(int i=0;i<8;i++){
10268
pinMode(dataPins[i],INPUT);
10369
}
104-
// for(int i=0;i<8;i++){
105-
// digitalWrite(dataPins[i],HIGH);
106-
// }
10770
digitalWrite(programPin,LOW);
10871
digitalWrite(readPin,LOW);
109-
72+
11073
}
11174
void setAddress(uint32_t Addr){
11275
for(int i=0;i<8;i++){
@@ -139,9 +102,6 @@ void setData(char Data){
139102
}
140103
}
141104
void programByte(byte Data){
142-
//select address
143-
//
144-
//setAddress(adr);
145105
setData(Data);
146106
//Vpp pulse
147107
delayMicroseconds(4);
@@ -155,7 +115,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
155115
unsigned long address=0;
156116
byte CHK=sectorH,CHKreceived;
157117
CHK^=sectorL;
158-
118+
159119
address=sectorH;
160120
address=(address<<8)|sectorL;
161121
address*=128;
@@ -168,7 +128,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
168128
while(Serial.available()==0);
169129
CHKreceived=Serial.read();
170130
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
172132
if(CHKreceived==CHK){
173133
for (int i = 0; i < 128; i++){
174134
setAddress(address++);
@@ -177,7 +137,7 @@ void writeSector(unsigned char sectorH,unsigned char sectorL){
177137
Serial.write(CHK);
178138
}
179139
readMode();
180-
140+
181141
}
182142
int readROM(){
183143
unsigned long num=1024*1024;
@@ -195,9 +155,7 @@ int readROM(){
195155
//checksum^=data;
196156
}
197157
digitalWrite(readPin,HIGH);
198-
158+
199159
//Serial.write(checksum);
200160
//Serial.write(0xAA);
201161
}
202-
203-

eprom.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
ser = serial.Serial('/dev/ttyACM0', 230400, timeout=0)
66
#time.sleep(10);#my arduino bugs if data is written to the port after opening it
7-
#filename='sonic.bin'#name of the rom, bin format
8-
#f=open(name,'rb');
9-
#with open(filename,'rb') as f:
107
romsize=1024
118

129
while True:
@@ -40,10 +37,6 @@
4037
data = ser.read(1)#must read the bytes and put in a file
4138
f.write(data)
4239
numBytes=numBytes+1
43-
#if(numBytes%8192==0):
44-
# //block=block+1
45-
# f.close()
46-
# f = open(name+str(block)+".bin", 'ab')
4740
f.close()
4841
if(option==2):
4942
name=input("What's the name of the file?")
@@ -56,20 +49,17 @@
5649
time.sleep(0.001)
5750
ser.write(struct.pack(">B",i>>8))
5851
CHK=i>>8
59-
#CHK=ord(CHK)
6052
time.sleep(0.001)
6153
ser.write(struct.pack(">B",i&0xFF))
6254
CHK^=i&0xFF
6355
time.sleep(0.001)
6456
data=f.read(128);
6557
print(data)
66-
#print("CHK:", CHK)
6758
for j in range(len(data)):
6859
CHK=CHK^data[j]
6960
time.sleep(0.001)
7061
print("Sector:",i)
7162
print("CHK:", CHK)
72-
#ser.write(data)
7363
response=~CHK
7464
while response!=CHK:
7565
ser.write(data)

0 commit comments

Comments
 (0)