Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
university:tools:pluto:hacking:power_amp [11 Jul 2019 01:00]
Robin Getz add note about speed
university:tools:pluto:hacking:power_amp [16 Jul 2019 20:15] (current)
Robin Getz [Test Results]
Line 87: Line 87:
 </​WRAP>​ </​WRAP>​
  
 +OK, someone asked for the C code - it's pretty trivial, just longer. You will need to change the uri, and put in proper error checking.
 +
 +<​code>​
 +#include <​stdio.h>​
 +#include <​iio.h>​
 +#include <​unistd.h>​
 +#include <​stdio.h>​
 +#include <​signal.h>​
 +
 +
 +volatile sig_atomic_t stop = 0;
 +
 +void inthand(int signum) {
 +        stop = 1;
 +}
 +
 +int main(int argc, char **argv)
 +{
 +        struct iio_context *ctx;
 +        struct iio_device *dev;
 +        struct iio_channel *ch;
 +        const char* val_str;
 +        ssize_t ret = 0;
 +        char buf[256];
 +
 +        signal(SIGINT,​ inthand);
 +
 +        /* Create IIO Context */
 +        ctx = iio_create_context_from_uri("​usb:​1.3.5"​);​
 +
 +        /* Find IIO device in current context */
 +        dev = iio_context_find_device(ctx,​ "​ad9361-phy"​);​
 +
 +        /* Write into the IIO debug attributes */
 +        iio_device_debug_attr_write_bool(dev,​ "​adi,​frequency-division-duplex-mode-enable",​ 0);
 +        iio_device_debug_attr_write_bool(dev,​ "​adi,​gpo0-slave-rx-enable",​ 1);
 +        iio_device_debug_attr_write_bool(dev,​ "​adi,​gpo1-slave-tx-enable",​ 1);
 +        iio_device_debug_attr_write_bool(dev,​ "​initialize",​ 1);
 +        ​
 +        while (!stop) {
 +                ret++;
 +                iio_device_attr_write(dev,​ "​ensm_mode",​ "​rx"​);​
 +                iio_device_attr_write(dev,​ "​ensm_mode",​ "​tx"​);​
 +        }
 +        iio_context_destroy(ctx);​
 +        printf("​iteration = %li\n",​ ret);
 +        return EXIT_SUCCESS;​
 +}
 +</​code>​
 +
 +Over USB, you get:<​xterm>​
 + time ./foo 
 +^Citteration = 2693
 +
 +real 0m5.283s
 +</​xterm>​
 +
 +or about 0.980876346 ms per Rx/Tx slot.
 +
 +^ Platform ​ ^ transport ^ Infrastructure ​ ^  Timing ^
 +| host | USB | shell | 80ms |
 +| host | USB | C code | 0.6 to 1.3 ms |
 +| pluto | local | shell | 30-35ms |
 +| pluto | local | C Code | 0.2 to 0.6 ms | 
 +
 +Again, these are representative numbers for software control, faster is possible with pin control.
 ===== Testing in IIO Oscilloscope ===== ===== Testing in IIO Oscilloscope =====
  
university/tools/pluto/hacking/power_amp.1562799655.txt.gz · Last modified: 11 Jul 2019 01:00 by Robin Getz