aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/gpio.cpp
Commit message (Collapse)AuthorAgeFilesLines
* fixup! examples: gpio: Refactor exampleMartin Braun2022-06-101-14/+32
| | | | | | The example refactoring required usage of the get/set source API, which isn't available on B2xx series. This patch tests for the existence of said API, and disables its usage if appropriate.
* fixup! examples: gpio: Refactor exampleMartin Braun2022-06-101-4/+13
| | | | | | | | | | 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.
* examples: gpio: Refactor exampleMartin Braun2022-06-101-286/+368
| | | | | | | | | | | | | | | | The example had organically grown and was getting hard to read, and also had some known issues. Summary of fixes: - Default GPIO bank and connector are now derived from the device. This allows this example to pass without throwing an exception on E3xx and X4xx series when using default arguments. - The bitbang test is moved into its own code section, to make the rest more readable. - We move all the streamer-related code into a helper struct - Some repetitive parts of the code are moved into their own functions - The argument --require-loopback is added, which will fail tests if GPIO pins are not correctly looped back externally - --list-banks is renamed to --list_banks for consistency
* example: gpio: Separate bank and port argumentsLane Kolbly2021-11-031-10/+18
| | | | | | | "bank" refers to what the radio control sees, and "port" refers to what the user looking at the physical device sees. For example, on X410 each radio control only has a single (24-bit) output, which can be routed to either of two ports.
* host: Update code base using clang-tidyMartin Braun2021-03-041-2/+2
| | | | | | | | | The checks from the new clang-tidy file are applied to the source tree using: $ find . -name "*.cpp" | sort -u | xargs \ --max-procs 8 --max-args 1 clang-tidy --format-style=file \ --fix -p /path/to/compile_commands.json
* examples: Update gpio exampleMichael West2020-04-301-92/+117
| | | | | | | | | | The example assumed that there was always at least one TX and on RX channel. Since that is not always true, this change checks for TX and RX channels and only exucutes tests for what exists on the device. Applied clang format. Signed-off-by: Michael West <michael.west@ettus.com>
* uhd: Apply clang-format against all .cpp and .hpp files in host/Martin Braun2020-03-031-1/+1
| | | | | Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of files that clang-format gets applied against.
* examples: Wrap get_gpio_src() with try/catch blocksteviez2020-02-191-7/+14
| | | | | Non-RFNoC devices do not support get_gpio_src() entrypoing so wrap call with a try/catch block
* x300: add front-panel GPIO source controleklai2020-02-181-4/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a ZPU register to control the FP GPIO source. These are 2bits per GPIO pin, totalling 24 bits. 0 corresponds to RF-A, 1 corresponds to RF-B. The following Python code will control the upper 6 bits of the front-panel GPIO from the B-side radio on an X300: >>> import uhd >>> U = uhd.usrp.MultiUSRP("type=x300") >>> U.get_gpio_src_banks() ['FP0'] >>> U.get_gpio_src("FP0") ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA'] >>> U.set_gpio_src("FP0", ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB']) >>> U.get_gpio_src("FP0") ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB'] >>> # Make all GPIOs outputs: >>> U.set_gpio_attr("FP0A", "DDR", 0xFFF) >>> U.set_gpio_attr("FP0B", "DDR", 0xFFF) >>> # Control all GPIOs from software (not ATR): >>> U.set_gpio_attr("FP0A", "CTRL", 0x000) >>> U.set_gpio_attr("FP0B", "CTRL", 0x000) >>> # Bottom 3 pins go high from radio A >>> U.set_gpio_attr("FP0A", "OUT", 0x007) >>> # Top 3 pins go high from radio B >>> U.set_gpio_attr("FP0B", "OUT", 0xE00) Amends the gpio.cpp example to allow switching the source. Co-authored-by: Brent Stapleton <brent.stapleton@ettus.com>
* examples: gpio: Replace get_time_now() with steady_clock::now()Martin Braun2019-11-261-12/+17
| | | | | | | | | | The gpio example would continously call get_time_now() to time a loop. There is no need to query a device here, so we query the system timer instead. This fixes an issue where the large amounts of control traffic could slow down TX, causing the TX and FDX tests to fail. This was only ever seen on the X300_HG over 1GigE.
* examples: gpio: Fix minor issuesMartin Braun2019-11-261-3/+3
| | | | | - Use GPIO_BIT(x) instead of 1<<x where appropriate - Correctly use rx_buff/tx_buff in recv/send, respectively
* examples: gpio: Add note on which bank is being usedMartin Braun2019-11-261-0/+1
| | | | | This will print the currently-used GPIO bank's name before starting the test.
* examples: gpio: Add --list-banks optionMartin Braun2019-11-261-0/+9
| | | | | | | The gpio example can now list all available banks before running tests. Use like this: gpio --args $args --list-banks
* examples: remove thread priority elevationCiro Nishiguchi2019-10-221-2/+0
| | | | | | | Remove UHD call to elevate thread priority to realtime. Setting all threads to the same realtime priority can cause the threads to not share access to the network interface fairly, which adversely affects operation of the worker threads in UHD.
* uhd: mpm: apply clang-format to all filesBrent Stapleton2019-01-161-129/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file.
* examples: utils: skip formatting program optionsBrent Stapleton2019-01-161-0/+2
| | | | | | Turning off clang formatting around the program option declarations. clang-format makes them looks bad an unreadable because it thinks the options are function calls or something.
* example: Refactor gpio.cppMartin Braun2018-03-301-12/+22
| | | | | | Minor changes: - Remove some Boost usage - Minor formatting changes
* uhd: Update license headersMartin Braun2018-02-191-1/+2
| | | | | | | All copyright is now attributed to "Ettus Research, a National Instruments company". SPDX headers were also updated to latest version 3.0.
* Move all license headers to SPDX format.Martin Braun2017-12-221-12/+1
|
* utils: add set_thread_name API call, move thread_priority to threadAndrej Rode2017-06-291-1/+1
|
* uhd: replace BOOST_FOREACH with C++11 range-based for loopAndrej Rode2017-02-101-1/+1
| | | | | Note: This is the first commit that uses for-range, and range-based for-loops are now usable for UHD development.
* GPIO: Set CTRL register before OUT register in GPIO example.michael-west2016-12-091-3/+3
|
* fixup! Remove all boost:: namespace prefix for uint32_t, int32_t etc. ↵Martin Braun2016-11-151-12/+12
| | | | | | (fixed-width types) Now also removes the namespaces in examples/
* Remove all boost:: namespace prefix for uint32_t, int32_t etc. (fixed-width ↵Martin Braun2016-11-081-1/+1
| | | | | | | | types) - Also removes all references to boost/cstdint.hpp and replaces it with stdint.h (The 'correct' replacement would be <cstdint>, but not all of our compilers support that).
* B200: UHD support for FPGPIO connector on REV6+ boards.Ian Buckley2015-03-091-0/+462
- GPIO on UART connector all board Revs - Consolidated fpgpio_bitbang into fpgpio example and renamed it gpio - Changed FP_GPIO readback address to match X300