From 010c1e3e4007f74253b8819166a2ef77896e3998 Mon Sep 17 00:00:00 2001 From: Brian Peek <2321675+BrianPeek@users.noreply.github.com> Date: Tue, 27 Sep 2022 23:02:38 -0700 Subject: [PATCH] start of different EPROM sizes --- .vscode/extensions.json | 10 -------- src/SendEPROM | 1 + src/{ => teensy}/main.cpp | 48 +++++++++++++++++++++++++++------------ 3 files changed, 34 insertions(+), 25 deletions(-) delete mode 100644 .vscode/extensions.json create mode 160000 src/SendEPROM rename src/{ => teensy}/main.cpp (73%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/src/SendEPROM b/src/SendEPROM new file mode 160000 index 0000000..852bcbb --- /dev/null +++ b/src/SendEPROM @@ -0,0 +1 @@ +Subproject commit 852bcbb35134d515fa85c28a36daf8a93beeb717 diff --git a/src/main.cpp b/src/teensy/main.cpp similarity index 73% rename from src/main.cpp rename to src/teensy/main.cpp index db25f40..5caa4d0 100644 --- a/src/main.cpp +++ b/src/teensy/main.cpp @@ -2,24 +2,34 @@ #include #include -// forced to a 2mbit eprom // FLASHMEM // DMAMEM // PROGMEM +enum eMode : unsigned char +{ + m27C256 = 1, + m27C020 = 2, + mUnknown = 0xFF +}; + #define ROM_BUFFER_LEN (256*1024) char buffer[ROM_BUFFER_LEN]; const char *filename = "rom.bin"; +eMode mode = m27C020; +Stream* stream; int32_t inPins[] = { 19,18,14,15,40,41,17,16,22,23,20,21,38,39,26,27,24,25,-1 }; int32_t outPins[] = { 10,12,11,13,8,7,36,37,-1 }; -void readFile(int port) +void readData(Stream* s) { const int length = 1024; char buff[length]; - memset(buffer, 0, ROM_BUFFER_LEN); + mode = (eMode)s->read(); + + memset(buffer, 0xFF, ROM_BUFFER_LEN); size_t read = 0; size_t total = 0; @@ -29,15 +39,7 @@ void readFile(int port) { memset(buff, 0, length); - switch(port) - { - case 0: - read = Serial.readBytes(buff, length); - break; - case 1: - read = Serial1.readBytes(buff, length); - break; - } + read = s->readBytes(buff, length); total += read; if(read > 0) @@ -90,7 +92,23 @@ void loop() uint32_t outb = 0; // read address pins - uint32_t addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4); + uint32_t addr = 0; + + switch(mode) + { + // 32Kbit, 8KB, 0x0000-0x7FFF + case m27C256: + addr = ((io6 >> 16) & 0x7FFF); + break; + + // 2Mbit, 256KB, 0x00000-0x3FFFF + case m27C020: + addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4); + break; + + default: + break; + } // get byte at addr char b = buffer[addr]; @@ -101,8 +119,8 @@ void loop() // read file from either serial port, if available if(Serial.available()) - readFile(0); + readData(&Serial); if(Serial1.available()) - readFile(1); + readData(&Serial1); }