2003-02-13 19:27:50 +00:00
|
|
|
/*
|
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
2006-08-29 21:39:26 +00:00
|
|
|
* Copyright (C) 2000-2006 Brian S. Dean <bsd@bsdhome.com>
|
2003-02-13 19:27:50 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2012-11-20 14:03:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-02-13 19:27:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2003-02-14 20:34:03 +00:00
|
|
|
#include "ac_cfg.h"
|
|
|
|
|
2003-02-13 19:27:50 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2010-01-17 16:58:06 +00:00
|
|
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2005-11-03 22:37:37 +00:00
|
|
|
# include "freebsd_ppi.h"
|
2003-02-13 19:27:50 +00:00
|
|
|
#elif defined(__linux__)
|
2005-11-03 22:37:37 +00:00
|
|
|
# include "linux_ppdev.h"
|
2009-02-23 22:04:57 +00:00
|
|
|
#elif defined(__sun__) || defined(__sun) /* Solaris */
|
2005-11-03 22:37:37 +00:00
|
|
|
# include "solaris_ecpp.h"
|
2003-02-13 19:27:50 +00:00
|
|
|
#endif
|
|
|
|
|
2007-01-24 21:07:54 +00:00
|
|
|
#include "avrdude.h"
|
2003-02-13 19:27:50 +00:00
|
|
|
#include "avr.h"
|
|
|
|
#include "pindefs.h"
|
|
|
|
#include "pgm.h"
|
|
|
|
#include "ppi.h"
|
2005-09-18 20:12:23 +00:00
|
|
|
#include "bitbang.h"
|
2012-01-31 17:03:43 +00:00
|
|
|
#include "par.h"
|
2003-02-13 19:27:50 +00:00
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
#if HAVE_PARPORT
|
|
|
|
|
2003-02-13 19:27:50 +00:00
|
|
|
struct ppipins_t {
|
|
|
|
int pin;
|
|
|
|
int reg;
|
|
|
|
int bit;
|
|
|
|
int inverted;
|
|
|
|
};
|
|
|
|
|
2006-08-29 21:39:26 +00:00
|
|
|
static struct ppipins_t ppipins[] = {
|
2003-02-13 19:27:50 +00:00
|
|
|
{ 1, PPICTRL, 0x01, 1 },
|
|
|
|
{ 2, PPIDATA, 0x01, 0 },
|
|
|
|
{ 3, PPIDATA, 0x02, 0 },
|
|
|
|
{ 4, PPIDATA, 0x04, 0 },
|
|
|
|
{ 5, PPIDATA, 0x08, 0 },
|
|
|
|
{ 6, PPIDATA, 0x10, 0 },
|
|
|
|
{ 7, PPIDATA, 0x20, 0 },
|
|
|
|
{ 8, PPIDATA, 0x40, 0 },
|
|
|
|
{ 9, PPIDATA, 0x80, 0 },
|
|
|
|
{ 10, PPISTATUS, 0x40, 0 },
|
|
|
|
{ 11, PPISTATUS, 0x80, 1 },
|
|
|
|
{ 12, PPISTATUS, 0x20, 0 },
|
|
|
|
{ 13, PPISTATUS, 0x10, 0 },
|
|
|
|
{ 14, PPICTRL, 0x02, 1 },
|
|
|
|
{ 15, PPISTATUS, 0x08, 0 },
|
|
|
|
{ 16, PPICTRL, 0x04, 0 },
|
|
|
|
{ 17, PPICTRL, 0x08, 1 }
|
|
|
|
};
|
|
|
|
|
2005-09-18 20:12:23 +00:00
|
|
|
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
|
2003-02-13 19:27:50 +00:00
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
static int par_setpin_internal(PROGRAMMER * pgm, int pin, int value)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
2006-04-13 20:10:55 +00:00
|
|
|
int inverted;
|
2003-02-13 19:27:50 +00:00
|
|
|
|
2006-04-13 20:10:55 +00:00
|
|
|
inverted = pin & PIN_INVERSE;
|
2005-09-18 20:12:23 +00:00
|
|
|
pin &= PIN_MASK;
|
|
|
|
|
2003-02-13 19:27:50 +00:00
|
|
|
if (pin < 1 || pin > 17)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pin--;
|
|
|
|
|
2005-09-18 20:12:23 +00:00
|
|
|
if (ppipins[pin].inverted)
|
2006-04-13 20:10:55 +00:00
|
|
|
inverted = !inverted;
|
|
|
|
|
|
|
|
if (inverted)
|
2003-02-13 19:27:50 +00:00
|
|
|
value = !value;
|
|
|
|
|
|
|
|
if (value)
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2003-02-13 19:27:50 +00:00
|
|
|
else
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2003-02-13 19:27:50 +00:00
|
|
|
|
2006-08-17 15:06:20 +00:00
|
|
|
if (pgm->ispdelay > 1)
|
|
|
|
bitbang_delay(pgm->ispdelay);
|
2003-02-13 19:27:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
static int par_setpin(PROGRAMMER * pgm, int pinfunc, int value)
|
|
|
|
{
|
|
|
|
return par_setpin_internal(pgm, pgm->pinno[pinfunc], value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void par_setmany(PROGRAMMER * pgm, int pinfunc, int value)
|
2006-08-29 21:39:26 +00:00
|
|
|
{
|
2012-11-13 21:34:02 +00:00
|
|
|
int pin, mask;
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
int pinset = pgm->pinno[pinfunc];
|
2012-11-13 21:34:02 +00:00
|
|
|
|
|
|
|
/* mask is anything non-pin - needs to be applied to each par_setpin to preserve inversion */
|
|
|
|
mask = pinset & (~PIN_MASK);
|
2006-08-29 21:39:26 +00:00
|
|
|
|
|
|
|
for (pin = 1; pin <= 17; pin++) {
|
|
|
|
if (pinset & (1 << pin))
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setpin_internal(pgm, pin | mask, value);
|
2006-08-29 21:39:26 +00:00
|
|
|
}
|
|
|
|
}
|
2003-02-13 19:27:50 +00:00
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
static int par_getpin(PROGRAMMER * pgm, int pinfunc)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
|
|
|
int value;
|
2006-04-13 20:10:55 +00:00
|
|
|
int inverted;
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
int pin = pgm->pinno[pinfunc];
|
2003-02-13 19:27:50 +00:00
|
|
|
|
2006-04-13 20:10:55 +00:00
|
|
|
inverted = pin & PIN_INVERSE;
|
2005-09-18 20:12:23 +00:00
|
|
|
pin &= PIN_MASK;
|
|
|
|
|
2003-02-13 19:27:50 +00:00
|
|
|
if (pin < 1 || pin > 17)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pin--;
|
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
value = ppi_get(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2003-02-13 19:27:50 +00:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
value = 1;
|
|
|
|
|
2005-09-18 20:12:23 +00:00
|
|
|
if (ppipins[pin].inverted)
|
2006-04-13 20:10:55 +00:00
|
|
|
inverted = !inverted;
|
|
|
|
|
|
|
|
if (inverted)
|
2003-02-13 19:27:50 +00:00
|
|
|
value = !value;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
static int par_highpulsepin(PROGRAMMER * pgm, int pinfunc)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
2006-04-13 20:10:55 +00:00
|
|
|
int inverted;
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
int pin = pgm->pinno[pinfunc];
|
2006-04-13 20:10:55 +00:00
|
|
|
|
|
|
|
inverted = pin & PIN_INVERSE;
|
|
|
|
pin &= PIN_MASK;
|
2003-02-13 19:27:50 +00:00
|
|
|
|
|
|
|
if (pin < 1 || pin > 17)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
pin--;
|
|
|
|
|
2006-04-13 20:10:55 +00:00
|
|
|
if (ppipins[pin].inverted)
|
|
|
|
inverted = !inverted;
|
|
|
|
|
|
|
|
if (inverted) {
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2006-08-17 15:06:20 +00:00
|
|
|
if (pgm->ispdelay > 1)
|
|
|
|
bitbang_delay(pgm->ispdelay);
|
2003-02-13 19:27:50 +00:00
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2006-08-17 15:06:20 +00:00
|
|
|
if (pgm->ispdelay > 1)
|
|
|
|
bitbang_delay(pgm->ispdelay);
|
2006-04-13 20:10:55 +00:00
|
|
|
} else {
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_set(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2006-08-17 15:06:20 +00:00
|
|
|
if (pgm->ispdelay > 1)
|
|
|
|
bitbang_delay(pgm->ispdelay);
|
2006-04-13 20:10:55 +00:00
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_clr(&pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
2006-08-17 15:06:20 +00:00
|
|
|
if (pgm->ispdelay > 1)
|
|
|
|
bitbang_delay(pgm->ispdelay);
|
2006-04-13 20:10:55 +00:00
|
|
|
}
|
2003-02-13 19:27:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* apply power to the AVR processor
|
|
|
|
*/
|
2005-11-01 23:02:06 +00:00
|
|
|
static void par_powerup(PROGRAMMER * pgm)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_VCC, 1); /* power up */
|
2003-02-13 19:27:50 +00:00
|
|
|
usleep(100000);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove power from the AVR processor
|
|
|
|
*/
|
2005-11-01 23:02:06 +00:00
|
|
|
static void par_powerdown(PROGRAMMER * pgm)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_VCC, 0); /* power down */
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
static void par_disable(PROGRAMMER * pgm)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_BUFF, 1); /* turn off */
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
static void par_enable(PROGRAMMER * pgm)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Prepare to start talking to the connected device - pull reset low
|
|
|
|
* first, delay a few milliseconds, then enable the buffer. This
|
|
|
|
* sequence allows the AVR to be reset before the buffer is enabled
|
|
|
|
* to avoid a short period of time where the AVR may be driving the
|
|
|
|
* programming lines at the same time the programmer tries to. Of
|
|
|
|
* course, if a buffer is being used, then the /RESET line from the
|
|
|
|
* programmer needs to be directly connected to the AVR /RESET line
|
|
|
|
* and not via the buffer chip.
|
|
|
|
*/
|
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setpin(pgm, PIN_AVR_RESET, 0);
|
2003-02-13 19:27:50 +00:00
|
|
|
usleep(1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* enable the 74367 buffer, if connected; this signal is active low
|
|
|
|
*/
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_BUFF, 0);
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
static int par_open(PROGRAMMER * pgm, char * port)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
2004-01-28 20:01:44 +00:00
|
|
|
int rc;
|
|
|
|
|
2014-05-16 15:52:25 +00:00
|
|
|
if (bitbang_check_prerequisites(pgm) < 0)
|
|
|
|
return -1;
|
2006-08-23 21:06:28 +00:00
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_open(port, &pgm->fd);
|
|
|
|
if (pgm->fd.ifd < 0) {
|
2014-05-18 08:41:46 +00:00
|
|
|
avrdude_message("%s: failed to open parallel port \"%s\"\n\n",
|
2003-02-13 19:27:50 +00:00
|
|
|
progname, port);
|
2014-05-16 15:52:25 +00:00
|
|
|
return -1;
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2004-01-28 20:01:44 +00:00
|
|
|
/*
|
|
|
|
* save pin values, so they can be restored when device is closed
|
|
|
|
*/
|
2006-12-11 12:47:35 +00:00
|
|
|
rc = ppi_getall(&pgm->fd, PPIDATA);
|
2004-01-28 20:01:44 +00:00
|
|
|
if (rc < 0) {
|
2014-05-18 08:41:46 +00:00
|
|
|
avrdude_message("%s: error reading status of ppi data port\n", progname);
|
2004-01-28 20:01:44 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pgm->ppidata = rc;
|
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
rc = ppi_getall(&pgm->fd, PPICTRL);
|
2004-01-28 20:01:44 +00:00
|
|
|
if (rc < 0) {
|
2014-05-18 08:41:46 +00:00
|
|
|
avrdude_message("%s: error reading status of ppi ctrl port\n", progname);
|
2004-01-28 20:01:44 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pgm->ppictrl = rc;
|
|
|
|
|
|
|
|
return 0;
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
static void par_close(PROGRAMMER * pgm)
|
2003-02-13 19:27:50 +00:00
|
|
|
{
|
2006-08-29 23:12:15 +00:00
|
|
|
|
2004-01-28 20:01:44 +00:00
|
|
|
/*
|
|
|
|
* Restore pin values before closing,
|
|
|
|
* but ensure that buffers are turned off.
|
|
|
|
*/
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_setall(&pgm->fd, PPIDATA, pgm->ppidata);
|
|
|
|
ppi_setall(&pgm->fd, PPICTRL, pgm->ppictrl);
|
2004-01-28 20:01:44 +00:00
|
|
|
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_BUFF, 1);
|
2006-08-29 23:12:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle exit specs.
|
|
|
|
*/
|
|
|
|
switch (pgm->exit_reset) {
|
|
|
|
case EXIT_RESET_ENABLED:
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setpin(pgm, PIN_AVR_RESET, 0);
|
2006-08-29 23:12:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_RESET_DISABLED:
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setpin(pgm, PIN_AVR_RESET, 1);
|
2006-08-29 23:12:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_RESET_UNSPEC:
|
|
|
|
/* Leave it alone. */
|
|
|
|
break;
|
|
|
|
}
|
2011-08-26 12:35:08 +00:00
|
|
|
|
|
|
|
switch (pgm->exit_datahigh) {
|
|
|
|
case EXIT_DATAHIGH_ENABLED:
|
|
|
|
ppi_setall(&pgm->fd, PPIDATA, 0xff);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_DATAHIGH_DISABLED:
|
|
|
|
ppi_setall(&pgm->fd, PPIDATA, 0x00);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_DATAHIGH_UNSPEC:
|
|
|
|
/* Leave it alone. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-08-29 23:12:15 +00:00
|
|
|
switch (pgm->exit_vcc) {
|
|
|
|
case EXIT_VCC_ENABLED:
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_VCC, 1);
|
2006-08-29 23:12:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_VCC_DISABLED:
|
Rework of bitbanging functions setpin, getpin, highpulsepin to make simplier use of new pindefs data in pgm structure
* linuxgpio.c, bitbang.c, buspirate.c, par.c, pgm.h, term.c, serbb_*.c: changed
interface of setpin, getpin, highpulsepin to take pin function as parameter
(not the real number, which can be found by pgm->pinno[function])
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1252 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-12-04 19:02:55 +00:00
|
|
|
par_setmany(pgm, PPI_AVR_VCC, 0);
|
2006-08-29 23:12:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXIT_VCC_UNSPEC:
|
|
|
|
/* Leave it alone. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
ppi_close(&pgm->fd);
|
|
|
|
pgm->fd.ifd = -1;
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 23:02:06 +00:00
|
|
|
/*
|
|
|
|
* parse the -E string
|
|
|
|
*/
|
2006-08-29 23:12:15 +00:00
|
|
|
static int par_parseexitspecs(PROGRAMMER * pgm, char *s)
|
2005-11-01 23:02:06 +00:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
while ((cp = strtok(s, ","))) {
|
|
|
|
if (strcmp(cp, "reset") == 0) {
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->exit_reset = EXIT_RESET_ENABLED;
|
2005-11-01 23:02:06 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(cp, "noreset") == 0) {
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->exit_reset = EXIT_RESET_DISABLED;
|
2005-11-01 23:02:06 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(cp, "vcc") == 0) {
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->exit_vcc = EXIT_VCC_ENABLED;
|
2005-11-01 23:02:06 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(cp, "novcc") == 0) {
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->exit_vcc = EXIT_VCC_DISABLED;
|
2005-11-01 23:02:06 +00:00
|
|
|
}
|
2011-08-26 12:35:08 +00:00
|
|
|
else if (strcmp(cp, "d_high") == 0) {
|
|
|
|
pgm->exit_datahigh = EXIT_DATAHIGH_ENABLED;
|
|
|
|
}
|
|
|
|
else if (strcmp(cp, "d_low") == 0) {
|
|
|
|
pgm->exit_datahigh = EXIT_DATAHIGH_DISABLED;
|
|
|
|
}
|
2005-11-01 23:02:06 +00:00
|
|
|
else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
s = 0; /* strtok() should be called with the actual string only once */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-02-13 19:27:50 +00:00
|
|
|
void par_initpgm(PROGRAMMER * pgm)
|
|
|
|
{
|
|
|
|
strcpy(pgm->type, "PPI");
|
|
|
|
|
2013-05-03 22:35:00 +00:00
|
|
|
pgm_fill_old_pins(pgm); // TODO to be removed if old pin data no longer needed
|
|
|
|
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->exit_vcc = EXIT_VCC_UNSPEC;
|
|
|
|
pgm->exit_reset = EXIT_RESET_UNSPEC;
|
2011-08-26 12:35:08 +00:00
|
|
|
pgm->exit_datahigh = EXIT_DATAHIGH_UNSPEC;
|
2006-08-29 23:12:15 +00:00
|
|
|
|
2005-09-18 20:12:23 +00:00
|
|
|
pgm->rdy_led = bitbang_rdy_led;
|
|
|
|
pgm->err_led = bitbang_err_led;
|
|
|
|
pgm->pgm_led = bitbang_pgm_led;
|
|
|
|
pgm->vfy_led = bitbang_vfy_led;
|
|
|
|
pgm->initialize = bitbang_initialize;
|
2012-02-01 22:26:58 +00:00
|
|
|
pgm->display = pgm_display_generic;
|
2003-02-13 19:27:50 +00:00
|
|
|
pgm->enable = par_enable;
|
|
|
|
pgm->disable = par_disable;
|
|
|
|
pgm->powerup = par_powerup;
|
|
|
|
pgm->powerdown = par_powerdown;
|
2005-09-18 20:12:23 +00:00
|
|
|
pgm->program_enable = bitbang_program_enable;
|
|
|
|
pgm->chip_erase = bitbang_chip_erase;
|
|
|
|
pgm->cmd = bitbang_cmd;
|
2011-08-23 21:03:36 +00:00
|
|
|
pgm->cmd_tpi = bitbang_cmd_tpi;
|
2009-02-17 15:31:27 +00:00
|
|
|
pgm->spi = bitbang_spi;
|
2003-02-13 19:27:50 +00:00
|
|
|
pgm->open = par_open;
|
|
|
|
pgm->close = par_close;
|
2005-11-01 23:02:06 +00:00
|
|
|
pgm->setpin = par_setpin;
|
|
|
|
pgm->getpin = par_getpin;
|
|
|
|
pgm->highpulsepin = par_highpulsepin;
|
2006-08-29 23:12:15 +00:00
|
|
|
pgm->parseexitspecs = par_parseexitspecs;
|
2006-11-20 15:04:09 +00:00
|
|
|
pgm->read_byte = avr_read_byte_default;
|
|
|
|
pgm->write_byte = avr_write_byte_default;
|
2003-02-13 19:27:50 +00:00
|
|
|
}
|
2005-11-01 23:02:06 +00:00
|
|
|
|
|
|
|
#else /* !HAVE_PARPORT */
|
|
|
|
|
|
|
|
void par_initpgm(PROGRAMMER * pgm)
|
|
|
|
{
|
2014-05-18 08:41:46 +00:00
|
|
|
avrdude_message("%s: parallel port access not available in this configuration\n",
|
|
|
|
progname);
|
2005-11-01 23:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_PARPORT */
|
2012-02-03 07:21:39 +00:00
|
|
|
|
|
|
|
const char par_desc[] = "Parallel port bitbanging";
|