usb_blaster: ublast_access.h: add guard macro
[openocd.git] / src / jtag / drivers / usb_blaster / ublast_access.h
1 /*
2 * Driver for USB-JTAG, Altera USB-Blaster and compatibles
3 *
4 * Inspired from original code from Kolja Waschk's USB-JTAG project
5 * (http://www.ixo.de/info/usb_jtag/), and from openocd project.
6 *
7 * Copyright (C) 2013 Franck Jullien franck.jullien@gmail.com
8 * Copyright (C) 2012 Robert Jarzmik robert.jarzmik@free.fr
9 * Copyright (C) 2011 Ali Lown ali@lown.me.uk
10 * Copyright (C) 2009 Catalin Patulea cat@vv.carleton.ca
11 * Copyright (C) 2006 Kolja Waschk usbjtag@ixo.de
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 */
24
25 #ifndef JTAG_UBLAST_ACCESS_H
26 #define JTAG_UBLAST_ACCESS_H
27
28 #include <libusb_common.h>
29
30 /* Low level flags */
31 #define COPY_TDO_BUFFER (1 << 0)
32
33 struct ublast_lowlevel {
34 uint16_t ublast_vid;
35 uint16_t ublast_pid;
36 uint16_t ublast_vid_uninit;
37 uint16_t ublast_pid_uninit;
38 char *ublast_device_desc;
39 struct jtag_libusb_device_handle *libusb_dev;
40 char *firmware_path;
41
42 int (*write)(struct ublast_lowlevel *low, uint8_t *buf, int size,
43 uint32_t *bytes_written);
44 int (*read)(struct ublast_lowlevel *low, uint8_t *buf, unsigned size,
45 uint32_t *bytes_read);
46 int (*open)(struct ublast_lowlevel *low);
47 int (*close)(struct ublast_lowlevel *low);
48 int (*speed)(struct ublast_lowlevel *low, int speed);
49
50 void *priv;
51 int flags;
52 };
53
54 /**
55 * ublast_register_ftdi - get a lowlevel USB Blaster driver
56 * ublast_register_ftd2xx - get a lowlevel USB Blaster driver
57 * ublast2_register_libusb - get a lowlevel USB Blaster II driver
58 *
59 * Get a lowlevel USB-Blaster driver. In the current implementation, there are 3
60 * possible lowlevel drivers :
61 * - one based on libftdi from ftdichip.com
62 * - one based on libftdxx, the free alternative
63 * - one based on libusb, specific to the USB-Blaster II
64 *
65 * Returns the lowlevel driver structure.
66 */
67 extern struct ublast_lowlevel *ublast_register_ftdi(void);
68 extern struct ublast_lowlevel *ublast_register_ftd2xx(void);
69 extern struct ublast_lowlevel *ublast2_register_libusb(void);
70
71 #endif /* JTAG_UBLAST_ACCESS_H */