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

43
main.c
View File

@@ -476,7 +476,48 @@ int main(int argc, char * argv [])
case 'B': /* specify JTAG ICE bit clock period */
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",
progname, optarg);
exit(1);