00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _USRP_PRIMS_H_
00035 #define _USRP_PRIMS_H_
00036
00037 #include <usrp_slots.h>
00038 #include <string>
00039
00040 static const int USRP_HASH_SIZE = 16;
00041
00042 enum usrp_load_status_t { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED };
00043
00044 struct usb_dev_handle;
00045 struct usb_device;
00046
00051 void usrp_one_time_init ();
00052
00053
00054
00055
00056 void usrp_rescan ();
00057
00068 struct usb_device *usrp_find_device (int nth, bool fx2_ok_p = false);
00069
00070 bool usrp_usrp_p (struct usb_device *q);
00071 bool usrp_usrp0_p (struct usb_device *q);
00072 bool usrp_usrp1_p (struct usb_device *q);
00073 bool usrp_usrp2_p (struct usb_device *q);
00074 int usrp_hw_rev (struct usb_device *q);
00075
00076 bool usrp_fx2_p (struct usb_device *q);
00077
00078 bool usrp_unconfigured_usrp_p (struct usb_device *q);
00079 bool usrp_configured_usrp_p (struct usb_device *q);
00080
00090 struct usb_dev_handle *usrp_open_cmd_interface (struct usb_device *dev);
00091 struct usb_dev_handle *usrp_open_rx_interface (struct usb_device *dev);
00092 struct usb_dev_handle *usrp_open_tx_interface (struct usb_device *dev);
00093
00097 bool usrp_close_interface (struct usb_dev_handle *udh);
00098
00108 usrp_load_status_t
00109 usrp_load_firmware (struct usb_dev_handle *udh, const char *filename, bool force);
00110
00121 usrp_load_status_t
00122 usrp_load_firmware_nth (int nth, const char *filename, bool force);
00123
00127 usrp_load_status_t
00128 usrp_load_fpga (struct usb_dev_handle *udh, const char *filename, bool force);
00129
00135 bool usrp_load_standard_bits (int nth, bool force,
00136 const std::string fpga_filename = "",
00137 const std::string firmware_filename = "");
00138
00143 bool usrp_set_hash (struct usb_dev_handle *udh, int which,
00144 const unsigned char hash[USRP_HASH_SIZE]);
00145
00150 bool usrp_get_hash (struct usb_dev_handle *udh, int which,
00151 unsigned char hash[USRP_HASH_SIZE]);
00152
00153 bool usrp_write_fpga_reg (struct usb_dev_handle *udh, int reg, int value);
00154 bool usrp_read_fpga_reg (struct usb_dev_handle *udh, int reg, int *value);
00155 bool usrp_set_fpga_reset (struct usb_dev_handle *udh, bool on);
00156 bool usrp_set_fpga_tx_enable (struct usb_dev_handle *udh, bool on);
00157 bool usrp_set_fpga_rx_enable (struct usb_dev_handle *udh, bool on);
00158 bool usrp_set_fpga_tx_reset (struct usb_dev_handle *udh, bool on);
00159 bool usrp_set_fpga_rx_reset (struct usb_dev_handle *udh, bool on);
00160 bool usrp_set_led (struct usb_dev_handle *udh, int which, bool on);
00161
00162 bool usrp_check_rx_overrun (struct usb_dev_handle *udh, bool *overrun_p);
00163 bool usrp_check_tx_underrun (struct usb_dev_handle *udh, bool *underrun_p);
00164
00165
00166
00167 bool usrp_i2c_write (struct usb_dev_handle *udh, int i2c_addr,
00168 const void *buf, int len);
00169
00170 bool usrp_i2c_read (struct usb_dev_handle *udh, int i2c_addr,
00171 void *buf, int len);
00172
00173
00174
00175
00176 bool usrp_spi_write (struct usb_dev_handle *udh,
00177 int optional_header, int enables, int format,
00178 const void *buf, int len);
00179
00180 bool usrp_spi_read (struct usb_dev_handle *udh,
00181 int optional_header, int enables, int format,
00182 void *buf, int len);
00183
00184
00185 bool usrp_9862_write (struct usb_dev_handle *udh,
00186 int which_codec,
00187 int regno,
00188 int value);
00189
00190 bool usrp_9862_read (struct usb_dev_handle *udh,
00191 int which_codec,
00192 int regno,
00193 unsigned char *value);
00194
00201 bool usrp_9862_write_many (struct usb_dev_handle *udh, int which_codec,
00202 const unsigned char *buf, int len);
00203
00204
00208 bool usrp_9862_write_many_all (struct usb_dev_handle *udh,
00209 const unsigned char *buf, int len);
00210
00211
00212
00213
00214
00215 bool usrp_eeprom_write (struct usb_dev_handle *udh, int i2c_addr,
00216 int eeprom_offset, const void *buf, int len);
00217
00218
00219
00220
00221
00222 bool usrp_eeprom_read (struct usb_dev_handle *udh, int i2c_addr,
00223 int eeprom_offset, void *buf, int len);
00224
00225
00226
00227
00244 bool usrp_write_aux_dac (struct usb_dev_handle *uhd, int slot,
00245 int which_dac, int value);
00246
00254 bool usrp_read_aux_adc (struct usb_dev_handle *udh, int slot,
00255 int which_adc, int *value);
00256
00257
00261 const std::string usrp_dbid_to_string (int dbid);
00262
00263
00264 enum usrp_dbeeprom_status_t { UDBE_OK, UDBE_BAD_SLOT, UDBE_NO_EEPROM, UDBE_INVALID_EEPROM };
00265
00266 struct usrp_dboard_eeprom {
00267 unsigned short id;
00268 unsigned short oe;
00269
00270 short offset[2];
00271 };
00272
00276 usrp_dbeeprom_status_t
00277 usrp_read_dboard_eeprom (struct usb_dev_handle *udh,
00278 int slot_id, usrp_dboard_eeprom *eeprom);
00279
00283 bool usrp_write_dboard_offsets (struct usb_dev_handle *udh, int slot_id,
00284 short offset0, short offset1);
00285
00292 std::string usrp_serial_number(struct usb_dev_handle *udh);
00293
00294 #endif