aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2022-05-27 16:16:47 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2022-06-10 13:24:05 -0500
commitba950f8d6e9c8dd55ba3784b15d48985745f03d1 (patch)
treec21f85dba382103019aa780afb079b4a2363b3d6 /host
parent022386279a3ef4fa364ab5e2041eedeb3bd7b07b (diff)
downloaduhd-ba950f8d6e9c8dd55ba3784b15d48985745f03d1.tar.gz
uhd-ba950f8d6e9c8dd55ba3784b15d48985745f03d1.tar.bz2
uhd-ba950f8d6e9c8dd55ba3784b15d48985745f03d1.zip
fixup! examples: gpio: Refactor example
The refactoring changed the behaviour of --bitbang: before, it would terminate after one readback unless --repeat was specified, in which case it would require a Ctrl-C (SIGINT). After the refactoring, it always required a SIGINT. This changes the behaviour back to prior to 727141d, and will now only read back once, unless --repeat is provided. This also fixes the bitbang devtest, which would go on indefinitely.
Diffstat (limited to 'host')
-rw-r--r--host/examples/gpio.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/host/examples/gpio.cpp b/host/examples/gpio.cpp
index 730cf905f..01648c187 100644
--- a/host/examples/gpio.cpp
+++ b/host/examples/gpio.cpp
@@ -185,7 +185,8 @@ void run_bitbang_test(uhd::usrp::multi_usrp::sptr usrp,
const uint32_t out,
const uint32_t mask,
const uint32_t num_bits,
- const std::chrono::milliseconds dwell_time)
+ const std::chrono::milliseconds dwell_time,
+ const bool repeat)
{
// Set all pins to "GPIO", and DDR/OUT to whatever the user requested
usrp->set_gpio_attr(gpio_bank, "CTRL", 0, mask);
@@ -198,7 +199,7 @@ void run_bitbang_test(uhd::usrp::multi_usrp::sptr usrp,
std::cout << std::endl;
std::signal(SIGINT, &sig_int_handler);
- while (not stop_signal_called) {
+ do {
// dwell and continuously read back GPIO values
auto stop_time = std::chrono::steady_clock::now() + dwell_time;
while (not stop_signal_called and std::chrono::steady_clock::now() < stop_time) {
@@ -208,7 +209,7 @@ void run_bitbang_test(uhd::usrp::multi_usrp::sptr usrp,
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
std::cout << std::endl;
- }
+ } while (repeat && !stop_signal_called);
}
@@ -468,7 +469,15 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
// The bitbang test is its own thing
if (vm.count("bitbang")) {
- run_bitbang_test(usrp, gpio_bank, port, ddr, out, mask, num_bits, dwell_time);
+ run_bitbang_test(usrp,
+ gpio_bank,
+ port,
+ ddr,
+ out,
+ mask,
+ num_bits,
+ dwell_time,
+ bool(vm.count("repeat")));
return EXIT_SUCCESS;
}