diff options
author | ttsou | 2009-09-14 00:08:02 -0400 |
---|---|---|
committer | ttsou | 2009-09-16 17:08:52 -0400 |
commit | 0f03f1c1d460d865aeff91b9538266b0b210a357 (patch) | |
tree | 12d6281362c71538c6be8a1adc52774021e2af2f | |
parent | 2c30dff7d519987a0f239f29f09e340d203c0148 (diff) | |
download | gnuradio-0f03f1c1d460d865aeff91b9538266b0b210a357.tar.gz gnuradio-0f03f1c1d460d865aeff91b9538266b0b210a357.tar.bz2 gnuradio-0f03f1c1d460d865aeff91b9538266b0b210a357.zip |
Combined additiona usrp_prims code
-rw-r--r-- | config/usrp_libusb.m4 | 6 | ||||
-rw-r--r-- | usrp/host/include/usrp/usrp_prims.h.in | 17 | ||||
-rw-r--r-- | usrp/host/lib/usrp_basic_libusb.cc | 8 | ||||
-rw-r--r-- | usrp/host/lib/usrp_basic_libusb1.cc | 13 | ||||
-rw-r--r-- | usrp/host/lib/usrp_prims_common.cc | 153 | ||||
-rw-r--r-- | usrp/host/lib/usrp_prims_libusb.cc | 173 | ||||
-rw-r--r-- | usrp/host/lib/usrp_prims_libusb1.cc | 184 |
7 files changed, 217 insertions, 337 deletions
diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index 107144e33..593ffbd5c 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -108,8 +108,10 @@ _EOF_ if test x$have_libusb1 = xno; then echo 'struct usb_device;'>> $tmpfile echo 'struct usb_dev_handle;'>> $tmpfile - echo 'typedef struct usb_device libusb_device;' >> $tmpfile - echo 'typedef struct usb_dev_handle libusb_device_handle;' >> $tmpfile + echo 'struct usb_device_descriptor;' >> $tmpfile + echo 'typedef usb_device libusb_device;' >> $tmpfile + echo 'typedef usb_dev_handle libusb_device_handle;' >> $tmpfile + echo 'typedef usb_device_descriptor libusb_device_descriptor;' >> $tmpfile echo >> $tmpfile fi diff --git a/usrp/host/include/usrp/usrp_prims.h.in b/usrp/host/include/usrp/usrp_prims.h.in index 69f41e57d..ae12bbe65 100644 --- a/usrp/host/include/usrp/usrp_prims.h.in +++ b/usrp/host/include/usrp/usrp_prims.h.in @@ -260,19 +260,22 @@ std::string usrp_serial_number(libusb_device_handle *udh); * Internal functions */ -bool _usrp_configured_p (libusb_device *q); - libusb_device_handle *usrp_open_interface(libusb_device *dev, int interface, int altinterface); -bool write_internal_ram (libusb_device_handle *udh, unsigned char *buf, - int start_addr, size_t len); - int write_cmd (libusb_device_handle *udh, int request, int value, int index, unsigned char *bytes, int len); -bool usrp1_fpga_write (libusb_device_handle *udh, int regno, int value); -bool usrp1_fpga_read (libusb_device_handle *udh, int regno, int *value); +libusb_device_descriptor get_usb_device_descriptor (libusb_device *q); + +libusb_device *get_usb_device (libusb_device_handle *udh); + +int usb_control_transfer (struct usb_dev_handle *udh, int request_type, + int request, int value, int index, + unsigned char *data, int length, + unsigned int timeout); +} + #endif /* _USRP_PRIMS_H_ */ diff --git a/usrp/host/lib/usrp_basic_libusb.cc b/usrp/host/lib/usrp_basic_libusb.cc index c4842cac9..bd22d6ad4 100644 --- a/usrp/host/lib/usrp_basic_libusb.cc +++ b/usrp/host/lib/usrp_basic_libusb.cc @@ -43,13 +43,6 @@ using namespace ad9862; #define NELEM(x) (sizeof (x) / sizeof (x[0])) -// These set the buffer size used for each end point using the fast -// usb interface. The kernel ends up locking down this much memory. - -static const int FUSB_BUFFER_SIZE = fusb_sysconfig::default_buffer_size(); -static const int FUSB_BLOCK_SIZE = fusb_sysconfig::max_block_size(); -static const int FUSB_NBLOCKS = FUSB_BUFFER_SIZE / FUSB_BLOCK_SIZE; - static const double POLLING_INTERVAL = 0.1; // seconds @@ -65,7 +58,6 @@ static const double POLLING_INTERVAL = 0.1; // seconds // CLKIN = 64 MHz // CLKSEL pin = high // -// These settings give us: // CLKOUT1 = CLKIN = 64 MHz // CLKOUT2 = CLKIN = 64 MHz // ADC is clocked at 64 MHz diff --git a/usrp/host/lib/usrp_basic_libusb1.cc b/usrp/host/lib/usrp_basic_libusb1.cc index b1e3a5e3e..64cff6078 100644 --- a/usrp/host/lib/usrp_basic_libusb1.cc +++ b/usrp/host/lib/usrp_basic_libusb1.cc @@ -44,13 +44,6 @@ using namespace ad9862; #define NELEM(x) (sizeof (x) / sizeof (x[0])) -// These set the buffer size used for each end point using the fast -// usb interface. The kernel ends up locking down this much memory. - -static const int FUSB_BUFFER_SIZE = fusb_sysconfig::default_buffer_size(); -static const int FUSB_BLOCK_SIZE = fusb_sysconfig::max_block_size(); -static const int FUSB_NBLOCKS = FUSB_BUFFER_SIZE / FUSB_BLOCK_SIZE; - static const double POLLING_INTERVAL = 0.1; // seconds @@ -103,7 +96,6 @@ usrp_basic::usrp_basic (int which_board, */ memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows)); -// d_ctx = usrp_one_time_init(true); usrp_one_time_init (&d_ctx); if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename, d_ctx)) @@ -144,9 +136,8 @@ usrp_basic::~usrp_basic () if (d_udh) libusb_close (d_udh); - // Each object should be running in it's own context. If running in default - // context then leave the instance open as it may be shared. This might - // occur in mixed libusb-0.12 and libusb-1.0 environments. + // Each object _should_ be running in its own context. If running in default + // context then leave the instance open as it may be shared. if (d_ctx != NULL) libusb_exit (d_ctx); diff --git a/usrp/host/lib/usrp_prims_common.cc b/usrp/host/lib/usrp_prims_common.cc index af763acc2..1517d51ac 100644 --- a/usrp/host/lib/usrp_prims_common.cc +++ b/usrp/host/lib/usrp_prims_common.cc @@ -40,6 +40,7 @@ #include <algorithm> #include <ad9862.h> #include <assert.h> +#include "std_paths.h" #ifdef HAVE_LIBUSB_1 #include <libusb-1.0/libusb.h> @@ -67,9 +68,6 @@ static const char *default_firmware_filename = "std.ihx"; static const char *default_fpga_filename = "std_2rxhb_2tx.rbf"; -#include "std_paths.h" -#include <stdio.h> - static char * find_file (const char *filename, int hw_rev) { @@ -107,10 +105,48 @@ get_proto_filename(const std::string user_filename, const char *env_var, const c } -void power_down_9862s (libusb_device_handle *udh); +static void power_down_9862s (libusb_device_handle *udh); + // ---------------------------------------------------------------- +/* + * q must be a real USRP, not an FX2. Return its hardware rev number. + */ + +int +usrp_hw_rev (libusb_device *q) +{ + libusb_device_descriptor desc = get_usb_device_descriptor(q); + return desc.bcdDevice & 0x00FF; +} + +/* + * q must be a real USRP, not an FX2. Return true if it's configured. + */ +static bool +_usrp_configured_p (libusb_device *q) +{ + libusb_device_descriptor desc = get_usb_device_descriptor(q); + return (desc.bcdDevice & 0xFF00) != 0; +} + +bool +usrp_usrp_p (libusb_device *q) +{ + libusb_device_descriptor desc = get_usb_device_descriptor(q); + return (desc.idVendor == USB_VID_FSF + && desc.idProduct == USB_PID_FSF_USRP); +} + +bool +usrp_fx2_p (libusb_device *q) +{ + libusb_device_descriptor desc = get_usb_device_descriptor(q); + return (desc.idVendor == USB_VID_CYPRESS + && desc.idProduct == USB_PID_CYPRESS_FX2); +} + bool usrp_usrp0_p (libusb_device *q) { @@ -142,6 +178,10 @@ usrp_configured_usrp_p (libusb_device *q) return usrp_usrp_p (q) && _usrp_configured_p (q); } + +// ---------------------------------------------------------------- + + libusb_device_handle * usrp_open_cmd_interface (libusb_device *dev) { @@ -162,6 +202,35 @@ usrp_open_tx_interface (libusb_device *dev) // ---------------------------------------------------------------- +// write internal ram using Cypress vendor extension + +static bool +write_internal_ram (libusb_device_handle *udh, unsigned char *buf, + int start_addr, size_t len) +{ + int addr; + int n; + int a; + int quanta = MAX_EP0_PKTSIZE; + + for (addr = start_addr; addr < start_addr + (int) len; addr += quanta){ + n = len + start_addr - addr; + if (n > quanta) + n = quanta; + + a = usb_control_transfer (udh, 0x40, 0xA0, + addr, 0, (unsigned char *)(buf + (addr - start_addr)), n, 1000); + + if (a < 0){ + fprintf(stderr,"write_internal_ram failed: %u\n", a); + return false; + } + } + return true; +} + + +// ---------------------------------------------------------------- // whack the CPUCS register using the upload RAM vendor extension static bool @@ -348,6 +417,31 @@ usrp_set_led (libusb_device_handle *udh, int which, bool on) return r == 0; } +bool +usrp_set_hash (libusb_device_handle *udh, int which, + const unsigned char hash[USRP_HASH_SIZE]) +{ + which &= 1; + + // we use the Cypress firmware down load command to jam it in. + int r = usb_control_transfer (udh, 0x40, 0xa0, hash_slot_addr[which], 0, + (unsigned char *) hash, USRP_HASH_SIZE, 1000); + return r == USRP_HASH_SIZE; +} + +bool +usrp_get_hash (libusb_device_handle *udh, int which, + unsigned char hash[USRP_HASH_SIZE]) +{ + which &= 1; + + // we use the Cypress firmware upload command to fetch it. + int r = usb_control_transfer (udh, 0xc0, 0xa0, hash_slot_addr[which], 0, + (unsigned char *) hash, USRP_HASH_SIZE, 1000); + return r == USRP_HASH_SIZE; +} + + static bool usrp_set_switch (libusb_device_handle *udh, int cmd_byte, bool on) @@ -355,7 +449,7 @@ usrp_set_switch (libusb_device_handle *udh, int cmd_byte, bool on) return write_cmd (udh, cmd_byte, on, 0, 0, 0) == 0; } -bool +static bool usrp1_fpga_write (libusb_device_handle *udh, int regno, int value) { @@ -374,7 +468,7 @@ usrp1_fpga_write (libusb_device_handle *udh, buf, sizeof (buf)); } -bool +static bool usrp1_fpga_read (libusb_device_handle *udh, int regno, int *value) { @@ -392,6 +486,29 @@ usrp1_fpga_read (libusb_device_handle *udh, return ok; } +bool +usrp_write_fpga_reg (libusb_device_handle *udh, int reg, int value) +{ + switch (usrp_hw_rev (get_usb_device (udh))){ + case 0: // not supported ;) + abort(); + + default: + return usrp1_fpga_write (udh, reg, value); + } +} + +bool +usrp_read_fpga_reg (libusb_device_handle *udh, int reg, int *value) +{ + switch (usrp_hw_rev (get_usb_device (udh))){ + case 0: // not supported ;) + abort(); + + default: + return usrp1_fpga_read (udh, reg, value); + } +} bool usrp_set_fpga_reset (libusb_device_handle *udh, bool on) @@ -814,6 +931,25 @@ usrp_9862_write_many_all (libusb_device_handle *udh, return result; } +static void +power_down_9862s (libusb_device_handle *udh) +{ + static const unsigned char regs[] = { + REG_RX_PWR_DN, 0x01, // everything + REG_TX_PWR_DN, 0x0f, // pwr dn digital and analog_both + REG_TX_MODULATOR, 0x00 // coarse & fine modulators disabled + }; + + switch (usrp_hw_rev (get_usb_device (udh))){ + case 0: + break; + + default: + usrp_9862_write_many_all (udh, regs, sizeof (regs)); + break; + } +} + static const int EEPROM_PAGESIZE = 16; @@ -1077,3 +1213,8 @@ usrp_write_dboard_offsets (libusb_device_handle *udh, int slot_id, return usrp_eeprom_write (udh, slot_to_i2c_addr (slot_id), 0, buf, sizeof (buf)); } + + + + + diff --git a/usrp/host/lib/usrp_prims_libusb.cc b/usrp/host/lib/usrp_prims_libusb.cc index 9371fb0e2..d07caaa9d 100644 --- a/usrp/host/lib/usrp_prims_libusb.cc +++ b/usrp/host/lib/usrp_prims_libusb.cc @@ -26,10 +26,7 @@ #include "usrp/usrp_prims.h" #include "usrp_commands.h" -#include "usrp_ids.h" -#include "usrp_i2c_addr.h" -#include "fpga_regs_common.h" -#include "fpga_regs_standard.h" +//#include "usrp_ids.h" #include <usb.h> #include <errno.h> #include <stdio.h> @@ -37,8 +34,6 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> -#include <time.h> // FIXME should check with autoconf (nanosleep) -#include <algorithm> #include <ad9862.h> #include <assert.h> @@ -46,23 +41,33 @@ extern "C" { #include "md5.h" }; -#define VERBOSE 0 - using namespace ad9862; -static const int FIRMWARE_HASH_SLOT = 0; -static const int FPGA_HASH_SLOT = 1; +struct usb_device_descriptor +get_usb_device_descriptor (struct usb_device *q) +{ + return q->descriptor; +} -static const int hash_slot_addr[2] = { - USRP_HASH_SLOT_0_ADDR, - USRP_HASH_SLOT_1_ADDR -}; +struct usb_device * +get_usb_device (struct usb_dev_handle *udh) +{ + return usb_device (udh); +} -static const char *default_firmware_filename = "std.ihx"; -static const char *default_fpga_filename = "std_2rxhb_2tx.rbf"; +int +usb_control_transfer (struct usb_dev_handle *udh, int request_type, + int request, int value, int index, + unsigned char *data, int length, unsigned int timeout) +{ + return usb_control_msg (udh, request_type, request, value, index, + (char*) *data, length, (int) timeout); + +} + + +// ---------------------------------------------------------------- -#include "std_paths.h" -#include <stdio.h> void usrp_one_time_init (libusb_context **ctx) @@ -84,42 +89,10 @@ usrp_rescan () usb_find_devices (); } -// ---------------------------------------------------------------- - -/* - * q must be a real USRP, not an FX2. Return its hardware rev number. - */ -int -usrp_hw_rev (struct usb_device *q) -{ - return q->descriptor.bcdDevice & 0x00FF; -} - -/* - * q must be a real USRP, not an FX2. Return true if it's configured. - */ -bool -_usrp_configured_p (struct usb_device *q) -{ - return (q->descriptor.bcdDevice & 0xFF00) != 0; -} - -bool -usrp_usrp_p (struct usb_device *q) -{ - return (q->descriptor.idVendor == USB_VID_FSF - && q->descriptor.idProduct == USB_PID_FSF_USRP); -} - -bool -usrp_fx2_p (struct usb_device *q) -{ - return (q->descriptor.idVendor == USB_VID_CYPRESS - && q->descriptor.idProduct == USB_PID_CYPRESS_FX2); -} // ---------------------------------------------------------------- + struct usb_device * usrp_find_device (int nth, bool fx2_ok_p, libusb_context *ctx) { @@ -201,38 +174,11 @@ usrp_close_interface (struct usb_dev_handle *udh) return usb_close (udh) == 0; } -// ---------------------------------------------------------------- -// write internal ram using Cypress vendor extension - -bool -write_internal_ram (struct usb_dev_handle *udh, unsigned char *buf, - int start_addr, size_t len) -{ - int addr; - int n; - int a; - int quanta = MAX_EP0_PKTSIZE; - - for (addr = start_addr; addr < start_addr + (int) len; addr += quanta){ - n = len + start_addr - addr; - if (n > quanta) - n = quanta; - - a = usb_control_msg (udh, 0x40, 0xA0, - addr, 0, (char *)(buf + (addr - start_addr)), n, 1000); - - if (a < 0){ - fprintf(stderr,"write_internal_ram failed: %s\n", usb_strerror()); - return false; - } - } - return true; -} - // ---------------------------------------------------------------- // write vendor extension command to USRP + int write_cmd (struct usb_dev_handle *udh, int request, int value, int index, @@ -252,76 +198,9 @@ write_cmd (struct usb_dev_handle *udh, } -bool -usrp_set_hash (struct usb_dev_handle *udh, int which, - const unsigned char hash[USRP_HASH_SIZE]) -{ - which &= 1; - - // we use the Cypress firmware down load command to jam it in. - int r = usb_control_msg (udh, 0x40, 0xa0, hash_slot_addr[which], 0, - (char *) hash, USRP_HASH_SIZE, 1000); - return r == USRP_HASH_SIZE; -} - -bool -usrp_get_hash (struct usb_dev_handle *udh, int which, - unsigned char hash[USRP_HASH_SIZE]) -{ - which &= 1; - - // we use the Cypress firmware upload command to fetch it. - int r = usb_control_msg (udh, 0xc0, 0xa0, hash_slot_addr[which], 0, - (char *) hash, USRP_HASH_SIZE, 1000); - return r == USRP_HASH_SIZE; -} - -bool -usrp_write_fpga_reg (struct usb_dev_handle *udh, int reg, int value) -{ - switch (usrp_hw_rev (usb_device (udh))){ - case 0: // not supported ;) - abort(); - - default: - return usrp1_fpga_write (udh, reg, value); - } -} - -bool -usrp_read_fpga_reg (struct usb_dev_handle *udh, int reg, int *value) -{ - switch (usrp_hw_rev (usb_device (udh))){ - case 0: // not supported ;) - abort(); - - default: - return usrp1_fpga_read (udh, reg, value); - } -} - - -void -power_down_9862s (struct usb_dev_handle *udh) -{ - static const unsigned char regs[] = { - REG_RX_PWR_DN, 0x01, // everything - REG_TX_PWR_DN, 0x0f, // pwr dn digital and analog_both - REG_TX_MODULATOR, 0x00 // coarse & fine modulators disabled - }; - - switch (usrp_hw_rev (usb_device (udh))){ - case 0: - break; - - default: - usrp_9862_write_many_all (udh, regs, sizeof (regs)); - break; - } -} - // ---------------------------------------------------------------- + std::string usrp_serial_number(struct usb_dev_handle *udh) { diff --git a/usrp/host/lib/usrp_prims_libusb1.cc b/usrp/host/lib/usrp_prims_libusb1.cc index 672974259..5cea97d8b 100644 --- a/usrp/host/lib/usrp_prims_libusb1.cc +++ b/usrp/host/lib/usrp_prims_libusb1.cc @@ -41,97 +41,64 @@ #include <algorithm> #include <ad9862.h> #include <assert.h> +#include "std_paths.h" extern "C" { #include "md5.h" }; -#define VERBOSE 0 - using namespace ad9862; -static const int FIRMWARE_HASH_SLOT = 0; -static const int FPGA_HASH_SLOT = 1; - -static const int hash_slot_addr[2] = { - USRP_HASH_SLOT_0_ADDR, - USRP_HASH_SLOT_1_ADDR -}; - -static const char *default_firmware_filename = "std.ihx"; -static const char *default_fpga_filename = "std_2rxhb_2tx.rbf"; -#include "std_paths.h" -#include <stdio.h> - -void -usrp_one_time_init (libusb_context **ctx) +struct libusb_device_descriptor +get_usb_device_descriptor(struct libusb_device *q) { int ret; + struct libusb_device_descriptor desc; - if ((ret = libusb_init (ctx)) < 0) - fprintf (stderr, "usrp: libusb_init failed %i\n", ret); + if ((ret = libusb_get_device_descriptor(q, &desc)) < 0) + fprintf (stderr, "usrp: libusb_get_device_descriptor failed %d\n", ret); + + return desc; } -void -usrp_rescan () +struct libusb_device * +get_usb_device (struct libusb_device_handle *udh) { - // nop + return libusb_get_device (udh); } -// ---------------------------------------------------------------- - -/* - * q must be a real USRP, not an FX2. Return its hardware rev number. - */ int -usrp_hw_rev (struct libusb_device *q) +usb_control_transfer (struct usb_dev_handle *udh, uint8_t request_type, + uint8_t request, uint16_t value, uint16_t index, + unsigned char *data, uint16_t length, + unsigned int timeout) { - struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(q, &desc) < 0) - fprintf (stderr, "usrp: libusb_get_device_descriptor failed\n"); + return libusb_control_transfer (udh, request_type, request, value, index, + *data, length, timeout); - return desc.bcdDevice & 0x00FF; } -/* - * q must be a real USRP, not an FX2. Return true if it's configured. - */ -bool -_usrp_configured_p (struct libusb_device *q) -{ - struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(q, &desc) < 0) - fprintf (stderr, "usrp: libusb_get_device_descriptor failed\n"); - return (desc.bcdDevice & 0xFF00) != 0; -} +// ---------------------------------------------------------------- -bool -usrp_usrp_p (struct libusb_device *q) + +void +usrp_one_time_init (libusb_context **ctx) { - struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(q, &desc) < 0) - fprintf (stderr, "usrp: libusb_get_device_descriptor failed\n"); + int ret; - return (desc.idVendor == USB_VID_FSF - && desc.idProduct == USB_PID_FSF_USRP); + if ((ret = libusb_init (ctx)) < 0) + fprintf (stderr, "usrp: libusb_init failed %i\n", ret); } -bool -usrp_fx2_p (struct libusb_device *q) +void +usrp_rescan () { - struct libusb_device_descriptor desc; - if (libusb_get_device_descriptor(q, &desc) < 0) - fprintf (stderr, "usrp: libusb_get_device_descriptor failed\n"); - - return (desc.idVendor == USB_VID_CYPRESS - && desc.idProduct == USB_PID_CYPRESS_FX2); + // nop } -// ---------------------------------------------------------------- - struct libusb_device * usrp_find_device (int nth, bool fx2_ok_p, libusb_context *ctx) { @@ -207,37 +174,11 @@ usrp_close_interface (libusb_device_handle *udh) return 0; } -// ---------------------------------------------------------------- -// write internal ram using Cypress vendor extension - -bool -write_internal_ram (struct libusb_device_handle *udh, unsigned char *buf, - int start_addr, size_t len) -{ - int addr; - int n; - int a; - int quanta = MAX_EP0_PKTSIZE; - - for (addr = start_addr; addr < start_addr + (int) len; addr += quanta){ - n = len + start_addr - addr; - if (n > quanta) - n = quanta; - - a = libusb_control_transfer (udh, 0x40, 0xA0, - addr, 0, (unsigned char *)(buf + (addr - start_addr)), n, 1000); - - if (a < 0){ - fprintf(stderr,"write_internal_ram failed: %u\n", a); - return false; - } - } - return true; -} // ---------------------------------------------------------------- // write vendor extension command to USRP + int write_cmd (struct libusb_device_handle *udh, int request, int value, int index, @@ -258,75 +199,6 @@ write_cmd (struct libusb_device_handle *udh, return r; } -bool -usrp_set_hash (struct libusb_device_handle *udh, int which, - const unsigned char hash[USRP_HASH_SIZE]) -{ - which &= 1; - - // we use the Cypress firmware down load command to jam it in. - int r = libusb_control_transfer (udh, 0x40, 0xa0, hash_slot_addr[which], 0, - (unsigned char *) hash, USRP_HASH_SIZE, 1000); - return r == USRP_HASH_SIZE; -} - -bool -usrp_get_hash (struct libusb_device_handle *udh, int which, - unsigned char hash[USRP_HASH_SIZE]) -{ - which &= 1; - - // we use the Cypress firmware upload command to fetch it. - int r = libusb_control_transfer (udh, 0xc0, 0xa0, hash_slot_addr[which], 0, - (unsigned char *) hash, USRP_HASH_SIZE, 1000); - return r == USRP_HASH_SIZE; -} - -bool -usrp_write_fpga_reg (struct libusb_device_handle *udh, int reg, int value) -{ - switch (usrp_hw_rev (libusb_get_device (udh))){ - case 0: // not supported ;) - abort(); - - default: - return usrp1_fpga_write (udh, reg, value); - } -} - -bool -usrp_read_fpga_reg (struct libusb_device_handle *udh, int reg, int *value) -{ - switch (usrp_hw_rev (libusb_get_device (udh))){ - case 0: // not supported ;) - abort(); - - default: - return usrp1_fpga_read (udh, reg, value); - } -} - - - -void -power_down_9862s (struct libusb_device_handle *udh) -{ - static const unsigned char regs[] = { - REG_RX_PWR_DN, 0x01, // everything - REG_TX_PWR_DN, 0x0f, // pwr dn digital and analog_both - REG_TX_MODULATOR, 0x00 // coarse & fine modulators disabled - }; - - switch (usrp_hw_rev (libusb_get_device (udh))){ - case 0: - break; - - default: - usrp_9862_write_many_all (udh, regs, sizeof (regs)); - break; - } -} - // ---------------------------------------------------------------- |