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>
|
2005-10-20 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||||
|
|
||||||
* butterfly.c: fix yet another sign extension bug.
|
* butterfly.c: fix yet another sign extension bug.
|
||||||
|
|
|
@ -108,6 +108,9 @@ sysconf_DATA = avrdude.conf
|
||||||
|
|
||||||
install-exec-local: backup-avrdude-conf
|
install-exec-local: backup-avrdude-conf
|
||||||
|
|
||||||
|
distclean-local:
|
||||||
|
rm -f avrdude.conf
|
||||||
|
|
||||||
# This will get run before the config file is installed.
|
# This will get run before the config file is installed.
|
||||||
backup-avrdude-conf:
|
backup-avrdude-conf:
|
||||||
@echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}"
|
@echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}"
|
||||||
|
|
|
@ -220,17 +220,6 @@ default_serial = "@DEFAULT_SER_PORT@";
|
||||||
# PROGRAMMER DEFINITIONS
|
# 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
|
programmer
|
||||||
id = "avrisp";
|
id = "avrisp";
|
||||||
desc = "Atmel AVR ISP";
|
desc = "Atmel AVR ISP";
|
||||||
|
@ -316,6 +305,20 @@ programmer
|
||||||
type = avr910;
|
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
|
programmer
|
||||||
id = "stk200";
|
id = "stk200";
|
||||||
desc = "STK200";
|
desc = "STK200";
|
||||||
|
@ -452,6 +455,7 @@ programmer
|
||||||
miso = 11;
|
miso = 11;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@HAVE_PARPORT_END@
|
||||||
|
|
||||||
#
|
#
|
||||||
# some ultra cheap programmers use bitbanging on the
|
# some ultra cheap programmers use bitbanging on the
|
||||||
|
|
|
@ -40,35 +40,6 @@ extern char * progname;
|
||||||
extern int do_cycles;
|
extern int do_cycles;
|
||||||
extern int verbose;
|
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
|
* 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.
|
* Write and read one bit on SPI.
|
||||||
* Some notes on timing: Let T be the time it takes to do
|
* 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 high for 2T
|
||||||
* - SCK is low for 2T
|
* - SCK is low for 2T
|
||||||
* - MOSI setuptime is 1T
|
* - MOSI setuptime is 1T
|
||||||
|
@ -99,17 +70,17 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
||||||
b = (byte >> i) & 0x01;
|
b = (byte >> i) & 0x01;
|
||||||
|
|
||||||
/* set the data input line as desired */
|
/* 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
|
* read the result bit (it is either valid from a previous falling
|
||||||
* edge or it is ignored in the current context)
|
* 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;
|
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)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitbang_err_led(PROGRAMMER * pgm, int value)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitbang_pgm_led(PROGRAMMER * pgm, int value)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitbang_vfy_led(PROGRAMMER * pgm, int value)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,11 +207,11 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||||
pgm->powerup(pgm);
|
pgm->powerup(pgm);
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
|
|
||||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||||
usleep(20000);
|
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 */
|
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);
|
rc = pgm->program_enable(pgm, p);
|
||||||
if ((rc == 0)||(rc == -1))
|
if ((rc == 0)||(rc == -1))
|
||||||
break;
|
break;
|
||||||
bitbang_highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
pgm->highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
||||||
tries++;
|
tries++;
|
||||||
} while (tries < 65);
|
} while (tries < 65);
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,18 @@ AC_ARG_ENABLE(
|
||||||
esac],
|
esac],
|
||||||
[enabled_doc=no])
|
[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
|
if test "$enabled_doc" = "yes"; then
|
||||||
|
|
||||||
SUBDIRS_AC='doc @WINDOWS_DIRS@'
|
SUBDIRS_AC='doc @WINDOWS_DIRS@'
|
||||||
|
@ -127,6 +139,10 @@ case $target in
|
||||||
DEFAULT_PAR_PORT="unknown"
|
DEFAULT_PAR_PORT="unknown"
|
||||||
DEFAULT_SER_PORT="/dev/cuaa0"
|
DEFAULT_SER_PORT="/dev/cuaa0"
|
||||||
;;
|
;;
|
||||||
|
*-*-solaris*)
|
||||||
|
DEFAULT_PAR_PORT="unknown"
|
||||||
|
DEFAULT_SER_PORT="/dev/term/a"
|
||||||
|
;;
|
||||||
*-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
*-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||||
DEFAULT_PAR_PORT="lpt1"
|
DEFAULT_PAR_PORT="lpt1"
|
||||||
DEFAULT_SER_PORT="com1"
|
DEFAULT_SER_PORT="com1"
|
||||||
|
@ -137,14 +153,29 @@ case $target in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
AC_MSG_CHECKING([for parallel device])
|
if test "$enabled_parport" = "yes"; then
|
||||||
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
|
AC_MSG_CHECKING([for parallel device])
|
||||||
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
|
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_CHECKING([for serial device])
|
||||||
AC_MSG_RESULT([$DEFAULT_SER_PORT])
|
AC_MSG_RESULT([$DEFAULT_SER_PORT])
|
||||||
AC_SUBST(DEFAULT_SER_PORT, $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.
|
# See if we need to drop into the windows subdir.
|
||||||
case $target in
|
case $target in
|
||||||
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
|
||||||
|
@ -168,9 +199,17 @@ fi
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
windows/Makefile
|
windows/Makefile
|
||||||
avrdude.spec
|
avrdude.spec
|
||||||
avrdude.conf
|
|
||||||
Makefile
|
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]*
|
ID [_a-zA-Z][_a-zA-Z0-9]*
|
||||||
SIGN [+-]
|
SIGN [+-]
|
||||||
|
|
||||||
%x str
|
%x strng
|
||||||
%x incl
|
%x incl
|
||||||
%x comment
|
%x comment
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ SIGN [+-]
|
||||||
{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
|
{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
|
||||||
{SIGN}*"."{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; }
|
0x{HEXDIGIT}+ { yylval = hexnumber(yytext); return TKN_NUMBER; }
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ SIGN [+-]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<str>{
|
<strng>{
|
||||||
\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
|
\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
|
||||||
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
|
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
|
||||||
\\n *string_buf_ptr++ = '\n';
|
\\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)
|
int read_config(char * file)
|
||||||
{
|
{
|
||||||
FILE * f;
|
FILE * f;
|
||||||
|
@ -742,11 +709,11 @@ int main(int argc, char * argv [])
|
||||||
char * homedir;
|
char * homedir;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
progname = rindex(argv[0],'/');
|
progname = strrchr(argv[0],'/');
|
||||||
|
|
||||||
#if defined (WIN32NATIVE)
|
#if defined (WIN32NATIVE)
|
||||||
/* take care of backslash as dir sep in W32 */
|
/* take care of backslash as dir sep in W32 */
|
||||||
if (!progname) progname = rindex(argv[0],'\\');
|
if (!progname) progname = strrchr(argv[0],'\\');
|
||||||
#endif /* WIN32NATIVE */
|
#endif /* WIN32NATIVE */
|
||||||
|
|
||||||
if (progname)
|
if (progname)
|
||||||
|
@ -1106,14 +1073,13 @@ int main(int argc, char * argv [])
|
||||||
|
|
||||||
|
|
||||||
if (exitspecs != NULL) {
|
if (exitspecs != NULL) {
|
||||||
if (strcmp(pgm->type, "PPI") != 0) {
|
if (pgm->getexitspecs == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: WARNING: -E option is only valid with \"PPI\" "
|
"%s: WARNING: -E option not supported by this programmer type\n",
|
||||||
"programmer types\n",
|
|
||||||
progname);
|
progname);
|
||||||
exitspecs = NULL;
|
exitspecs = NULL;
|
||||||
}
|
}
|
||||||
else if (getexitspecs(exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
else if (pgm->getexitspecs(pgm, exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
||||||
usage();
|
usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,12 @@
|
||||||
#include "ppi.h"
|
#include "ppi.h"
|
||||||
#include "bitbang.h"
|
#include "bitbang.h"
|
||||||
|
|
||||||
|
extern char * progname;
|
||||||
|
extern int do_cycles;
|
||||||
|
extern int verbose;
|
||||||
|
|
||||||
|
#if HAVE_PARPORT
|
||||||
|
|
||||||
#define SLOW_TOGGLE 0
|
#define SLOW_TOGGLE 0
|
||||||
|
|
||||||
struct ppipins_t {
|
struct ppipins_t {
|
||||||
|
@ -71,12 +77,7 @@ struct ppipins_t ppipins[] = {
|
||||||
|
|
||||||
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
|
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
|
||||||
|
|
||||||
|
static int par_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||||
extern char * progname;
|
|
||||||
extern int do_cycles;
|
|
||||||
extern int verbose;
|
|
||||||
|
|
||||||
int par_setpin(int fd, int pin, int value)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
pin &= PIN_MASK;
|
pin &= PIN_MASK;
|
||||||
|
@ -90,9 +91,9 @@ int par_setpin(int fd, int pin, int value)
|
||||||
value = !value;
|
value = !value;
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
ppi_set(fd, ppipins[pin].reg, ppipins[pin].bit);
|
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||||
else
|
else
|
||||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||||
|
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
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;
|
int value;
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ int par_getpin(int fd, int pin)
|
||||||
|
|
||||||
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)
|
if (value)
|
||||||
value = 1;
|
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)
|
if (pin < 1 || pin > 17)
|
||||||
|
@ -133,11 +134,11 @@ int par_highpulsepin(int fd, int pin)
|
||||||
|
|
||||||
pin--;
|
pin--;
|
||||||
|
|
||||||
ppi_set(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
|
||||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||||
|
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
|
@ -158,7 +159,7 @@ int par_getpinmask(int pin)
|
||||||
|
|
||||||
|
|
||||||
char vccpins_buf[64];
|
char vccpins_buf[64];
|
||||||
char * vccpins_str(unsigned int pmask)
|
static char * vccpins_str(unsigned int pmask)
|
||||||
{
|
{
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
int pin;
|
int pin;
|
||||||
|
@ -183,7 +184,7 @@ char * vccpins_str(unsigned int pmask)
|
||||||
/*
|
/*
|
||||||
* apply power to the AVR processor
|
* 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 */
|
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
@ -193,17 +194,17 @@ void par_powerup(PROGRAMMER * pgm)
|
||||||
/*
|
/*
|
||||||
* remove power from the AVR processor
|
* 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 */
|
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]);
|
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
|
* 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.
|
* 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);
|
usleep(1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -225,7 +226,7 @@ void par_enable(PROGRAMMER * pgm)
|
||||||
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
|
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;
|
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,
|
* Restore pin values before closing,
|
||||||
|
@ -275,7 +276,7 @@ void par_close(PROGRAMMER * pgm)
|
||||||
pgm->fd = -1;
|
pgm->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void par_display(PROGRAMMER * pgm, char * p)
|
static void par_display(PROGRAMMER * pgm, char * p)
|
||||||
{
|
{
|
||||||
char vccpins[64];
|
char vccpins[64];
|
||||||
char buffpins[64];
|
char buffpins[64];
|
||||||
|
@ -320,6 +321,38 @@ void par_display(PROGRAMMER * pgm, char * p)
|
||||||
p, pgm->pinno[PIN_LED_VFY]);
|
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)
|
void par_initpgm(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +373,19 @@ void par_initpgm(PROGRAMMER * pgm)
|
||||||
pgm->cmd = bitbang_cmd;
|
pgm->cmd = bitbang_cmd;
|
||||||
pgm->open = par_open;
|
pgm->open = par_open;
|
||||||
pgm->close = par_close;
|
pgm->close = par_close;
|
||||||
|
pgm->setpin = par_setpin;
|
||||||
/* this is a parallel port bitbang device */
|
pgm->getpin = par_getpin;
|
||||||
pgm->flag = 0;
|
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);
|
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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,10 @@ typedef struct programmer_t {
|
||||||
int (*set_varef) (struct programmer_t * pgm, double v);
|
int (*set_varef) (struct programmer_t * pgm, double v);
|
||||||
int (*set_fosc) (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 (*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 */
|
char config_file[PATH_MAX]; /* config file where defined */
|
||||||
int lineno; /* config file line number */
|
int lineno; /* config file line number */
|
||||||
char flag; /* for private use of the programmer */
|
char flag; /* for private use of the programmer */
|
||||||
|
@ -104,8 +108,6 @@ void usleep(unsigned long us);
|
||||||
|
|
||||||
void gettimeofday(struct timeval*, void*z);
|
void gettimeofday(struct timeval*, void*z);
|
||||||
|
|
||||||
#define rindex strrchr
|
|
||||||
|
|
||||||
#endif /* __win32native_h */
|
#endif /* __win32native_h */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,15 +58,15 @@ struct termios oldmode;
|
||||||
7 cts <-
|
7 cts <-
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int serregbits[] =
|
static int serregbits[] =
|
||||||
{ TIOCM_CD, 0, 0, TIOCM_DTR, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS };
|
{ TIOCM_CD, 0, 0, TIOCM_DTR, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS };
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
char *serpins[7] =
|
static char *serpins[7] =
|
||||||
{ "CD", "RXD", "TXD ~RESET", "DTR MOSI", "DSR", "RTS SCK", "CTS MISO" };
|
{ "CD", "RXD", "TXD ~RESET", "DTR MOSI", "DSR", "RTS SCK", "CTS MISO" };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void serbb_setpin(int fd, int pin, int value)
|
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||||
{
|
{
|
||||||
unsigned int ctl;
|
unsigned int ctl;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pin < 1 || pin > 7 )
|
if ( pin < 1 || pin > 7 )
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
pin--;
|
pin--;
|
||||||
|
|
||||||
|
@ -88,24 +88,24 @@ void serbb_setpin(int fd, int pin, int value)
|
||||||
switch ( pin )
|
switch ( pin )
|
||||||
{
|
{
|
||||||
case 2: /* txd */
|
case 2: /* txd */
|
||||||
ioctl(fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
case 3: /* dtr, rts */
|
case 3: /* dtr, rts */
|
||||||
case 5: ioctl(fd, TIOCMGET, &ctl);
|
case 5: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||||
if ( value )
|
if ( value )
|
||||||
ctl |= serregbits[pin];
|
ctl |= serregbits[pin];
|
||||||
else
|
else
|
||||||
ctl &= ~(serregbits[pin]);
|
ctl &= ~(serregbits[pin]);
|
||||||
ioctl(fd, TIOCMSET, &ctl);
|
ioctl(pgm->fd, TIOCMSET, &ctl);
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
default: /* impossible */
|
default: /* impossible */
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int serbb_getpin(int fd, int pin)
|
static int serbb_getpin(PROGRAMMER * pgm, int pin)
|
||||||
{
|
{
|
||||||
unsigned int ctl;
|
unsigned int ctl;
|
||||||
unsigned char invert;
|
unsigned char invert;
|
||||||
|
@ -131,7 +131,7 @@ int serbb_getpin(int fd, int pin)
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
case 6: ioctl(fd, TIOCMGET, &ctl);
|
case 6: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||||
if ( !invert )
|
if ( !invert )
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#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)
|
if (pin < 1 || pin > 7)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
serbb_setpin(fd, pin, 1);
|
serbb_setpin(pgm, pin, 1);
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
#endif
|
#endif
|
||||||
serbb_setpin(fd, pin, 0);
|
serbb_setpin(pgm, pin, 0);
|
||||||
|
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
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 */
|
/* MAYBE */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_enable(PROGRAMMER *pgm)
|
static void serbb_enable(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_disable(PROGRAMMER *pgm)
|
static void serbb_disable(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_powerup(PROGRAMMER *pgm)
|
static void serbb_powerup(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_powerdown(PROGRAMMER *pgm)
|
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||||
{
|
{
|
||||||
struct termios mode;
|
struct termios mode;
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -206,41 +206,40 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
||||||
|
|
||||||
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||||
|
|
||||||
if ( pgm->fd > 0 )
|
if (pgm->fd < 0)
|
||||||
{
|
return(-1);
|
||||||
tcgetattr(pgm->fd, &mode);
|
|
||||||
oldmode = mode;
|
|
||||||
|
|
||||||
cfmakeraw(&mode);
|
tcgetattr(pgm->fd, &mode);
|
||||||
mode.c_iflag &= ~(INPCK | IXOFF | IXON);
|
oldmode = mode;
|
||||||
mode.c_cflag &= ~(HUPCL | CSTOPB | CRTSCTS);
|
|
||||||
mode.c_cflag |= (CLOCAL | CREAD);
|
|
||||||
mode.c_cc [VMIN] = 1;
|
|
||||||
mode.c_cc [VTIME] = 0;
|
|
||||||
|
|
||||||
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. */
|
tcsetattr(pgm->fd, TCSANOW, &mode);
|
||||||
flags = fcntl(pgm->fd, F_GETFL, 0);
|
|
||||||
if (flags == -1)
|
/* Clear O_NONBLOCK flag. */
|
||||||
|
flags = fcntl(pgm->fd, F_GETFL, 0);
|
||||||
|
if (flags == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Can not get flags\n", progname);
|
fprintf(stderr, "%s: Can not get flags\n", progname);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
flags &= ~O_NONBLOCK;
|
flags &= ~O_NONBLOCK;
|
||||||
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Can not clear nonblock flag\n", progname);
|
fprintf(stderr, "%s: Can not clear nonblock flag\n", progname);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_close(PROGRAMMER *pgm)
|
static void serbb_close(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
tcsetattr(pgm->fd, TCSADRAIN, &oldmode);
|
tcsetattr(pgm->fd, TCSANOW, &oldmode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +262,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
||||||
pgm->cmd = bitbang_cmd;
|
pgm->cmd = bitbang_cmd;
|
||||||
pgm->open = serbb_open;
|
pgm->open = serbb_open;
|
||||||
pgm->close = serbb_close;
|
pgm->close = serbb_close;
|
||||||
|
pgm->setpin = serbb_setpin;
|
||||||
/* this is a serial port bitbang device */
|
pgm->getpin = serbb_getpin;
|
||||||
pgm->flag = 1;
|
pgm->highpulsepin = serbb_highpulsepin;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WIN32NATIVE */
|
#endif /* WIN32NATIVE */
|
||||||
|
|
|
@ -59,9 +59,9 @@ static int dtr, rts, txd;
|
||||||
Negative pin # means negated value.
|
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;
|
LPVOID lpMsgBuf;
|
||||||
DWORD dwFunc;
|
DWORD dwFunc;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -73,7 +73,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pin < 1 || pin > 7)
|
if (pin < 1 || pin > 7)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
pin--;
|
pin--;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: serbb_setpin(): unknown pin %d\n",
|
"%s: serbb_setpin(): unknown pin %d\n",
|
||||||
progname, pin + 1);
|
progname, pin + 1);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbose > 4)
|
if (verbose > 4)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -126,12 +126,12 @@ void serbb_setpin(int fd, int pin, int value)
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
exit(1);
|
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;
|
LPVOID lpMsgBuf;
|
||||||
int invert, rv;
|
int invert, rv;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -224,16 +224,16 @@ int serbb_getpin(int fd, int pin)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int serbb_highpulsepin(int fd, int pin)
|
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||||
{
|
{
|
||||||
if (pin < 1 || pin > 7)
|
if (pin < 1 || pin > 7)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
serbb_setpin(fd, pin, 1);
|
serbb_setpin(pgm, pin, 1);
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
#endif
|
#endif
|
||||||
serbb_setpin(fd, pin, 0);
|
serbb_setpin(pgm, pin, 0);
|
||||||
|
|
||||||
#if SLOW_TOGGLE
|
#if SLOW_TOGGLE
|
||||||
usleep(1000);
|
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 */
|
/* MAYBE */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_enable(PROGRAMMER *pgm)
|
static void serbb_enable(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_disable(PROGRAMMER *pgm)
|
static void serbb_disable(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_powerup(PROGRAMMER *pgm)
|
static void serbb_powerup(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_powerdown(PROGRAMMER *pgm)
|
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||||
{
|
{
|
||||||
DCB dcb;
|
DCB dcb;
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
|
@ -332,7 +332,7 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serbb_close(PROGRAMMER *pgm)
|
static void serbb_close(PROGRAMMER *pgm)
|
||||||
{
|
{
|
||||||
HANDLE hComPort=(HANDLE)pgm->fd;
|
HANDLE hComPort=(HANDLE)pgm->fd;
|
||||||
if (hComPort != INVALID_HANDLE_VALUE)
|
if (hComPort != INVALID_HANDLE_VALUE)
|
||||||
|
@ -364,9 +364,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
||||||
pgm->cmd = bitbang_cmd;
|
pgm->cmd = bitbang_cmd;
|
||||||
pgm->open = serbb_open;
|
pgm->open = serbb_open;
|
||||||
pgm->close = serbb_close;
|
pgm->close = serbb_close;
|
||||||
|
pgm->setpin = serbb_setpin;
|
||||||
/* this is a serial port bitbang device */
|
pgm->getpin = serbb_getpin;
|
||||||
pgm->flag = 1;
|
pgm->highpulsepin = serbb_highpulsepin;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WIN32NATIVE */
|
#endif /* WIN32NATIVE */
|
||||||
|
|
Loading…
Reference in New Issue