mirror of
https://github.com/ole00/afterburner.git
synced 2024-06-16 06:29:36 +00:00
ensure GPIOs are set to Input when not active
This should prevent accidental damage of the GAL chip during insertion into the socket.
This commit is contained in:
parent
ed14f825a5
commit
ae955a8b6b
|
@ -250,6 +250,24 @@ void printHelp(char full) {
|
||||||
Serial.println(F(" t - test VPP"));
|
Serial.println(F(" t - test VPP"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setupGpios(uint8_t pm) {
|
||||||
|
|
||||||
|
// Serial input of the GAL chip, output from Arduino
|
||||||
|
pinMode(PIN_SDIN, pm);
|
||||||
|
|
||||||
|
pinMode(PIN_STROBE, pm);
|
||||||
|
pinMode(PIN_PV, pm);
|
||||||
|
pinMode(PIN_RA0, pm);
|
||||||
|
pinMode(PIN_RA1, pm);
|
||||||
|
pinMode(PIN_RA2, pm);
|
||||||
|
pinMode(PIN_RA3, pm);
|
||||||
|
pinMode(PIN_RA4, pm);
|
||||||
|
pinMode(PIN_RA5, pm);
|
||||||
|
pinMode(PIN_SCLK, pm);
|
||||||
|
|
||||||
|
pinMode(PIN_VPP, pm);
|
||||||
|
}
|
||||||
|
|
||||||
// setup the Arduino board
|
// setup the Arduino board
|
||||||
void setup() {
|
void setup() {
|
||||||
// initialize serial:
|
// initialize serial:
|
||||||
|
@ -259,27 +277,13 @@ void setup() {
|
||||||
echoEnabled = 0;
|
echoEnabled = 0;
|
||||||
mapUploaded = 0;
|
mapUploaded = 0;
|
||||||
typeCheck = 1; //do type check
|
typeCheck = 1; //do type check
|
||||||
lineIndex = 0;
|
|
||||||
|
|
||||||
// Serial output from the GAL chip, input for Arduino
|
// Serial output from the GAL chip, input for Arduino
|
||||||
pinMode(PIN_SDOUT, INPUT);
|
pinMode(PIN_SDOUT, INPUT);
|
||||||
// Serial input of the GAL chip, output from Arduino
|
|
||||||
pinMode(PIN_SDIN, OUTPUT);
|
|
||||||
|
|
||||||
pinMode(PIN_STROBE, OUTPUT);
|
// Set all GPIO pins to Input to prevent accidents when
|
||||||
pinMode(PIN_PV, OUTPUT);
|
// inserting the GAL IC into socket.
|
||||||
pinMode(PIN_RA0, OUTPUT);
|
setupGpios(INPUT);
|
||||||
pinMode(PIN_RA1, OUTPUT);
|
|
||||||
pinMode(PIN_RA2, OUTPUT);
|
|
||||||
pinMode(PIN_RA3, OUTPUT);
|
|
||||||
pinMode(PIN_RA4, OUTPUT);
|
|
||||||
pinMode(PIN_RA5, OUTPUT);
|
|
||||||
pinMode(PIN_SCLK, OUTPUT);
|
|
||||||
|
|
||||||
pinMode(PIN_VPP, OUTPUT);
|
|
||||||
// Important - the output pins should be kept high.
|
|
||||||
// TurnOff function does that (keeps pin high).
|
|
||||||
turnOff();
|
|
||||||
|
|
||||||
printHelp(0);
|
printHelp(0);
|
||||||
Serial.println(">");
|
Serial.println(">");
|
||||||
|
@ -539,11 +543,12 @@ static void turnOff(void)
|
||||||
delay(2);
|
delay(2);
|
||||||
setVCC(0); // turn off VCC (if controlled)
|
setVCC(0); // turn off VCC (if controlled)
|
||||||
|
|
||||||
|
setupGpios(INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GAL init sequence
|
// GAL init sequence
|
||||||
static void turnOn(char mode) {
|
static void turnOn(char mode) {
|
||||||
|
setupGpios(OUTPUT);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mode == WRITEGAL ||
|
mode == WRITEGAL ||
|
||||||
|
@ -1443,11 +1448,14 @@ static void printNoFusesError() {
|
||||||
|
|
||||||
static void testVoltage(int seconds) {
|
static void testVoltage(int seconds) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
pinMode(PIN_VPP, OUTPUT);
|
||||||
setVPP(1);
|
setVPP(1);
|
||||||
for (i = 0 ; i < seconds; i++) {
|
for (i = 0 ; i < seconds; i++) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
setVPP(0);
|
setVPP(0);
|
||||||
|
pinMode(PIN_VPP, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user