File: iofx2.h

package info (click to toggle)
xc3sprog 0%2Bsvn795%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 8,800 kB
  • sloc: cpp: 15,983; ansic: 849; vhdl: 410; makefile: 3
file content (75 lines) | stat: -rw-r--r-- 2,334 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* JTAG low-level I/O to FX2

Using I2C addresses above 0x80 in the USRP/XGUFF framework

Copyright (C) 2005-2011 Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef IOFX2_H
#define IOFX2_H

#if defined (__WIN32__)
#include <windows.h>
#include <libusb0/usb.h>
#else
#include <usb.h>
#endif

#include "iobase.h"
#include "cabledb.h"

#define USRP_VENDOR 0xfffe
#define USRP_DEVICE 0x0018

/* Not yet defined in usrp*/
#define USRP_CLOCK_INOUT_BYTES     0x80
#define USRP_CLOCK_OUT_BYTES       0x81
#define USRP_CLOCK_IN_BYTES        0x81
#define USRP_CLOCK_INOUT_BITS      0x82
#define USRP_CLOCK_INOUT_BITS_LAST 0x83
#define USPR_CLOCK_OUT_TMS         0x84

#define USRP_CMD_SIZE  64

class IOFX2 : public IOBase
{
 protected:
  int bptr, calls_rd, calls_wr;

 public:
  IOFX2();
  int Init(struct cable_t *cable, char const *serial, unsigned int freq);
  ~IOFX2();

  void txrx_block(const unsigned char *tdi, unsigned char *tdo, int length, bool last);
  void tx_tms(unsigned char *pat, int length, int force);

 private:
  struct usb_dev_handle *fx2_dev;
  /// String representation of last error
  const char *error_str;
  int fx2_usb_open_desc(int vendor, int product, const char* description, const char* serial);
  struct usb_dev_handle * usrp_open_interface (struct usb_device *dev, int interface, int altinterface);
  bool usrp_close_interface (struct usb_dev_handle *udh);
  bool usrp_i2c_write(int address, const void *buf, int len);
  bool usrp_i2c_read (int i2c_addr, void *buf, int len);
  int  write_cmd (struct usb_dev_handle *udh,
		  int request, int value, int index,
		  unsigned char *bytes, int len);
};

#endif // IOFX2_H