From 590424e9b9a12ff21f14fc119b8dbaeb48a25219 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Thu, 13 Apr 2006 20:10:55 +0000 Subject: [PATCH] Add logic to handle inverted signals for parallel ports as well, using a tilde in avrdude.conf. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@577 81a1dc3b-b13d-400b-aceb-764788c761c2 --- par.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/par.c b/par.c index 3303856f..7b7766d5 100644 --- a/par.c +++ b/par.c @@ -81,7 +81,9 @@ struct ppipins_t ppipins[] = { static int par_setpin(PROGRAMMER * pgm, int pin, int value) { + int inverted; + inverted = pin & PIN_INVERSE; pin &= PIN_MASK; if (pin < 1 || pin > 17) @@ -90,6 +92,9 @@ static int par_setpin(PROGRAMMER * pgm, int pin, int value) pin--; if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) value = !value; if (value) @@ -108,7 +113,9 @@ static int par_setpin(PROGRAMMER * pgm, int pin, int value) static int par_getpin(PROGRAMMER * pgm, int pin) { int value; + int inverted; + inverted = pin & PIN_INVERSE; pin &= PIN_MASK; if (pin < 1 || pin > 17) @@ -122,6 +129,9 @@ static int par_getpin(PROGRAMMER * pgm, int pin) value = 1; if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) value = !value; return value; @@ -130,21 +140,40 @@ static int par_getpin(PROGRAMMER * pgm, int pin) static int par_highpulsepin(PROGRAMMER * pgm, int pin) { + int inverted; + + inverted = pin & PIN_INVERSE; + pin &= PIN_MASK; if (pin < 1 || pin > 17) return -1; pin--; - ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + if (ppipins[pin].inverted) + inverted = !inverted; + + if (inverted) { + ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); #if SLOW_TOGGLE - usleep(1000); + usleep(1000); #endif - ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); #if SLOW_TOGGLE - usleep(1000); + usleep(1000); #endif + } else { + ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); +#if SLOW_TOGGLE + usleep(1000); +#endif + ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); + +#if SLOW_TOGGLE + usleep(1000); +#endif + } return 0; }