main: avoid potential miss with probe clock frequency
This commit is contained in:
parent
fd329158de
commit
13af012163
20
src/main.cpp
20
src/main.cpp
|
|
@ -72,7 +72,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* command line args. */
|
/* command line args. */
|
||||||
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
|
struct arguments args = {0, false, false, false, 0, "", "", "-", "", -1,
|
||||||
DEFAULT_FREQ, "-", false, false, false, false, Device::WR_SRAM, false,
|
0, "-", false, false, false, false, Device::WR_SRAM, false,
|
||||||
false, false, "", "", "", -1, 0};
|
false, false, "", "", "", -1, 0};
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
try {
|
try {
|
||||||
|
|
@ -97,8 +97,6 @@ int main(int argc, char **argv)
|
||||||
board = &(board_list[args.board]);
|
board = &(board_list[args.board]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t freq = args.freq;
|
|
||||||
|
|
||||||
/* if a board name is specified try to use this to determine cable */
|
/* if a board name is specified try to use this to determine cable */
|
||||||
if (board) {
|
if (board) {
|
||||||
/* set pins config (only when user has not already provided
|
/* set pins config (only when user has not already provided
|
||||||
|
|
@ -128,9 +126,13 @@ int main(int argc, char **argv)
|
||||||
else if (!board->fpga_part.empty() && args.fpga_part.empty())
|
else if (!board->fpga_part.empty() && args.fpga_part.empty())
|
||||||
args.fpga_part = board->fpga_part;
|
args.fpga_part = board->fpga_part;
|
||||||
|
|
||||||
/* Some boards can override the default clock speed */
|
/* Some boards can override the default clock speed
|
||||||
if (board->default_freq != CABLE_DEFAULT && freq == DEFAULT_FREQ)
|
* if args.freq == 0: the `--freq` arg has not been used
|
||||||
freq = board->default_freq;
|
* => apply board->default_freq with a value of
|
||||||
|
* 0 (no default frequency) or > 0 (board has a default frequency)
|
||||||
|
*/
|
||||||
|
if (args.freq == 0)
|
||||||
|
args.freq = board->default_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.cable[0] == '-') { /* if no board and no cable */
|
if (args.cable[0] == '-') { /* if no board and no cable */
|
||||||
|
|
@ -139,6 +141,12 @@ int main(int argc, char **argv)
|
||||||
args.cable = "ft2232";
|
args.cable = "ft2232";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if args.freq == 0: no user requirement nor board default
|
||||||
|
* clock speed => set default frequency
|
||||||
|
*/
|
||||||
|
if (args.freq == 0)
|
||||||
|
args.freq = DEFAULT_FREQ;
|
||||||
|
|
||||||
auto select_cable = cable_list.find(args.cable);
|
auto select_cable = cable_list.find(args.cable);
|
||||||
if (select_cable == cable_list.end()) {
|
if (select_cable == cable_list.end()) {
|
||||||
printError("error : " + args.cable + " not found");
|
printError("error : " + args.cable + " not found");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue