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
This commit is contained in:
joerg_wunsch 2006-04-13 20:10:55 +00:00
parent a37080cc24
commit 6f06530404
1 changed files with 33 additions and 4 deletions

37
par.c
View File

@ -81,7 +81,9 @@ struct ppipins_t ppipins[] = {
static int par_setpin(PROGRAMMER * pgm, int pin, int value) static int par_setpin(PROGRAMMER * pgm, int pin, int value)
{ {
int inverted;
inverted = pin & PIN_INVERSE;
pin &= PIN_MASK; pin &= PIN_MASK;
if (pin < 1 || pin > 17) if (pin < 1 || pin > 17)
@ -90,6 +92,9 @@ static int par_setpin(PROGRAMMER * pgm, int pin, int value)
pin--; pin--;
if (ppipins[pin].inverted) if (ppipins[pin].inverted)
inverted = !inverted;
if (inverted)
value = !value; value = !value;
if (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) static int par_getpin(PROGRAMMER * pgm, int pin)
{ {
int value; int value;
int inverted;
inverted = pin & PIN_INVERSE;
pin &= PIN_MASK; pin &= PIN_MASK;
if (pin < 1 || pin > 17) if (pin < 1 || pin > 17)
@ -122,6 +129,9 @@ static int par_getpin(PROGRAMMER * pgm, int pin)
value = 1; value = 1;
if (ppipins[pin].inverted) if (ppipins[pin].inverted)
inverted = !inverted;
if (inverted)
value = !value; value = !value;
return value; return value;
@ -130,21 +140,40 @@ static int par_getpin(PROGRAMMER * pgm, int pin)
static int par_highpulsepin(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) if (pin < 1 || pin > 17)
return -1; return -1;
pin--; 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 #if SLOW_TOGGLE
usleep(1000); usleep(1000);
#endif #endif
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit); ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
#if SLOW_TOGGLE #if SLOW_TOGGLE
usleep(1000); usleep(1000);
#endif #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; return 0;
} }