command: Cleaned up in cmd_frequency and added some robustness
This commit is contained in:
parent
35f071c22e
commit
50457bac13
|
@ -329,23 +329,27 @@ bool cmd_frequency(target *t, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
(void)t;
|
(void)t;
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
char *p;
|
char *multiplier = NULL;
|
||||||
uint32_t frequency = strtol(argv[1], &p, 10);
|
uint32_t frequency = strtoul(argv[1], &multiplier, 10);
|
||||||
switch (*p) {
|
if (!multiplier) {
|
||||||
|
gdb_outf("Frequency must be an integral value possibly followed by 'k' or 'M'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (*multiplier) {
|
||||||
case 'k':
|
case 'k':
|
||||||
frequency *= 1000;
|
frequency *= 1000U;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
frequency *= 1000 * 1000;
|
frequency *= 1000U * 1000U;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
platform_max_frequency_set(frequency);
|
platform_max_frequency_set(frequency);
|
||||||
}
|
}
|
||||||
uint32_t freq = platform_max_frequency_get();
|
const uint32_t freq = platform_max_frequency_get();
|
||||||
if (freq == FREQ_FIXED)
|
if (freq == FREQ_FIXED)
|
||||||
gdb_outf("SWJ freq fixed\n");
|
gdb_outf("SWJ freq fixed\n");
|
||||||
else
|
else
|
||||||
gdb_outf("Max SWJ freq %08" PRIx32 "\n", freq);
|
gdb_outf("Current SWJ freq %" PRIu32 "Hz\n", freq);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue