Rewrite the serbb code so the pin numbering matches the

DB9 connector, and fix some related bugs in serbb_posix.c.

Closes bug #16265: dasa2 does not work under posix

* avrdude.conf.in: New serbb pin numbering; added "siprog"
as an alias for "ponyser".
* serbb_posix.c: New pin numbering, fix some confusion.
* serbb_win32.c: New pin numbering.

The generic and Posix-related parts of these changes have
been contributed by Hanns-Konrad Unger


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@632 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2006-08-30 14:09:58 +00:00
parent cdbd7d4cf0
commit fd71b3e437
3 changed files with 81 additions and 54 deletions

View File

@ -610,18 +610,45 @@ programmer
# some ultra cheap programmers use bitbanging on the # some ultra cheap programmers use bitbanging on the
# serialport. # serialport.
# #
# PC - DB9 - Pins for RS232:
#
# GND 5 -- |O
# | O| <- 9 RI
# DTR 4 <- |O |
# | O| <- 8 CTS
# TXD 3 <- |O |
# | O| -> 7 RTS
# RXD 2 -> |O |
# | O| <- 6 DSR
# DCD 1 -> |O
#
# Using RXD is currently not supported.
# Using RI is not supported under Win32 but is supported under Posix.
# serial ponyprog design (dasa2 in uisp) # serial ponyprog design (dasa2 in uisp)
# reset=!txd sck=rts mosi=dtr miso=cts # reset=!txd sck=rts mosi=dtr miso=cts
programmer programmer
id = "ponyser"; id = "ponyser";
desc = "serial port banging, design ponyprog serial"; desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts";
type = serbb; type = serbb;
reset = ~3; reset = ~3;
sck = 6; sck = 7;
mosi = 4; mosi = 4;
miso = 7; miso = 8;
;
# Same as above, different name
# reset=!txd sck=rts mosi=dtr miso=cts
programmer
id = "siprog";
desc = "Lancos SI-Prog <http://www.lancos.com/siprogsch.html>";
type = serbb;
reset = ~3;
sck = 7;
mosi = 4;
miso = 8;
; ;
# unknown (dasa in uisp) # unknown (dasa in uisp)
@ -631,10 +658,10 @@ programmer
id = "dasa"; id = "dasa";
desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
type = serbb; type = serbb;
reset = 6; reset = 7;
sck = 4; sck = 4;
mosi = 3; mosi = 3;
miso = 7; miso = 8;
; ;
# unknown (dasa3 in uisp) # unknown (dasa3 in uisp)
@ -645,9 +672,9 @@ programmer
desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts";
type = serbb; type = serbb;
reset = ~4; reset = ~4;
sck = 6; sck = 7;
mosi = 3; mosi = 3;
miso = 7; miso = 8;
; ;
# #

View File

@ -2,6 +2,7 @@
* avrdude - A Downloader/Uploader for AVR device programmers * avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com> * Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org> * Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -50,20 +51,24 @@ struct termios oldmode;
serial port/pin mapping serial port/pin mapping
1 cd <- 1 cd <-
2 rxd <- 2 (rxd) <-
3 txd -> 3 txd ->
4 dtr -> 4 dtr ->
5 dsr <- 5 GND
6 rts -> 6 dsr <-
7 cts <- 7 rts ->
8 cts <-
9 ri <-
*/ */
static int serregbits[] = #define DB9PINS 9
{ TIOCM_CD, 0, 0, TIOCM_DTR, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS };
static int serregbits[DB9PINS + 1] =
{ 0, TIOCM_CD, 0, 0, TIOCM_DTR, 0, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS, TIOCM_RI };
#ifdef DEBUG #ifdef DEBUG
static char *serpins[7] = static char *serpins[DB9PINS + 1] =
{ "CD", "RXD", "TXD ~RESET", "DTR MOSI", "DSR", "RTS SCK", "CTS MISO" }; { "NONE", "CD", "RXD", "TXD", "DTR", "GND", "DSR", "RTS", "CTS", "RI" };
#endif #endif
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value) static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
@ -76,23 +81,22 @@ static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
pin &= PIN_MASK; pin &= PIN_MASK;
} }
if ( pin < 1 || pin > 7 ) if ( pin < 1 || pin > DB9PINS )
return -1; return -1;
pin--;
#ifdef DEBUG #ifdef DEBUG
printf("%s to %d\n",serpins[pin],value); printf("%s to %d\n",serpins[pin],value);
#endif #endif
switch ( pin ) switch ( pin )
{ {
case 2: /* txd */ case 3: /* txd */
ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0); ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0);
return 0; return 0;
case 3: /* dtr, rts */ case 4: /* dtr */
case 5: ioctl(pgm->fd, TIOCMGET, &ctl); case 7: /* rts */
ioctl(pgm->fd, TIOCMGET, &ctl);
if ( value ) if ( value )
ctl |= serregbits[pin]; ctl |= serregbits[pin];
else else
@ -117,21 +121,19 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
} else } else
invert = 0; invert = 0;
if ( pin < 1 || pin > 7 ) if ( pin < 1 || pin > DB9PINS )
return(-1); return(-1);
pin --;
switch ( pin ) switch ( pin )
{ {
case 1: /* rxd, currently not implemented, FIXME */ case 2: /* rxd, currently not implemented, FIXME */
return(-1); return(-1);
case 0: /* cd, dsr, dtr, rts, cts */ case 1: /* cd */
case 3: case 6: /* dsr */
case 4: case 8: /* cts */
case 5: case 9: /* ri */
case 6: ioctl(pgm->fd, TIOCMGET, &ctl); ioctl(pgm->fd, TIOCMGET, &ctl);
if ( !invert ) if ( !invert )
{ {
#ifdef DEBUG #ifdef DEBUG
@ -154,7 +156,7 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin) static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
{ {
if (pin < 1 || pin > 7) if ( pin < 1 || pin > DB9PINS )
return -1; return -1;
serbb_setpin(pgm, pin, 1); serbb_setpin(pgm, pin, 1);

View File

@ -2,7 +2,7 @@
* avrdude - A Downloader/Uploader for AVR device programmers * avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de> * Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org> * Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
* Copyright (C) 2005 Joerg Wunsch <j@uriah.heep.sax.de> * Copyright (C) 2005, 2006 Joerg Wunsch <j@uriah.heep.sax.de>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -49,16 +49,18 @@ static int dtr, rts, txd;
serial port/pin mapping serial port/pin mapping
1 cd <- 1 cd <-
2 rxd <- 2 (rxd) <-
3 txd -> 3 txd ->
4 dtr -> 4 dtr ->
5 dsr <- 5 GND
6 rts -> 6 dsr <-
7 cts <- 7 rts ->
8 cts <-
Negative pin # means negated value. 9 ri <-
*/ */
#define DB9PINS 9
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value) static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
{ {
HANDLE hComPort = (HANDLE)pgm->fd; HANDLE hComPort = (HANDLE)pgm->fd;
@ -72,26 +74,24 @@ static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
pin &= PIN_MASK; pin &= PIN_MASK;
} }
if (pin < 1 || pin > 7) if (pin < 1 || pin > DB9PINS)
return -1; return -1;
pin--;
switch (pin) switch (pin)
{ {
case 2: /* txd */ case 3: /* txd */
dwFunc = value? SETBREAK: CLRBREAK; dwFunc = value? SETBREAK: CLRBREAK;
name = value? "SETBREAK": "CLRBREAK"; name = value? "SETBREAK": "CLRBREAK";
txd = value; txd = value;
break; break;
case 3: /* dtr */ case 4: /* dtr */
dwFunc = value? SETDTR: CLRDTR; dwFunc = value? SETDTR: CLRDTR;
name = value? "SETDTR": "CLRDTR"; name = value? "SETDTR": "CLRDTR";
dtr = value; dtr = value;
break; break;
case 5: /* rts */ case 7: /* rts */
dwFunc = value? SETRTS: CLRRTS; dwFunc = value? SETRTS: CLRRTS;
name = value? "SETRTS": "CLRRTS"; name = value? "SETRTS": "CLRRTS";
break; break;
@ -144,12 +144,10 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
} else } else
invert = 0; invert = 0;
if (pin < 1 || pin > 7) if (pin < 1 || pin > DB9PINS)
return -1; return -1;
pin --; if (pin == 1 /* cd */ || pin == 6 /* dsr */ || pin == 8 /* cts */)
if (pin == 0 /* cd */ || pin == 4 /* dsr */ || pin == 6 /* cts */)
{ {
if (!GetCommModemStatus(hComPort, &modemstate)) if (!GetCommModemStatus(hComPort, &modemstate))
{ {
@ -176,13 +174,13 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
progname, modemstate); progname, modemstate);
switch (pin) switch (pin)
{ {
case 0: case 1:
modemstate &= MS_RLSD_ON; modemstate &= MS_RLSD_ON;
break; break;
case 4: case 6:
modemstate &= MS_DSR_ON; modemstate &= MS_DSR_ON;
break; break;
case 6: case 8:
modemstate &= MS_CTS_ON; modemstate &= MS_CTS_ON;
break; break;
} }
@ -195,15 +193,15 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
switch (pin) switch (pin)
{ {
case 2: /* txd */ case 3: /* txd */
rv = txd; rv = txd;
name = "TXD"; name = "TXD";
break; break;
case 3: /* dtr */ case 4: /* dtr */
rv = dtr; rv = dtr;
name = "DTR"; name = "DTR";
break; break;
case 5: /* rts */ case 7: /* rts */
rv = rts; rv = rts;
name = "RTS"; name = "RTS";
break; break;