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 56aa52e7dd
commit 462b5a04a7
3 changed files with 81 additions and 54 deletions

View File

@ -610,18 +610,45 @@ programmer
# some ultra cheap programmers use bitbanging on the
# 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)
# reset=!txd sck=rts mosi=dtr miso=cts
programmer
id = "ponyser";
desc = "serial port banging, design ponyprog serial";
desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts";
type = serbb;
reset = ~3;
sck = 6;
sck = 7;
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)
@ -631,10 +658,10 @@ programmer
id = "dasa";
desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
type = serbb;
reset = 6;
reset = 7;
sck = 4;
mosi = 3;
miso = 7;
miso = 8;
;
# unknown (dasa3 in uisp)
@ -645,9 +672,9 @@ programmer
desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts";
type = serbb;
reset = ~4;
sck = 6;
sck = 7;
mosi = 3;
miso = 7;
miso = 8;
;
#

View File

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

View File

@ -2,7 +2,7 @@
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de>
* 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
* 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
1 cd <-
2 rxd <-
2 (rxd) <-
3 txd ->
4 dtr ->
5 dsr <-
6 rts ->
7 cts <-
Negative pin # means negated value.
5 GND
6 dsr <-
7 rts ->
8 cts <-
9 ri <-
*/
#define DB9PINS 9
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
{
HANDLE hComPort = (HANDLE)pgm->fd;
@ -72,26 +74,24 @@ static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
pin &= PIN_MASK;
}
if (pin < 1 || pin > 7)
if (pin < 1 || pin > DB9PINS)
return -1;
pin--;
switch (pin)
{
case 2: /* txd */
case 3: /* txd */
dwFunc = value? SETBREAK: CLRBREAK;
name = value? "SETBREAK": "CLRBREAK";
txd = value;
break;
case 3: /* dtr */
case 4: /* dtr */
dwFunc = value? SETDTR: CLRDTR;
name = value? "SETDTR": "CLRDTR";
dtr = value;
break;
case 5: /* rts */
case 7: /* rts */
dwFunc = value? SETRTS: CLRRTS;
name = value? "SETRTS": "CLRRTS";
break;
@ -144,12 +144,10 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
} else
invert = 0;
if (pin < 1 || pin > 7)
if (pin < 1 || pin > DB9PINS)
return -1;
pin --;
if (pin == 0 /* cd */ || pin == 4 /* dsr */ || pin == 6 /* cts */)
if (pin == 1 /* cd */ || pin == 6 /* dsr */ || pin == 8 /* cts */)
{
if (!GetCommModemStatus(hComPort, &modemstate))
{
@ -176,13 +174,13 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
progname, modemstate);
switch (pin)
{
case 0:
case 1:
modemstate &= MS_RLSD_ON;
break;
case 4:
case 6:
modemstate &= MS_DSR_ON;
break;
case 6:
case 8:
modemstate &= MS_CTS_ON;
break;
}
@ -195,15 +193,15 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
switch (pin)
{
case 2: /* txd */
case 3: /* txd */
rv = txd;
name = "TXD";
break;
case 3: /* dtr */
case 4: /* dtr */
rv = dtr;
name = "DTR";
break;
case 5: /* rts */
case 7: /* rts */
rv = rts;
name = "RTS";
break;