ZTEX core API for C
Host software API for ZTEX FPGA Boards for C
 All Data Structures Files Functions Variables
ztex.h
Go to the documentation of this file.
1 /*#
2  ZTEX Core API for C with examples
3  Copyright (C) 2009-2017 ZTEX GmbH.
4  http://www.ztex.de
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License version 3 as
8  published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, see http://www.gnu.org/licenses/.
17 #*/
18 
25 #ifndef __ztex_H
26 #define __ztex_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <sys/types.h>
33 #include <libusb-1.0/libusb.h>
34 
37 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
38 #define DIRSEP "\\"
39 #else
40 #define DIRSEP "/"
41 #endif
42 
43 #define TWO_TRIES( status, cmd ) \
44 {status = cmd;} \
45 if ( status < 0 ) { status=cmd; }
46 
49 typedef struct {
51  unsigned char product_string[128];
53  unsigned char sn_string[64];
55  uint8_t fx_version;
57  uint8_t board_series;
59  uint8_t board_number;
61  unsigned char board_variant[3];
63  uint8_t fast_config_ep;
65  uint8_t fast_config_if;
71  uint8_t default_out_ep;
73  uint8_t default_in_ep;
75 
76 
86 int ztex_scan_bus(char *sbuf, int sbuflen, libusb_device **devs, int op, int id_vendor, int id_product, int busnum, int devnum, char* sn, char* ps);
87 int ztex_get_device_info(libusb_device_handle *handle, ztex_device_info *info);
88 int ztex_print_device_info(char* sbuf, int sbuflen, const ztex_device_info *info);
89 
90 int ztex_get_fpga_config(libusb_device_handle *handle);
91 char* ztex_find_bitstream(const ztex_device_info *info, const char *path, const char* name);
92 int ztex_upload_bitstream(char* sbuf, int sbuflen, libusb_device_handle *handle, const ztex_device_info *info, FILE* fd, int bs);
93 
94 int ztex_default_gpio_ctl (libusb_device_handle *handle, int mask, int value) ;
95 int ztex_default_reset(libusb_device_handle *handle, int leave );
96 int ztex_default_lsi_set1 (libusb_device_handle *handle, uint8_t addr, uint32_t val);
97 int ztex_default_lsi_set2 (libusb_device_handle *handle, uint8_t addr, const uint32_t *val, int length);
98 int ztex_default_lsi_set3 (libusb_device_handle *handle, const uint8_t *addr, const uint32_t *val, int length);
99 int64_t ztex_default_lsi_get1 (libusb_device_handle *handle, uint8_t addr);
100 int ztex_default_lsi_get2 (libusb_device_handle *handle, uint8_t addr, uint32_t *val, int length);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif
uint8_t fast_config_ep
Endpoint for fast FPGA configuration; 0 means unsupported.
Definition: ztex.h:63
int ztex_print_device_info(char *sbuf, int sbuflen, const ztex_device_info *info)
Print device info to a string.
Definition: ztex.c:235
int ztex_get_device_info(libusb_device_handle *handle, ztex_device_info *info)
Get device information.
Definition: ztex.c:174
A structure with information about the device.
Definition: ztex.h:49
int ztex_default_lsi_set2(libusb_device_handle *handle, uint8_t addr, const uint32_t *val, int length)
Send data to the low speed interface of default firmwares.
Definition: ztex.c:544
uint8_t board_series
e.g. 2 for USB-FPGA Modules 2.14b; 255 means unknown
Definition: ztex.h:57
uint8_t default_in_ep
input endpoint of default interface; 255 means not available
Definition: ztex.h:73
uint8_t board_number
e.g. 14 for USB-FPGA Modules 2.14b; 255 means unknown
Definition: ztex.h:59
uint8_t default_version1
default interface major version number; 0 means default interface not available
Definition: ztex.h:67
char * ztex_find_bitstream(const ztex_device_info *info, const char *path, const char *name)
Search for bitstream at standard locations.
Definition: ztex.c:287
int ztex_get_fpga_config(libusb_device_handle *handle)
Get device information.
Definition: ztex.c:261
int ztex_default_gpio_ctl(libusb_device_handle *handle, int mask, int value)
Reads and modifies the 4 GPIO pins.
Definition: ztex.c:494
uint8_t fx_version
2 for FX2, 3 for FX3
Definition: ztex.h:55
int ztex_default_reset(libusb_device_handle *handle, int leave)
Assert the reset signal.
Definition: ztex.c:508
uint8_t fast_config_if
Interface for fast FPGA configuration.
Definition: ztex.h:65
int64_t ztex_default_lsi_get1(libusb_device_handle *handle, uint8_t addr)
Read data from the low speed interface of default firmwares.
Definition: ztex.c:602
uint8_t default_out_ep
output endpoint of default interface; 255 means not available
Definition: ztex.h:71
int ztex_default_lsi_set3(libusb_device_handle *handle, const uint8_t *addr, const uint32_t *val, int length)
Send data to the low speed interface of default firmwares.
Definition: ztex.c:574
uint8_t default_version2
default interface minor version number
Definition: ztex.h:69
int ztex_default_lsi_get2(libusb_device_handle *handle, uint8_t addr, uint32_t *val, int length)
Read data from the low speed interface of default firmwares.
Definition: ztex.c:620
int ztex_default_lsi_set1(libusb_device_handle *handle, uint8_t addr, uint32_t val)
Send data to the low speed interface of default firmwares.
Definition: ztex.c:525
int ztex_upload_bitstream(char *sbuf, int sbuflen, libusb_device_handle *handle, const ztex_device_info *info, FILE *fd, int bs)
Upload bitstream to volatile memory.
Definition: ztex.c:319
int ztex_scan_bus(char *sbuf, int sbuflen, libusb_device **devs, int op, int id_vendor, int id_product, int busnum, int devnum, char *sn, char *ps)
Scans the bus and performs certain operations on it.
Definition: ztex.c:105