Compare commits

..

No commits in common. "cf34c1dfee4038dd9d761cbea270ac74597437b8" and "29df84d42ee09cf0cfc1560c6261ddf75ad4cffc" have entirely different histories.

7 changed files with 10 additions and 77 deletions

View File

@ -14,20 +14,6 @@
#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
@ -87,25 +73,22 @@ 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
@ -171,13 +154,6 @@ 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
@ -320,38 +296,23 @@ 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,19 +81,6 @@
#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
@ -221,11 +208,6 @@ 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,23 +1253,13 @@ 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, 3);
if (readSize == 3) {
int retry = 1000;
readSize = serialDeviceRead(serialF, tmp, 5);
if (readSize == 5) {
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! %d \n", readSize);
printf("Warning: corrupted feed request!\n");
}
//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 (fffeefff)\n\tTDO ({:08x})\n\tMASK (fffeefff);\n".format(idcode))
file.write("SDR 32 TDI (ffffffff)\n\tTDO ({:08x})\n\tMASK (ffffffff);\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.