mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-13 17:34:56 +00:00
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:
43
main.c
43
main.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user