As Joerg Wunsch wrote:
> > - Would it be possible let avrdude invert the programming signals,
> > so that a board like this would be directly supported?
> Sure, please go ahead and implement it. Should be trivial.
Here's a proposed implementation. I tried to also fix the way Vcc and
buffer enable are handled, as I think the previous implementation was
broken wrt. pins that are already inverted by the printer port
hardware.
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Index: par.c
===================================================================
RCS file: /sources/avrdude/avrdude/par.c,v
retrieving revision 1.14
diff -u -u -r1.14 par.c
--- par.c 29 Nov 2005 20:20:22 -0000 1.14
+++ par.c 11 Apr 2006 12:33:27 -0000
@@ -81,7 +81,9 @@
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 @@
pin--;
if (ppipins[pin].inverted)
+ inverted = !inverted;
+
+ if (inverted)
value = !value;
if (value)
@@ -108,7 +113,9 @@
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 @@
value = 1;
if (ppipins[pin].inverted)
+ inverted = !inverted;
+
+ if (inverted)
value = !value;
return value;
@@ -130,21 +140,40 @@
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;
}
@@ -188,7 +217,17 @@
*/
static void par_powerup(PROGRAMMER * pgm)
{
- ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */
+ int pin;
+ unsigned int pmask = pgm->pinno[PPI_AVR_VCC];
+ unsigned int mask;
+ unsigned int invert = pmask & PIN_INVERSE;
+
+ /* power up each pin */
+ for (pin = 2, mask = 1; mask < PIN_MASK; mask <<= 1, pin++) {
+ if (pmask & mask) {
+ par_setpin(pgm, mask | invert, 1);
+ }
+ }
usleep(100000);
}
@@ -198,16 +237,50 @@
*/
static void par_powerdown(PROGRAMMER * pgm)
{
- ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power down */
+ int pin;
+ unsigned int pmask = pgm->pinno[PPI_AVR_VCC];
+ unsigned int mask;
+ unsigned int invert = pmask & PIN_INVERSE;
+
+ /* power down each pin */
+ for (pin = 2, mask = 1; mask < PIN_MASK; mask <<= 1, pin++) {
+ if (pmask & mask) {
+ par_setpin(pgm, mask | invert, 0);
+ }
+ }
+ usleep(100000);
}
+/*
+ * Deactivate 74367 buffer. Note that the enable line is low-active,
+ * so logic levels are reversed.
+ */
static void par_disable(PROGRAMMER * pgm)
{
- ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
+ int pin;
+ unsigned int pmask = pgm->pinno[PPI_AVR_BUFF];
+ unsigned int mask;
+ unsigned int invert = pmask & PIN_INVERSE;
+
+ /* disable each pin */
+ for (pin = 2, mask = 1; mask < PIN_MASK; mask <<= 1, pin++) {
+ if (pmask & mask) {
+ par_setpin(pgm, mask | invert, 1);
+ }
+ }
}
+/*
+ * Activate 74367 buffer. Note that the enable line is low-active,
+ * so logic levels are reversed.
+ */
static void par_enable(PROGRAMMER * pgm)
{
+ int pin;
+ unsigned int pmask = pgm->pinno[PPI_AVR_BUFF];
+ unsigned int mask;
+ unsigned int invert = pmask & PIN_INVERSE;
+
/*
* Prepare to start talking to the connected device - pull reset low
* first, delay a few milliseconds, then enable the buffer. This
@@ -225,7 +298,13 @@
/*
* enable the 74367 buffer, if connected; this signal is active low
*/
- ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
+ /* power up each pin */
+ for (pin = 2, mask = 1; mask < PIN_MASK; mask <<= 1, pin++) {
+ if (pmask & mask) {
+ par_setpin(pgm, mask | invert, 0);
+ }
+ }
+ /* disable each pin */
}
static int par_open(PROGRAMMER * pgm, char * port)
_______________________________________________
avrdude-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avrdude-dev