Prefix pin config entries in the config file with a "c:". Later, I
might make part descriptions read in this way and we can use a different letter for those (p). This will make the parsing easier to distinguish between the entry types. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@69 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
2962b3785b
commit
b82abdaf2c
21
avrdude.1
21
avrdude.1
|
@ -125,8 +125,11 @@ Atmel AVR serial program method.
|
|||
.It Fl C Ar Config-File
|
||||
Use the specified config file to locate the desired pin configuration.
|
||||
Pin configurations are specified in the config file using a colon
|
||||
seperated field format. The configuration name is the first field,
|
||||
the remaining fields are of the form:
|
||||
seperated field format. The configuration entry type is the first
|
||||
field and currently must be
|
||||
.Ar c:
|
||||
The configuration name is the second field, and the remaining fields
|
||||
are of the form:
|
||||
.Ar PIN=VALUE ,
|
||||
where
|
||||
.Ar PIN
|
||||
|
@ -135,8 +138,11 @@ can be
|
|||
The value is the pin number of the PC parallel port assigned to that
|
||||
function. The
|
||||
.Ar VCC
|
||||
pin can take multible values seperated by a comma. It's value(s) must
|
||||
come from pins 2 through 9. The default configuration file is
|
||||
pin can take on multiple values seperated by a comma (which are or'd
|
||||
together to create a bit mask).
|
||||
.Ar VCC
|
||||
pin numbers must come from pins 2 through 9. The default
|
||||
configuration file is
|
||||
.Pa /usr/local/etc/avrprog.conf .
|
||||
.It Fl e
|
||||
Causes a chip erase to be executed. This will reset the contents of the
|
||||
|
@ -304,7 +310,10 @@ Give a short on-line summary of the available commands.
|
|||
Leave terminal mode and thus
|
||||
.Nm avrprog .
|
||||
.El
|
||||
.Ss Parallel port pin connections
|
||||
.Ss Default Parallel port pin connections
|
||||
(these can be changed, see the
|
||||
.Fl c
|
||||
option)
|
||||
.TS
|
||||
ll.
|
||||
\fBPin number\fP \fBFunction\fP
|
||||
|
@ -325,6 +334,8 @@ ll.
|
|||
.It Pa /dev/ppi0
|
||||
default device to be used for communication with the programming
|
||||
hardware
|
||||
.It Pa /usr/local/etc/avrprog.conf.sample
|
||||
sample pin configuration file
|
||||
.It Pa /usr/local/etc/avrprog.conf
|
||||
default pin configuration file
|
||||
.It Pa ~/.inputrc
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
# Programmer Pin Configurations
|
||||
#
|
||||
# The format of these entries is as follows:
|
||||
# name:[desc=<description>:][[<pin>=<value>:]...]
|
||||
# c:<name>:[desc=<description>:][[<pin>=<value>:]...]
|
||||
#
|
||||
# Example: for a programmer called PGM-1 that uses pin 2 and 3 for
|
||||
# power, pins 4, 5, and 6 for RESET, SCK, and MOSI, and pin 10 for
|
||||
# MISO, we could use the following entry:
|
||||
#
|
||||
# pgm-1 : desc=Programmer 1:vcc=2,3:reset=4:sck=5:mosi=6:miso=10
|
||||
# c:pgm-1 : desc=Programmer 1:vcc=2,3:reset=4:sck=5:mosi=6:miso=10
|
||||
#
|
||||
# Continuation lines are supported, use a backslash (\) as the last
|
||||
# character of the line and the next line will included as part of the
|
||||
# configuration data.
|
||||
#
|
||||
|
||||
bsd : desc=Brian Dean's programmer:vcc=2,3,4,5:reset=7:sck=8:\
|
||||
mosi=9:miso=10
|
||||
c:bsd : desc=Brian Dean's programmer:vcc=2,3,4,5:reset=7:sck=8:\
|
||||
mosi=9:miso=10
|
||||
|
||||
dt006 : desc=Dontronics DT006:reset=4:sck=5:mosi=2:miso=11
|
||||
c:dt006 : desc=Dontronics DT006:reset=4:sck=5:mosi=2:miso=11
|
||||
|
||||
alf : desc=Tony Freibel's programmer:vcc=2,3,4,5:buff=6:\
|
||||
reset=7:sck=8:mosi=9:miso=10:errled=1:rdyled=14:pgmled=16:\
|
||||
vfyled=17
|
||||
c:alf : desc=Tony Freibel's programmer:vcc=2,3,4,5:buff=6:\
|
||||
reset=7:sck=8:mosi=9:miso=10:errled=1:rdyled=14:pgmled=16:\
|
||||
vfyled=17
|
||||
|
||||
|
|
75
main.c
75
main.c
|
@ -264,7 +264,6 @@ int print_module_versions ( FILE * outf, char * timestamp )
|
|||
}
|
||||
|
||||
|
||||
|
||||
#define MAX_LINE_LEN 1024
|
||||
#define MAX_PIN_NAME 64
|
||||
|
||||
|
@ -457,6 +456,7 @@ int read_config(char * infile, char * config, unsigned int * pinno,
|
|||
|
||||
lineno = 0;
|
||||
buf[0] = 0;
|
||||
cont = 0;
|
||||
while (fgets(line, MAX_LINE_LEN, f) != NULL) {
|
||||
lineno++;
|
||||
|
||||
|
@ -464,6 +464,9 @@ int read_config(char * infile, char * config, unsigned int * pinno,
|
|||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
/*
|
||||
* skip empty lines and lines that start with '#'
|
||||
*/
|
||||
if ((*p == '#')||(*p == '\n')||(*p == 0))
|
||||
continue;
|
||||
|
||||
|
@ -473,6 +476,37 @@ int read_config(char * infile, char * config, unsigned int * pinno,
|
|||
len--;
|
||||
}
|
||||
|
||||
/*
|
||||
* we're only interested in pin configuration data which begin
|
||||
* with "c:"
|
||||
*/
|
||||
if (((len < 3) || (p[0] != 'c')) && !cont)
|
||||
continue;
|
||||
|
||||
|
||||
/*
|
||||
* skip over the "c:"
|
||||
*/
|
||||
if (!cont) {
|
||||
p++;
|
||||
while (*p && isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p != ':') {
|
||||
fprintf(stderr, "line %d:\n%s\n",
|
||||
lineno, line);
|
||||
for (i=0; i<(p-line); i++) {
|
||||
fprintf(stderr, "-");
|
||||
}
|
||||
fprintf(stderr, "^\n");
|
||||
fprintf(stderr, "error at column %d, line %d of %s: expecting ':'\n",
|
||||
p-line+1, lineno, infile);
|
||||
return -1;
|
||||
}
|
||||
p++;
|
||||
len = strlen(p);
|
||||
}
|
||||
|
||||
cont = 0;
|
||||
|
||||
if (p[len-1] == '\\') {
|
||||
|
@ -547,12 +581,47 @@ int read_config(char * infile, char * config, unsigned int * pinno,
|
|||
|
||||
|
||||
|
||||
static char vccpins_buf[64];
|
||||
char * vccpins_str(unsigned int pmask)
|
||||
{
|
||||
unsigned int mask;
|
||||
int pin;
|
||||
char b2[8];
|
||||
char * b;
|
||||
|
||||
b = vccpins_buf;
|
||||
|
||||
b[0] = 0;
|
||||
for (pin = 2, mask = 1; mask < 0x80; mask = mask << 1, pin++) {
|
||||
if (pmask & mask) {
|
||||
sprintf(b2, "%d", pin);
|
||||
if (b[0] != 0)
|
||||
strcat(b, ",");
|
||||
strcat(b, b2);
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
void pinconfig_display(char * p, char * config, char * desc)
|
||||
{
|
||||
char vccpins[64];
|
||||
|
||||
if (pinno[PPI_AVR_VCC]) {
|
||||
snprintf(vccpins, sizeof(vccpins), " = pins %s",
|
||||
vccpins_str(pinno[PPI_AVR_VCC]));
|
||||
}
|
||||
else {
|
||||
vccpins[0] = 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%sProgrammer Pin Configuration: %s (%s)\n", p,
|
||||
config ? config : "DEFAULT", desc);
|
||||
|
||||
fprintf(stderr,
|
||||
"%s VCC = 0x%02x\n"
|
||||
"%s VCC = 0x%02x %s\n"
|
||||
"%s BUFF = %d\n"
|
||||
"%s RESET = %d\n"
|
||||
"%s SCK = %d\n"
|
||||
|
@ -562,7 +631,7 @@ void pinconfig_display(char * p, char * config, char * desc)
|
|||
"%s RDY LED = %d\n"
|
||||
"%s PGM LED = %d\n"
|
||||
"%s VFY LED = %d\n",
|
||||
p, pinno[PPI_AVR_VCC],
|
||||
p, pinno[PPI_AVR_VCC], vccpins,
|
||||
p, pinno[PIN_AVR_BUFF],
|
||||
p, pinno[PIN_AVR_RESET],
|
||||
p, pinno[PIN_AVR_SCK],
|
||||
|
|
Loading…
Reference in New Issue