From ab9fa88437d0c77f73b53ec3bab48f159a5951c5 Mon Sep 17 00:00:00 2001 From: rhgndf <16336768+rhgndf@users.noreply.github.com> Date: Mon, 30 Oct 2023 22:13:25 +0800 Subject: [PATCH] Support ATF20V8B --- afterburner.ino | 25 +++++++++++++++++++++---- src_pc/afterburner.c | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/afterburner.ino b/afterburner.ino index a016c2c..f779592 100644 --- a/afterburner.ino +++ b/afterburner.ino @@ -150,6 +150,7 @@ typedef enum { GAL6001, GAL6002, ATF16V8B, + ATF20V8B, ATF22V10B, ATF22V10C, LAST_GAL_TYPE //dummy @@ -301,6 +302,7 @@ galinfo[]= {GAL6001, 0x40, 0x41, 8294, 24, 78, 75, 97, 8222, 9, 63, 62, 96, 8, 8, CFG_BASE_600 , cfg6001, sizeof(cfg6001) , CFG_SET_ROW }, {GAL6002, 0x44, 0x44, 8330, 24, 78, 75, 97, 8258, 9, 63, 62, 96, 8, 8, CFG_BASE_600 , cfg6002, sizeof(cfg6002) , CFG_SET_ROW }, {ATF16V8B, 0x00, 0x00, 2194, 20, 32, 64, 32, 2056, 8, 63, 62, 58, 8, 60, CFG_BASE_16 , cfgV8AB, sizeof(cfgV8AB) , CFG_STROBE_ROW}, + {ATF20V8B, 0x00, 0x00, 2706, 24, 40, 64, 40, 2568, 8, 63, 62, 58, 8, 60, CFG_BASE_20 , cfgV8AB, sizeof(cfgV8AB) , CFG_STROBE_ROW}, {ATF22V10B, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22 , cfgV10, sizeof(cfgV10) , CFG_SET_ROW }, {ATF22V10C, 0x00, 0x00, 5892, 24, 44, 132, 44, 5828, 8, 61, 62, 58, 10, 16, CFG_BASE_22 , cfgV10, sizeof(cfgV10) , CFG_SET_ROW }, }; @@ -381,6 +383,7 @@ static void setPinMux(uint8_t pm) { break; case GAL20V8: + case ATF20V8B: pinMode(PIN_ZIF10, pm); pinMode(PIN_ZIF11, pm); pinMode(PIN_ZIF13, pm); @@ -745,7 +748,7 @@ static void setVPP(char on) { // when PES is read the VPP is not determined via PES if (on == READPES) { - if (gal == ATF16V8B || gal == ATF22V10B || gal == ATF22V10B) { + if (gal == ATF16V8B || gal == ATF20V8B || gal == ATF22V10B || gal == ATF22V10B) { v = VPP_10V0; } else { v = VPP_11V5; @@ -963,6 +966,10 @@ static void sendBit(char bitValue, char skipClkLow = 0) { setSDIN(bitValue); setSCLK(1); + // For some reason ATF20V8B needs a slower clock + if (gal == ATF20V8B) { + delay(1); + } if (!skipClkLow) { setSCLK(0); } @@ -1015,6 +1022,7 @@ static void strobeRow(char row, char setBit = BIT_NONE) switch(gal) { case GAL16V8: case GAL20V8: + case ATF20V8B: case ATF16V8B: setRow(row); // set RA0-5 to row number if (setBit) { @@ -1084,7 +1092,7 @@ static void writePes(void) { uint8_t rbit; uint8_t b, p; - if (gal == ATF16V8B || gal == ATF22V10B || gal == ATF22V10C) { + if (gal == ATF16V8B || gal == ATF20V8B || gal == ATF22V10B || gal == ATF22V10C) { Serial.println(F("ER write PES not supported")); return; } @@ -1136,7 +1144,7 @@ static unsigned char getDuration(unsigned char index) { } static void setGalDefaults(void) { - if (gal == ATF16V8B || gal == ATF22V10B || gal == ATF22V10C) { + if (gal == ATF16V8B || gal == ATF20V8B || gal == ATF22V10B || gal == ATF22V10C) { progtime = 20; erasetime = 100; vpp = 40; /* 10V */ @@ -1161,6 +1169,7 @@ void parsePes(char type) { switch (type) { case ATF16V8B: + case ATF20V8B: case ATF22V10B: case ATF22V10C: progtime = 20; @@ -1267,6 +1276,7 @@ void printPes(char type) { case GAL6001: Serial.print(F("GAL6001 ")); break; case GAL6002: Serial.print(F("GAL6002 ")); break; case ATF16V8B: Serial.print(0 == (flagBits & FLAG_BIT_ATF16V8C) ? F("ATF16V8B "): F("ATF16V8C ")); break; + case ATF20V8B: Serial.print(F("ATF20V8B ")); break; case ATF22V10B: Serial.print(F("ATF22V10B ")); break; case ATF22V10C: Serial.print(F("ATF22V10C ")); break; } @@ -1696,6 +1706,7 @@ static void readOrVerifyGal(char verify) break; case ATF16V8B: + case ATF20V8B: //read without delay, no discard if (verify) { i = verifyGalFuseMap(cfgV8AB, 0, 0); @@ -1703,7 +1714,7 @@ static void readOrVerifyGal(char verify) readGalFuseMap(cfgV8AB, 0, 0); } break; - + case GAL6001: case GAL6002: cfgArray = (gal == GAL6001) ? (unsigned char*) cfg6001 : (unsigned char*) cfg6002; @@ -1934,6 +1945,7 @@ static void writeGal() break; case ATF16V8B: + case ATF20V8B: writeGalFuseMapV8(cfgV8AB); break; @@ -1991,6 +2003,7 @@ static void secureGAL(void) static char checkGalTypeViaPes(void) { char type = UNKNOWN; + static const char PROGMEM pesATF20V8B[] = "0B8V02F1"; #ifdef DEBUG_PES char i; @@ -2010,6 +2023,9 @@ static char checkGalTypeViaPes(void) type = ATF22V10C; } } + else if (strncmp_P((const char*)pes, pesATF20V8B, 8) == 0) { + type = ATF20V8B; + } else if (pes[6] == 'F' && pes[5] == '1' && pes[4]== '6' && pes[3] == 'V' && pes[2]=='8') { type = ATF16V8B; if (pes[1] == 'C' || pes[1] == 'Z') { // ATF16V8C, ATF16V8CZ @@ -2140,6 +2156,7 @@ static void printGalName() { Serial.println(F("ATF16V8B")); } break; + case ATF20V8B: Serial.println(F("ATF20V8B")); break; case ATF22V10B: Serial.println(F("ATF22V10B")); break; case ATF22V10C: Serial.println(F("ATF22V10C")); break; default: Serial.println(F("GAL")); break; diff --git a/src_pc/afterburner.c b/src_pc/afterburner.c index 648f4b4..a0176f3 100644 --- a/src_pc/afterburner.c +++ b/src_pc/afterburner.c @@ -62,6 +62,7 @@ typedef enum { GAL6001, GAL6002, ATF16V8B, + ATF20V8B, ATF22V10B, ATF22V10C } Galtype; @@ -95,6 +96,7 @@ galinfo[] = { {GAL6001, 0x40, 0x41, "GAL6001", 8294, 24, 78, 75, 97, 8222, 9, 63, 62, 96, 8, 8, 68}, {GAL6002, 0x44, 0x44, "GAL6002", 8330, 24, 78, 75, 97, 8258, 9, 63, 62, 96, 8, 8, 104}, {ATF16V8B, 0x00, 0x00, "ATF16V8B", 2194, 20, 32, 64, 32, 2056, 8, 63, 54, 58, 8, 60, 82}, + {ATF20V8B, 0x00, 0x00, "ATF20V8B", 2706, 24, 40, 64, 40, 2568, 8, 63, 59, 58, 8, 60, 82}, {ATF22V10B, 0x00, 0x00, "ATF22V10B", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20}, {ATF22V10C, 0x00, 0x00, "ATF22V10C", 5892, 24, 44, 132, 44, 5828, 8, 61, 60, 58, 10, 16, 20}, };