Compare commits

...

3 Commits

Author SHA1 Message Date
Tom Nisbet 08f93deee6 Automatic detection of 2316 chip selects 2024-04-09 13:02:51 -04:00
Tom Nisbet 073bbfd0f4
Merge pull request #67 from jscrane/master
add 23xx support
2024-04-09 09:08:05 -04:00
steve fd5fbd564a add 23xx support 2024-04-07 12:13:25 +01:00
5 changed files with 234 additions and 1 deletions

View File

@ -11,6 +11,7 @@
//#define PROM_IS_SST39SF
//#define PROM_IS_SST28SF
//#define PROM_IS_8755A
//#define PROM_IS_23
// Don't change anything below this comment unless you are adding support for a new device type.
#if defined(PROM_IS_28C)
@ -23,6 +24,9 @@
#include "PromDeviceSST28SF.h"
#elif defined(PROM_IS_8755A)
#include "PromDevice8755A.h"
#elif defined(PROM_IS_23)
#include "PromDevice23.h"
// Additional device support goes here...
// Also add matching code in TommyPROM.ino to declare the new device
#else

View File

@ -114,6 +114,8 @@ void PromDevice::setDataBusMode(uint8_t mode)
{
DDRB &= 0xfc;
DDRD &= 0x03;
PORTB |= 0x03; // set pullup resistors
PORTD |= 0xfc;
}
}

185
TommyPROM/PromDevice23.cpp Normal file
View File

@ -0,0 +1,185 @@
// NOTE - The 23 series device support is a work in progress. It
// has not been tested or documented.
#include "Configure.h"
#if defined(PROM_IS_23)
#include "PromAddressDriver.h"
// IO lines for the EPROM device control
// Pins D2..D9 are used for the data bus.
#define CS3_PIN A0
#define CS2_PIN A1
#define CS1_PIN A2
#define CS3_BIT 0x04
#define CS2_BIT 0x02
#define CS1_BIT 0x01
static unsigned csBits;
// Set the status of the device control pins
static void enableCS(unsigned pin, unsigned maskBit) { digitalWrite(pin, (csBits & maskBit) ? HIGH : LOW); }
static void disableCS(unsigned pin, unsigned maskBit) { digitalWrite(pin, (csBits & maskBit) ? LOW : HIGH); }
static void enableCS1() { enableCS(CS1_PIN, CS1_BIT); }
static void disableCS1() { disableCS(CS1_PIN, CS1_BIT); }
static void enableCS2() { enableCS(CS2_PIN, CS2_BIT); }
static void disableCS2() { disableCS(CS2_PIN, CS2_BIT); }
static void enableCS3() { enableCS(CS3_PIN, CS3_BIT); }
static void disableCS3() { disableCS(CS3_PIN, CS3_BIT); }
PromDevice23::PromDevice23(uint32_t size)
: PromDevice(size, 0, 0, false)
{
}
void PromDevice23::begin()
{
// Define the data bus as input initially so that it does not put out a
// signal that could collide with output on the data pins of the EEPROM.
setDataBusMode(INPUT_PULLUP);
csBits = 0; // Init to CS3, CS2, and CS1 all active LOW
pinMode(CS1_PIN, OUTPUT);
pinMode(CS2_PIN, OUTPUT);
pinMode(CS3_PIN, OUTPUT);
disableCS1();
disableCS2();
disableCS3();
// This chip uses the shift register hardware for addresses, so initialize that.
PromAddressDriver::begin();
}
// Override the existing Unlock command to scan the different combinations of CS until
// data is found. If the CS lines are not correctly configured, the chip should not
// assert any signals on the data bus and the Arduino will read back all FF.
ERET PromDevice23::disableSoftwareWriteProtect()
{
// Finish out the Unlock message printed by the UI code
Serial.println("just kidding!");
// Scan a few different addresses in case there are legitimate empty blocks. With
// the total ROM size of 2K, it is very unlikely that there are several unused
// 16-byte blocks, so a valid set of CS pins should encounter some data.
for (uint32_t addrBase = 0x0000; (addrBase < mSize); addrBase += 0x250)
{
if (scanAddress(addrBase))
{
Serial.print("Setting CS bits to ");
printCSbits(csBits);
Serial.println();
return RET_OK;
}
}
Serial.println("No valid CS settings found");
return RET_FAIL;
}
// BEGIN PRIVATE METHODS
//
// Print the current CS bit settings.
void PromDevice23::printCSbits(unsigned bits)
{
Serial.print("CS3:");
Serial.print((bits & CS3_BIT) ? 'H':'L');
Serial.print(" CS2:");
Serial.print((bits & CS2_BIT) ? 'H':'L');
Serial.print(" CS1:");
Serial.print((bits & CS1_BIT) ? 'H':'L');
}
// Try all combinations of the CS bits and read 16 bytes of data from the chip.
// One of the CS settings should read some non-FF data.
bool PromDevice23::scanAddress(uint32_t addrBase)
{
unsigned saveBits = 0xff;
Serial.print("\nScanning Chip Select combinations starting at address ");
printByte(addrBase >> 8);
printByte(addrBase & 0xff);
Serial.println();
for (csBits = 0; (csBits < 8); csBits++)
{
// Disable all CS bits using the new definition of csBits
disableCS3();
disableCS2();
disableCS1();
printCSbits(csBits);
Serial.print(" - ");
for (unsigned offset = 0; (offset < 16); offset++)
{
byte data = readByte(addrBase + offset);
printByte(data);
Serial.print(' ');
if (data != 0xff)
{
// this combination of Chip Selects successfully read data
saveBits = csBits;
}
}
Serial.println();
}
if (saveBits != 0xff)
{
csBits = saveBits;
return true;
}
return false;
}
static const char hex[] = "0123456789abcdef";
void PromDevice23::printByte(byte b)
{
char line[3];
line[0] = hex[b >> 4];
line[1] = hex[b & 0x0f];
line[2] = '\0';
Serial.print(line);
}
// Use the PromAddressDriver to set a 16 bit address in the two address shift registers.
void PromDevice23::setAddress(uint32_t address)
{
PromAddressDriver::setAddress(address);
}
// Read a byte from a given address
byte PromDevice23::readByte(uint32_t address)
{
byte data = 0;
setAddress(address);
setDataBusMode(INPUT_PULLUP);
enableCS1();
enableCS2();
enableCS3();
delayMicroseconds(20);
data = readDataBus();
disableCS3();
disableCS2();
disableCS1();
return data;
}
#endif // #if defined(PROM_IS_23)

38
TommyPROM/PromDevice23.h Normal file
View File

@ -0,0 +1,38 @@
// NOTE - The 23 series device support is a work in progress. It
// has not been tested or documented.
#ifndef INCLUDE_PROM_DEVICE_23_H
#define INCLUDE_PROM_DEVICE_23_H
#include "Arduino.h"
#include "PromDevice.h"
/*****************************************************************************/
/*****************************************************************************/
/**
* PromDevice23 class
*
* Provides the device-specific interface to read data from a
* 23 series parallel PROM using the Arduino. Supported chips
* include 2316.
*/
class PromDevice23 : public PromDevice
{
public:
PromDevice23(uint32_t size);
void begin();
const char *getName() { return "23 series PROM"; }
ERET disableSoftwareWriteProtect(); // use the Unlock command to scan the chip selects
protected:
void printCSbits(unsigned bits);
bool scanAddress(uint32_t addrBase);
void printByte(byte b);
void setAddress(uint32_t address);
byte readByte(uint32_t address);
bool burnByte(byte value, uint32_t address) { return false; }
};
#endif // #define INCLUDE_PROM_DEVICE_23_H

View File

@ -19,7 +19,7 @@
#include "XModem.h"
static const char * MY_VERSION = "3.3";
static const char * MY_VERSION = "3.4";
// Global status
@ -36,6 +36,7 @@ CmdStatus cmdStatus;
// Data polling supported
PromDevice28C prom(32 * 1024L, 64, 10, true);
//PromDevice28C prom(8 * 1024L, 0, 10, true); // 28C64 with no page writes
//PromDevice28C prom(2 * 1024L, 0, 10, true); // 28C16 with no page writes
#elif defined(PROM_IS_27)
// Define a device for a 2764 EPROM with the following parameters:
@ -72,6 +73,9 @@ PromDeviceSST28SF prom(512 * 1024L, 40, true);
// Define a device for an Intel 8755A with a fixed size of 2K and no other parameters.
PromDevice8755A prom(2 * 1024L);
#elif defined(PROM_IS_23)
PromDevice23 prom(2 * 1024L); // 2316
// Additional device-specific code goes here...
//#elif defined(PROM_IS...