Make avrdude Solaris-compatible.
* Makefile.am: distclean avrdude.conf. * avrdude.conf.in: make the parallel-port programmers optional. * bitbang.c: move the bitbang features out into PROGRAMMER. * configure.ac: introduce --enable-parport, add Solaris. * lexer.l: replace str by strng to work around problems in some versions of flex. * main.c: move getexitspecs into the respective programmer's domain; replace rindex by the C-standard strrchr. * par.c: make parallel port optional. * par.h: everything but par_initpgm() is private now. * pgm.h: add setping/getping/highpulsepin/getexitspecs. * serbb_posix.c: generalize bitbang interface; replace cfmakeraw() by explicit code. * serbb_win32.c: generalize bitbang interface. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@539 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
a1c528dbe2
commit
496ab3fd81
|
@ -1,3 +1,21 @@
|
|||
2005-11-01 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
Make avrdude Solaris-compatible.
|
||||
* Makefile.am: distclean avrdude.conf.
|
||||
* avrdude.conf.in: make the parallel-port programmers optional.
|
||||
* bitbang.c: move the bitbang features out into PROGRAMMER.
|
||||
* configure.ac: introduce --enable-parport, add Solaris.
|
||||
* lexer.l: replace str by strng to work around problems in some
|
||||
versions of flex.
|
||||
* main.c: move getexitspecs into the respective programmer's
|
||||
domain; replace rindex by the C-standard strrchr.
|
||||
* par.c: make parallel port optional.
|
||||
* par.h: everything but par_initpgm() is private now.
|
||||
* pgm.h: add setping/getping/highpulsepin/getexitspecs.
|
||||
* serbb_posix.c: generalize bitbang interface; replace
|
||||
cfmakeraw() by explicit code.
|
||||
* serbb_win32.c: generalize bitbang interface.
|
||||
|
||||
2005-10-20 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* butterfly.c: fix yet another sign extension bug.
|
||||
|
|
|
@ -108,6 +108,9 @@ sysconf_DATA = avrdude.conf
|
|||
|
||||
install-exec-local: backup-avrdude-conf
|
||||
|
||||
distclean-local:
|
||||
rm -f avrdude.conf
|
||||
|
||||
# This will get run before the config file is installed.
|
||||
backup-avrdude-conf:
|
||||
@echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}"
|
||||
|
|
|
@ -220,17 +220,6 @@ default_serial = "@DEFAULT_SER_PORT@";
|
|||
# PROGRAMMER DEFINITIONS
|
||||
#
|
||||
|
||||
programmer
|
||||
id = "bsd";
|
||||
desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
|
||||
type = par;
|
||||
vcc = 2, 3, 4, 5;
|
||||
reset = 7;
|
||||
sck = 8;
|
||||
mosi = 9;
|
||||
miso = 10;
|
||||
;
|
||||
|
||||
programmer
|
||||
id = "avrisp";
|
||||
desc = "Atmel AVR ISP";
|
||||
|
@ -316,6 +305,20 @@ programmer
|
|||
type = avr910;
|
||||
;
|
||||
|
||||
@HAVE_PARPORT_BEGIN@ Inclusion of the following depends on --enable-parport
|
||||
# Parallel port programmers.
|
||||
|
||||
programmer
|
||||
id = "bsd";
|
||||
desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
|
||||
type = par;
|
||||
vcc = 2, 3, 4, 5;
|
||||
reset = 7;
|
||||
sck = 8;
|
||||
mosi = 9;
|
||||
miso = 10;
|
||||
;
|
||||
|
||||
programmer
|
||||
id = "stk200";
|
||||
desc = "STK200";
|
||||
|
@ -452,6 +455,7 @@ programmer
|
|||
miso = 11;
|
||||
;
|
||||
|
||||
@HAVE_PARPORT_END@
|
||||
|
||||
#
|
||||
# some ultra cheap programmers use bitbanging on the
|
||||
|
|
|
@ -40,35 +40,6 @@ extern char * progname;
|
|||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
static int bitbang_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
serbb_setpin(pgm->fd,pin,value);
|
||||
else
|
||||
par_setpin(pgm->fd,pin,value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int bitbang_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
return serbb_getpin(pgm->fd,pin);
|
||||
else
|
||||
return par_getpin(pgm->fd,pin);
|
||||
}
|
||||
|
||||
|
||||
static int bitbang_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
return serbb_highpulsepin(pgm->fd,pin);
|
||||
else
|
||||
return par_highpulsepin(pgm->fd,pin);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* transmit and receive a byte of data to/from the AVR device
|
||||
*/
|
||||
|
@ -82,7 +53,7 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
|||
/*
|
||||
* Write and read one bit on SPI.
|
||||
* Some notes on timing: Let T be the time it takes to do
|
||||
* one bitbang_setpin()-call resp. par clrpin()-call, then
|
||||
* one pgm->setpin()-call resp. par clrpin()-call, then
|
||||
* - SCK is high for 2T
|
||||
* - SCK is low for 2T
|
||||
* - MOSI setuptime is 1T
|
||||
|
@ -99,17 +70,17 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
|||
b = (byte >> i) & 0x01;
|
||||
|
||||
/* set the data input line as desired */
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1);
|
||||
|
||||
/*
|
||||
* read the result bit (it is either valid from a previous falling
|
||||
* edge or it is ignored in the current context)
|
||||
*/
|
||||
r = bitbang_getpin(pgm, pgm->pinno[PIN_AVR_MISO]);
|
||||
r = pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
|
||||
rbyte |= r << i;
|
||||
}
|
||||
|
@ -120,25 +91,25 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
|||
|
||||
int bitbang_rdy_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_RDY], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_RDY], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_err_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_ERR], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_ERR], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_pgm_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_PGM], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_vfy_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_VFY], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_VFY], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -236,11 +207,11 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
pgm->powerup(pgm);
|
||||
usleep(20000);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
usleep(20000);
|
||||
|
||||
bitbang_highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]);
|
||||
pgm->highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]);
|
||||
|
||||
usleep(20000); /* 20 ms XXX should be a per-chip parameter */
|
||||
|
||||
|
@ -261,7 +232,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||
rc = pgm->program_enable(pgm, p);
|
||||
if ((rc == 0)||(rc == -1))
|
||||
break;
|
||||
bitbang_highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
||||
pgm->highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
||||
tries++;
|
||||
} while (tries < 65);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ AC_CANONICAL_TARGET
|
|||
|
||||
AC_CONFIG_SRCDIR([main.c])
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER([ac_cfg.h])
|
||||
AM_CONFIG_HEADER([ac_cfg.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
|
@ -93,6 +93,18 @@ AC_ARG_ENABLE(
|
|||
esac],
|
||||
[enabled_doc=no])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[parport],
|
||||
AC_HELP_STRING(
|
||||
[--enable-parport],
|
||||
[Enable accessing parallel ports(default)]),
|
||||
[case "${enableval}" in
|
||||
yes) enabled_parport=yes ;;
|
||||
no) enabled_parport=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
|
||||
esac],
|
||||
[enabled_parport=yes])
|
||||
|
||||
if test "$enabled_doc" = "yes"; then
|
||||
|
||||
SUBDIRS_AC='doc @WINDOWS_DIRS@'
|
||||
|
@ -104,7 +116,7 @@ DIST_SUBDIRS_AC='windows'
|
|||
fi
|
||||
|
||||
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
|
||||
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
|
||||
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
|
||||
AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC)
|
||||
|
||||
|
||||
|
@ -127,6 +139,10 @@ case $target in
|
|||
DEFAULT_PAR_PORT="unknown"
|
||||
DEFAULT_SER_PORT="/dev/cuaa0"
|
||||
;;
|
||||
*-*-solaris*)
|
||||
DEFAULT_PAR_PORT="unknown"
|
||||
DEFAULT_SER_PORT="/dev/term/a"
|
||||
;;
|
||||
*-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||
DEFAULT_PAR_PORT="lpt1"
|
||||
DEFAULT_SER_PORT="com1"
|
||||
|
@ -137,14 +153,29 @@ case $target in
|
|||
;;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING([for parallel device])
|
||||
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
|
||||
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
|
||||
if test "$enabled_parport" = "yes"; then
|
||||
AC_MSG_CHECKING([for parallel device])
|
||||
if test "$DEFAULT_PAR_PORT" = "unknown"; then
|
||||
AC_MSG_NOTICE([parallel port access disabled for this system])
|
||||
enabled_parport=no
|
||||
else
|
||||
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
|
||||
fi
|
||||
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for serial device])
|
||||
AC_MSG_RESULT([$DEFAULT_SER_PORT])
|
||||
AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT)
|
||||
|
||||
if test "$enabled_parport" = "yes"; then
|
||||
AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled])
|
||||
confsubst="-e /^@HAVE_PARPORT_/d"
|
||||
else
|
||||
confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d"
|
||||
fi
|
||||
export confsubst
|
||||
|
||||
# See if we need to drop into the windows subdir.
|
||||
case $target in
|
||||
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||
|
@ -168,9 +199,17 @@ fi
|
|||
AC_CONFIG_FILES([
|
||||
windows/Makefile
|
||||
avrdude.spec
|
||||
avrdude.conf
|
||||
Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
# The procedure to create avrdude.conf involves two steps. First,
|
||||
# normal autoconf substitution will be applied, resulting in
|
||||
# avrdude.conf.tmp. Finally, a sed command will be applied to filter
|
||||
# out unwanted parts (currently the parallel port programmer types)
|
||||
# based on previous configuration results, thereby producing the final
|
||||
# avrdude.conf file.
|
||||
|
||||
AC_CONFIG_FILES([avrdude.conf.tmp:avrdude.conf.in],
|
||||
[sed $confsubst avrdude.conf.tmp > avrdude.conf])
|
||||
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -46,7 +46,7 @@ HEXDIGIT [0-9a-fA-F]
|
|||
ID [_a-zA-Z][_a-zA-Z0-9]*
|
||||
SIGN [+-]
|
||||
|
||||
%x str
|
||||
%x strng
|
||||
%x incl
|
||||
%x comment
|
||||
|
||||
|
@ -56,7 +56,7 @@ SIGN [+-]
|
|||
{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
|
||||
{SIGN}*"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
|
||||
|
||||
"\"" { string_buf_ptr = string_buf; BEGIN(str); }
|
||||
"\"" { string_buf_ptr = string_buf; BEGIN(strng); }
|
||||
|
||||
0x{HEXDIGIT}+ { yylval = hexnumber(yytext); return TKN_NUMBER; }
|
||||
|
||||
|
@ -99,7 +99,7 @@ SIGN [+-]
|
|||
}
|
||||
|
||||
|
||||
<str>{
|
||||
<strng>{
|
||||
\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
|
||||
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
|
||||
\\n *string_buf_ptr++ = '\n';
|
||||
|
|
|
@ -129,39 +129,6 @@ void usage(void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* parse the -E string
|
||||
*/
|
||||
int getexitspecs(char *s, int *set, int *clr)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
while ((cp = strtok(s, ","))) {
|
||||
if (strcmp(cp, "reset") == 0) {
|
||||
*clr |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "noreset") == 0) {
|
||||
*set |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "vcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*set |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else if (strcmp(cp, "novcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*clr |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
s = 0; /* strtok() should be called with the actual string only once */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int read_config(char * file)
|
||||
{
|
||||
FILE * f;
|
||||
|
@ -742,11 +709,11 @@ int main(int argc, char * argv [])
|
|||
char * homedir;
|
||||
#endif
|
||||
|
||||
progname = rindex(argv[0],'/');
|
||||
progname = strrchr(argv[0],'/');
|
||||
|
||||
#if defined (WIN32NATIVE)
|
||||
/* take care of backslash as dir sep in W32 */
|
||||
if (!progname) progname = rindex(argv[0],'\\');
|
||||
if (!progname) progname = strrchr(argv[0],'\\');
|
||||
#endif /* WIN32NATIVE */
|
||||
|
||||
if (progname)
|
||||
|
@ -1106,14 +1073,13 @@ int main(int argc, char * argv [])
|
|||
|
||||
|
||||
if (exitspecs != NULL) {
|
||||
if (strcmp(pgm->type, "PPI") != 0) {
|
||||
if (pgm->getexitspecs == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: -E option is only valid with \"PPI\" "
|
||||
"programmer types\n",
|
||||
"%s: WARNING: -E option not supported by this programmer type\n",
|
||||
progname);
|
||||
exitspecs = NULL;
|
||||
}
|
||||
else if (getexitspecs(exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
||||
else if (pgm->getexitspecs(pgm, exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
#include "ppi.h"
|
||||
#include "bitbang.h"
|
||||
|
||||
extern char * progname;
|
||||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
#if HAVE_PARPORT
|
||||
|
||||
#define SLOW_TOGGLE 0
|
||||
|
||||
struct ppipins_t {
|
||||
|
@ -71,12 +77,7 @@ struct ppipins_t ppipins[] = {
|
|||
|
||||
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
|
||||
|
||||
|
||||
extern char * progname;
|
||||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
int par_setpin(int fd, int pin, int value)
|
||||
static int par_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
|
||||
pin &= PIN_MASK;
|
||||
|
@ -90,9 +91,9 @@ int par_setpin(int fd, int pin, int value)
|
|||
value = !value;
|
||||
|
||||
if (value)
|
||||
ppi_set(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
else
|
||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
|
@ -102,7 +103,7 @@ int par_setpin(int fd, int pin, int value)
|
|||
}
|
||||
|
||||
|
||||
int par_getpin(int fd, int pin)
|
||||
static int par_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
int value;
|
||||
|
||||
|
@ -113,7 +114,7 @@ int par_getpin(int fd, int pin)
|
|||
|
||||
pin--;
|
||||
|
||||
value = ppi_get(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
value = ppi_get(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
if (value)
|
||||
value = 1;
|
||||
|
@ -125,7 +126,7 @@ int par_getpin(int fd, int pin)
|
|||
}
|
||||
|
||||
|
||||
int par_highpulsepin(int fd, int pin)
|
||||
static int par_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
|
||||
if (pin < 1 || pin > 17)
|
||||
|
@ -133,11 +134,11 @@ int par_highpulsepin(int fd, int pin)
|
|||
|
||||
pin--;
|
||||
|
||||
ppi_set(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
|
@ -158,7 +159,7 @@ int par_getpinmask(int pin)
|
|||
|
||||
|
||||
char vccpins_buf[64];
|
||||
char * vccpins_str(unsigned int pmask)
|
||||
static char * vccpins_str(unsigned int pmask)
|
||||
{
|
||||
unsigned int mask;
|
||||
int pin;
|
||||
|
@ -183,7 +184,7 @@ char * vccpins_str(unsigned int pmask)
|
|||
/*
|
||||
* apply power to the AVR processor
|
||||
*/
|
||||
void par_powerup(PROGRAMMER * pgm)
|
||||
static void par_powerup(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */
|
||||
usleep(100000);
|
||||
|
@ -193,17 +194,17 @@ void par_powerup(PROGRAMMER * pgm)
|
|||
/*
|
||||
* remove power from the AVR processor
|
||||
*/
|
||||
void par_powerdown(PROGRAMMER * pgm)
|
||||
static void par_powerdown(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power down */
|
||||
}
|
||||
|
||||
void par_disable(PROGRAMMER * pgm)
|
||||
static void par_disable(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
|
||||
}
|
||||
|
||||
void par_enable(PROGRAMMER * pgm)
|
||||
static void par_enable(PROGRAMMER * pgm)
|
||||
{
|
||||
/*
|
||||
* Prepare to start talking to the connected device - pull reset low
|
||||
|
@ -216,7 +217,7 @@ void par_enable(PROGRAMMER * pgm)
|
|||
* and not via the buffer chip.
|
||||
*/
|
||||
|
||||
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
usleep(1);
|
||||
|
||||
/*
|
||||
|
@ -225,7 +226,7 @@ void par_enable(PROGRAMMER * pgm)
|
|||
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
|
||||
}
|
||||
|
||||
int par_open(PROGRAMMER * pgm, char * port)
|
||||
static int par_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
@ -259,7 +260,7 @@ int par_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
|
||||
void par_close(PROGRAMMER * pgm)
|
||||
static void par_close(PROGRAMMER * pgm)
|
||||
{
|
||||
/*
|
||||
* Restore pin values before closing,
|
||||
|
@ -275,7 +276,7 @@ void par_close(PROGRAMMER * pgm)
|
|||
pgm->fd = -1;
|
||||
}
|
||||
|
||||
void par_display(PROGRAMMER * pgm, char * p)
|
||||
static void par_display(PROGRAMMER * pgm, char * p)
|
||||
{
|
||||
char vccpins[64];
|
||||
char buffpins[64];
|
||||
|
@ -320,6 +321,38 @@ void par_display(PROGRAMMER * pgm, char * p)
|
|||
p, pgm->pinno[PIN_LED_VFY]);
|
||||
}
|
||||
|
||||
/*
|
||||
* parse the -E string
|
||||
*/
|
||||
static int par_getexitspecs(PROGRAMMER * pgm, char *s, int *set, int *clr)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
while ((cp = strtok(s, ","))) {
|
||||
if (strcmp(cp, "reset") == 0) {
|
||||
*clr |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "noreset") == 0) {
|
||||
*set |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "vcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*set |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else if (strcmp(cp, "novcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*clr |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
s = 0; /* strtok() should be called with the actual string only once */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void par_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
|
@ -340,7 +373,19 @@ void par_initpgm(PROGRAMMER * pgm)
|
|||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = par_open;
|
||||
pgm->close = par_close;
|
||||
|
||||
/* this is a parallel port bitbang device */
|
||||
pgm->flag = 0;
|
||||
pgm->setpin = par_setpin;
|
||||
pgm->getpin = par_getpin;
|
||||
pgm->highpulsepin = par_highpulsepin;
|
||||
pgm->getexitspecs = par_getexitspecs;
|
||||
}
|
||||
|
||||
#else /* !HAVE_PARPORT */
|
||||
|
||||
void par_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: parallel port access not available in this configuration\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
#endif /* HAVE_PARPORT */
|
||||
|
|
|
@ -24,11 +24,6 @@
|
|||
|
||||
void par_initpgm (PROGRAMMER * pgm);
|
||||
|
||||
int par_getpinmask(int pin);
|
||||
int par_setpin(int fd, int pin, int value);
|
||||
int par_getpin(int fd, int pin);
|
||||
int par_highpulsepin(int fd, int pin);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,10 @@ typedef struct programmer_t {
|
|||
int (*set_varef) (struct programmer_t * pgm, double v);
|
||||
int (*set_fosc) (struct programmer_t * pgm, double v);
|
||||
int (*set_sck_period) (struct programmer_t * pgm, double v);
|
||||
int (*setpin) (struct programmer_t * pgm, int pin, int value);
|
||||
int (*getpin) (struct programmer_t * pgm, int pin);
|
||||
int (*highpulsepin) (struct programmer_t * pgm, int pin);
|
||||
int (*getexitspecs) (struct programmer_t * pgm, char *s, int *set, int *clr);
|
||||
char config_file[PATH_MAX]; /* config file where defined */
|
||||
int lineno; /* config file line number */
|
||||
char flag; /* for private use of the programmer */
|
||||
|
@ -104,8 +108,6 @@ void usleep(unsigned long us);
|
|||
|
||||
void gettimeofday(struct timeval*, void*z);
|
||||
|
||||
#define rindex strrchr
|
||||
|
||||
#endif /* __win32native_h */
|
||||
|
||||
|
||||
|
|
|
@ -58,15 +58,15 @@ struct termios oldmode;
|
|||
7 cts <-
|
||||
*/
|
||||
|
||||
int serregbits[] =
|
||||
static int serregbits[] =
|
||||
{ TIOCM_CD, 0, 0, TIOCM_DTR, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS };
|
||||
|
||||
#ifdef DEBUG
|
||||
char *serpins[7] =
|
||||
static char *serpins[7] =
|
||||
{ "CD", "RXD", "TXD ~RESET", "DTR MOSI", "DSR", "RTS SCK", "CTS MISO" };
|
||||
#endif
|
||||
|
||||
void serbb_setpin(int fd, int pin, int value)
|
||||
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
unsigned int ctl;
|
||||
|
||||
|
@ -77,7 +77,7 @@ void serbb_setpin(int fd, int pin, int value)
|
|||
}
|
||||
|
||||
if ( pin < 1 || pin > 7 )
|
||||
return;
|
||||
return -1;
|
||||
|
||||
pin--;
|
||||
|
||||
|
@ -88,24 +88,24 @@ void serbb_setpin(int fd, int pin, int value)
|
|||
switch ( pin )
|
||||
{
|
||||
case 2: /* txd */
|
||||
ioctl(fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||
return;
|
||||
ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||
return 0;
|
||||
|
||||
case 3: /* dtr, rts */
|
||||
case 5: ioctl(fd, TIOCMGET, &ctl);
|
||||
case 5: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||
if ( value )
|
||||
ctl |= serregbits[pin];
|
||||
else
|
||||
ctl &= ~(serregbits[pin]);
|
||||
ioctl(fd, TIOCMSET, &ctl);
|
||||
return;
|
||||
ioctl(pgm->fd, TIOCMSET, &ctl);
|
||||
return 0;
|
||||
|
||||
default: /* impossible */
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int serbb_getpin(int fd, int pin)
|
||||
static int serbb_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
unsigned int ctl;
|
||||
unsigned char invert;
|
||||
|
@ -131,7 +131,7 @@ int serbb_getpin(int fd, int pin)
|
|||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6: ioctl(fd, TIOCMGET, &ctl);
|
||||
case 6: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||
if ( !invert )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -152,16 +152,16 @@ int serbb_getpin(int fd, int pin)
|
|||
}
|
||||
}
|
||||
|
||||
int serbb_highpulsepin(int fd, int pin)
|
||||
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if (pin < 1 || pin > 7)
|
||||
return -1;
|
||||
|
||||
serbb_setpin(fd, pin, 1);
|
||||
serbb_setpin(pgm, pin, 1);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
serbb_setpin(fd, pin, 0);
|
||||
serbb_setpin(pgm, pin, 0);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
|
@ -172,32 +172,32 @@ int serbb_highpulsepin(int fd, int pin)
|
|||
|
||||
|
||||
|
||||
void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
static void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
{
|
||||
/* MAYBE */
|
||||
}
|
||||
|
||||
void serbb_enable(PROGRAMMER *pgm)
|
||||
static void serbb_enable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_disable(PROGRAMMER *pgm)
|
||||
static void serbb_disable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerup(PROGRAMMER *pgm)
|
||||
static void serbb_powerup(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerdown(PROGRAMMER *pgm)
|
||||
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
{
|
||||
struct termios mode;
|
||||
int flags;
|
||||
|
@ -206,41 +206,40 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
|
||||
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
||||
if ( pgm->fd > 0 )
|
||||
{
|
||||
tcgetattr(pgm->fd, &mode);
|
||||
oldmode = mode;
|
||||
if (pgm->fd < 0)
|
||||
return(-1);
|
||||
|
||||
cfmakeraw(&mode);
|
||||
mode.c_iflag &= ~(INPCK | IXOFF | IXON);
|
||||
mode.c_cflag &= ~(HUPCL | CSTOPB | CRTSCTS);
|
||||
mode.c_cflag |= (CLOCAL | CREAD);
|
||||
mode.c_cc [VMIN] = 1;
|
||||
mode.c_cc [VTIME] = 0;
|
||||
tcgetattr(pgm->fd, &mode);
|
||||
oldmode = mode;
|
||||
|
||||
tcsetattr(pgm->fd, TCSANOW, &mode);
|
||||
mode.c_iflag = IGNBRK | IGNPAR;
|
||||
mode.c_oflag = 0;
|
||||
mode.c_cflag = CLOCAL | CREAD | CS8 | B9600;
|
||||
mode.c_cc [VMIN] = 1;
|
||||
mode.c_cc [VTIME] = 0;
|
||||
|
||||
/* Clear O_NONBLOCK flag. */
|
||||
flags = fcntl(pgm->fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
tcsetattr(pgm->fd, TCSANOW, &mode);
|
||||
|
||||
/* Clear O_NONBLOCK flag. */
|
||||
flags = fcntl(pgm->fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not get flags\n", progname);
|
||||
return(-1);
|
||||
}
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not clear nonblock flag\n", progname);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void serbb_close(PROGRAMMER *pgm)
|
||||
static void serbb_close(PROGRAMMER *pgm)
|
||||
{
|
||||
tcsetattr(pgm->fd, TCSADRAIN, &oldmode);
|
||||
tcsetattr(pgm->fd, TCSANOW, &oldmode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,9 +262,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
|||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = serbb_open;
|
||||
pgm->close = serbb_close;
|
||||
|
||||
/* this is a serial port bitbang device */
|
||||
pgm->flag = 1;
|
||||
pgm->setpin = serbb_setpin;
|
||||
pgm->getpin = serbb_getpin;
|
||||
pgm->highpulsepin = serbb_highpulsepin;
|
||||
}
|
||||
|
||||
#endif /* WIN32NATIVE */
|
||||
|
|
|
@ -59,9 +59,9 @@ static int dtr, rts, txd;
|
|||
Negative pin # means negated value.
|
||||
*/
|
||||
|
||||
void serbb_setpin(int fd, int pin, int value)
|
||||
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
HANDLE hComPort = (HANDLE)fd;
|
||||
HANDLE hComPort = (HANDLE)pgm->fd;
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD dwFunc;
|
||||
const char *name;
|
||||
|
@ -73,7 +73,7 @@ void serbb_setpin(int fd, int pin, int value)
|
|||
}
|
||||
|
||||
if (pin < 1 || pin > 7)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
pin--;
|
||||
|
||||
|
@ -101,7 +101,7 @@ void serbb_setpin(int fd, int pin, int value)
|
|||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 4)
|
||||
fprintf(stderr,
|
||||
|
@ -126,12 +126,12 @@ void serbb_setpin(int fd, int pin, int value)
|
|||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serbb_getpin(int fd, int pin)
|
||||
static int serbb_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
HANDLE hComPort = (HANDLE)fd;
|
||||
HANDLE hComPort = (HANDLE)pgm->fd;
|
||||
LPVOID lpMsgBuf;
|
||||
int invert, rv;
|
||||
const char *name;
|
||||
|
@ -224,16 +224,16 @@ int serbb_getpin(int fd, int pin)
|
|||
return rv;
|
||||
}
|
||||
|
||||
int serbb_highpulsepin(int fd, int pin)
|
||||
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if (pin < 1 || pin > 7)
|
||||
return -1;
|
||||
|
||||
serbb_setpin(fd, pin, 1);
|
||||
serbb_setpin(pgm, pin, 1);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
serbb_setpin(fd, pin, 0);
|
||||
serbb_setpin(pgm, pin, 0);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
|
@ -243,32 +243,32 @@ int serbb_highpulsepin(int fd, int pin)
|
|||
}
|
||||
|
||||
|
||||
void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
static void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
{
|
||||
/* MAYBE */
|
||||
}
|
||||
|
||||
void serbb_enable(PROGRAMMER *pgm)
|
||||
static void serbb_enable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_disable(PROGRAMMER *pgm)
|
||||
static void serbb_disable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerup(PROGRAMMER *pgm)
|
||||
static void serbb_powerup(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerdown(PROGRAMMER *pgm)
|
||||
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
{
|
||||
DCB dcb;
|
||||
LPVOID lpMsgBuf;
|
||||
|
@ -332,7 +332,7 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void serbb_close(PROGRAMMER *pgm)
|
||||
static void serbb_close(PROGRAMMER *pgm)
|
||||
{
|
||||
HANDLE hComPort=(HANDLE)pgm->fd;
|
||||
if (hComPort != INVALID_HANDLE_VALUE)
|
||||
|
@ -364,9 +364,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
|||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = serbb_open;
|
||||
pgm->close = serbb_close;
|
||||
|
||||
/* this is a serial port bitbang device */
|
||||
pgm->flag = 1;
|
||||
pgm->setpin = serbb_setpin;
|
||||
pgm->getpin = serbb_getpin;
|
||||
pgm->highpulsepin = serbb_highpulsepin;
|
||||
}
|
||||
|
||||
#endif /* WIN32NATIVE */
|
||||
|
|
Loading…
Reference in New Issue