Compare commits

...

4 Commits

Author SHA1 Message Date
ole00 cf34c1dfee Sketch: support Arduino based on ESP32-S2 MCU
Because of the internal reference of 2.5V on Analogue pins
of ESP32-S2, the R6 must be modified from 20k Ohm to 16.67k Ohm.
This can be achieved by placing a new 100k Ohm resistor
in parallel with R6 resistor. Use this mod only when Arduino
is ESP32-S2 based.
2024-04-21 00:12:15 +01:00
ole00 babba5bca9 PC app: jtag: better handling of new line characters
Previously the new line characters were expected to be
part of the feed request message. This is not so on
ESP32 based Arduino library implementation. The new
line characters arrive later on separately after a small
pause This code change fixes 'corrupted feed request'
warning messages on such Arduino platforms.
2024-04-20 16:02:33 +01:00
ole00 afae1b2166 jtag: fuseconv.py: added support for ATF150XASV (3.3V)
The converted code ID check will match either AS or ASL or ASV
flavours of the ATF150X ICs.
2024-04-20 15:46:44 +01:00
ole00 9656fbadd3 xsvf: added support for ATF150XASV (3.3V)
The IDCODE check mask was updated to support:
ATF1502ASL: 0150203F or 0150303F
ATF1502ASV: 0151203F or 0151303F
ATF1504ASL: 0150403F or 0150503F
ATF1504ASV: 0151403F or 0151503F
The ID codes were found on https://bsdl.info
2024-04-20 15:31:53 +01:00
7 changed files with 77 additions and 10 deletions

View File

@ -14,6 +14,20 @@
#define POT_DAT A5
#define VPP A0
#if CONFIG_IDF_TARGET_ESP32S2 == 1
// ESP32-S2
#include "driver/adc.h"
#define ADC_PIN ADC2_CHANNEL_3
#define EEPROM_BEGIN() EEPROM.begin(128)
#define EEPROM_UPDATE(A,V) if ((V) != EEPROM.read((A))) EEPROM.write((A),(V))
#define EEPROM_END() EEPROM.end()
#else
// AVR
#define EEPROM_BEGIN()
#define EEPROM_UPDATE(A,V) EEPROM.update((A),(V))
#define EEPROM_END()
#endif
#include "aftb_mcp4131.h"
#ifndef FAIL
#define FAIL 0
@ -73,22 +87,25 @@ int8_t calOffset = 0; // VPP calibration offset: value 10 is 0.1V, value -10 is
static void varVppReadCalib(void) {
uint8_t i;
EEPROM_BEGIN();
//calibration not found
if (EEPROM.read(0) != 0xAF || EEPROM.read(1) != 0xCA) {
vppWiper[0] = 0;
Serial.println(F("No calibration data in EEPROM"));
EEPROM_END();
return;
}
calOffset = (int8_t) EEPROM.read(2);
for (i = 0; i < MAX_WIPER; i++) {
vppWiper[i] = EEPROM.read(i + 3);
#if 0
#if 0
Serial.print(F("Calib "));
Serial.print(i);
Serial.print(F(":"));
Serial.println(vppWiper[i]);
#endif
}
EEPROM_END();
}
// internal use only - set the wiper value on the digital pot
@ -154,6 +171,13 @@ static void varVppSet(uint8_t value) {
// SAMPLE_SHIFT moves the ADC gain error up/down
#define SAMPLE_SHIFT -45;
// ESP32-S2 (VREF 2.5V)
#elif CONFIG_IDF_TARGET_ESP32S2 == 1
#define SAMPLE_CNT 18
#define SAMPLE_DIVIDER 10
#define SAMPLE_MULTIPLIER 1
#define SAMPLE_OFFSET 5
//AVR based Arduinos (no ADC gain errors measured)
#else
#define SAMPLE_CNT 14
@ -296,23 +320,38 @@ ret:
}
static void varVppStoreWiperCalib() {
uint8_t i = 0;
//sanity check
if (vppWiper[0] == 0) {
#ifdef VPP_VERBOSE
Serial.println(F("VPP wiper is 0"));
#endif
return;
}
#ifdef VPP_VERBOSE
Serial.println(F("VPP storing calibration"));
#endif
EEPROM_BEGIN();
//write Afterburner calibration header
EEPROM.update(0, 0xAF);
EEPROM.update(1, 0xCA);
EEPROM.update(2, (uint8_t) calOffset);
EEPROM_UPDATE(0, 0xAF);
EEPROM_UPDATE(1, 0xCA);
EEPROM_UPDATE(2, (uint8_t) calOffset);
while (i < MAX_WIPER) {
EEPROM.update(3 + i, vppWiper[i]);
EEPROM_UPDATE(3 + i, vppWiper[i]);
i++;
}
EEPROM_END();
}
#if CONFIG_IDF_TARGET_ESP32S2 == 1
static void analogReference(uint8_t ref) {
analogReadResolution(10);
adc2_config_channel_atten(ADC_PIN, ADC_ATTEN_DB_11); // AREF 2.5V
}
#endif
//return 1 on success (variable VPP functionality present), 0 on failure (VPP not detected on board)
static int8_t varVppInit(void) {

View File

@ -81,6 +81,19 @@
#define PIN_ZIF23 3
#define PIN_ZIF_GND_CTRL 13
#if CONFIG_IDF_TARGET_ESP32S2 == 1
//A0: VPP sense
//A3: DIGI_POT CS
#define A0 14
#define A1 15
#define A2 16
#define A3 17
//clk and dat is shared SPI bus
#define A4 18
#define A5 21
#endif
// AVR, or UNO R4
//A0: VPP sense
//A3: DIGI_POT CS
#define PIN_SHR_EN A1
@ -208,6 +221,11 @@ typedef enum {
#define RAM_BIG
#endif
//ESP32-S2
#if CONFIG_IDF_TARGET_ESP32S2 == 1
#define RAM_BIG
#endif
// common CFG fuse address map for cfg16V8 and cfg20V8
// the only difference is the starting address: 2048 for cfg16V8 and 2560 for cfg20V8

View File

@ -1253,13 +1253,23 @@ static int readJtagSerialLine(char* buf, int bufSize, int maxDelay, int* feedReq
bufPos -= readSize;
buf[0] = 0;
//extra 5 bytes should be present: 3 bytes of size, 2 new line chars
readSize = serialDeviceRead(serialF, tmp, 5);
if (readSize == 5) {
readSize = serialDeviceRead(serialF, tmp, 3);
if (readSize == 3) {
int retry = 1000;
tmp[3] = 0;
*feedRequest = atoi(tmp);
maxDelay = 0; //force exit
//read the extra 2 characters (new line chars)
while (retry && readSize != 2) {
readSize = serialDeviceRead(serialF, tmp, 2);
retry--;
}
if (readSize != 2 || tmp[0] != '\r' || tmp[1] != '\n') {
printf("Warning: corrupted feed request ! %d \n", readSize);
}
} else {
printf("Warning: corrupted feed request!\n");
printf("Warning: corrupted feed request! %d \n", readSize);
}
//printf("***\n");
} else

View File

@ -96,7 +96,7 @@ def write_svf(file, svf_bits, device, *, comment):
def emit_check_idcode(idcode):
file.write("// Check IDCODE\n")
file.write("SIR 10 TDI ({:03x});\n".format(ATF15xxInstr.IDCODE))
file.write("SDR 32 TDI (ffffffff)\n\tTDO ({:08x})\n\tMASK (ffffffff);\n".format(idcode))
file.write("SDR 32 TDI (fffeefff)\n\tTDO ({:08x})\n\tMASK (fffeefff);\n".format(idcode))
def emit_enable():
file.write("// ISC enable\n")
file.write("SIR 10 TDI ({:03x});\n".format(ATF15xxInstr.ISC_CONFIG))

Binary file not shown.

Binary file not shown.

Binary file not shown.