Allow the -B option argument to be suffixed with Hz, kHz, or MHz, in

order to specify a bitclock frequency rather than period.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1347 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2014-11-23 21:49:56 +00:00
parent 3f77955a47
commit d0955aa6e0
5 changed files with 58 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2014-11-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* main.c: Allow the -B option argument to be suffixed with Hz,
kHz, or MHz, in order to specify a bitclock frequency rather than
period.
* avrdude.1: Document the -B option changes.
* doc/avrdude.texi: (Dito.)
2014-11-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2014-11-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #40870: config nitpick: ATtiny25/45/85 have 1 calibration byte not 2 bug #40870: config nitpick: ATtiny25/45/85 have 1 calibration byte not 2

3
NEWS
View File

@ -17,6 +17,9 @@ Current:
used by all the more modern Atmel tools (AVRISPmkII, JTAGICEmkII used by all the more modern Atmel tools (AVRISPmkII, JTAGICEmkII
in ISP mode, STK600 in ISP mode). in ISP mode, STK600 in ISP mode).
- The -B option can be suffixed with "Hz", "kHz", or "MHz", in
order to specify a bitclock frequency rather than period.
* New programmers supported: * New programmers supported:
- ... - ...

View File

@ -18,7 +18,7 @@
.\" .\"
.\" $Id$ .\" $Id$
.\" .\"
.Dd DATE January 17, 2014 .Dd DATE November 23, 2014
.Os .Os
.Dt AVRDUDE 1 .Dt AVRDUDE 1
.Sh NAME .Sh NAME
@ -257,6 +257,8 @@ programmer's entry of the configuration file.
.It Fl B Ar bitclock .It Fl B Ar bitclock
Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only).
The value is a floating-point number in microseconds. The value is a floating-point number in microseconds.
Alternatively, the value might be suffixed with "Hz", "kHz", or "MHz",
in order to specify the bit clock frequency, rather than a period.
The default value of the JTAG ICE results in about 1 microsecond bit The default value of the JTAG ICE results in about 1 microsecond bit
clock period, suitable for target MCUs running at 4 MHz clock and clock period, suitable for target MCUs running at 4 MHz clock and
above. above.

View File

@ -354,6 +354,8 @@ programmer's entry of the configuration file.
@item -B @var{bitclock} @item -B @var{bitclock}
Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only). Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only).
The value is a floating-point number in microseconds. The value is a floating-point number in microseconds.
Alternatively, the value might be suffixed with "Hz", "kHz", or "MHz",
in order to specify the bit clock frequency, rather than a period.
The default value of the JTAG ICE results in about 1 microsecond bit The default value of the JTAG ICE results in about 1 microsecond bit
clock period, suitable for target MCUs running at 4 MHz clock and clock period, suitable for target MCUs running at 4 MHz clock and
above. above.

43
main.c
View File

@ -476,7 +476,48 @@ int main(int argc, char * argv [])
case 'B': /* specify JTAG ICE bit clock period */ case 'B': /* specify JTAG ICE bit clock period */
bitclock = strtod(optarg, &e); bitclock = strtod(optarg, &e);
if ((e == optarg) || (*e != 0) || bitclock == 0.0) { if (*e != 0) {
/* trailing unit of measure present */
int suffixlen = strlen(e);
switch (suffixlen) {
case 2:
if ((e[0] != 'h' && e[0] != 'H') || e[1] != 'z')
bitclock = 0.0;
else
/* convert from Hz to microseconds */
bitclock = 1E6 / bitclock;
break;
case 3:
if ((e[1] != 'h' && e[1] != 'H') || e[2] != 'z')
bitclock = 0.0;
else {
switch (e[0]) {
case 'M':
case 'm': /* no Millihertz here :) */
bitclock = 1.0 / bitclock;
break;
case 'k':
bitclock = 1E3 / bitclock;
break;
default:
bitclock = 0.0;
break;
}
}
break;
default:
bitclock = 0.0;
break;
}
if (bitclock == 0.0)
avrdude_message(MSG_INFO, "%s: invalid bit clock unit of measure '%s'\n",
progname, e);
}
if ((e == optarg) || bitclock == 0.0) {
avrdude_message(MSG_INFO, "%s: invalid bit clock period specified '%s'\n", avrdude_message(MSG_INFO, "%s: invalid bit clock period specified '%s'\n",
progname, optarg); progname, optarg);
exit(1); exit(1);