ZTEX core API for C
Host software API for ZTEX FPGA Boards for C
ztex.h
Go to the documentation of this file.
1 /*%
2  ZTEX Core API for C with examples
3  Copyright (C) 2009-2023 ZTEX GmbH.
4  http://www.ztex.de
5 
6  This Source Code Form is subject to the terms of the Mozilla Public
7  License, v. 2.0. If a copy of the MPL was not distributed with this file,
8  You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10  Alternatively, the contents of this file may be used under the terms
11  of the GNU General Public License Version 3, as described below:
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 version 3 as
15  published by the Free Software Foundation.
16 
17  This program is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, see http://www.gnu.org/licenses/.
24 %*/
25 
32 #ifndef __ztex_H
33 #define __ztex_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <sys/types.h>
40 #include <libusb-1.0/libusb.h>
41 
44 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
45 #define DIRSEP "\\"
46 #else
47 #define DIRSEP "/"
48 #endif
49 
50 #define TWO_TRIES( status, cmd ) \
51 {status = cmd;} \
52 if ( status < 0 ) { status=cmd; }
53 
56 typedef struct {
58  unsigned char product_string[128];
60  unsigned char sn_string[64];
62  uint8_t fx_version;
64  uint8_t board_series;
66  uint8_t board_number;
68  unsigned char board_variant[3];
70  uint8_t fast_config_ep;
72  uint8_t fast_config_if;
78  uint8_t default_out_ep;
80  uint8_t default_in_ep;
82 
83 
93 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);
94 int ztex_get_device_info(libusb_device_handle *handle, ztex_device_info *info);
95 int ztex_print_device_info(char* sbuf, int sbuflen, const ztex_device_info *info);
96 
97 int ztex_get_fpga_config(libusb_device_handle *handle);
98 char* ztex_find_bitstream(const ztex_device_info *info, const char *path, const char* name);
99 int ztex_upload_bitstream(char* sbuf, int sbuflen, libusb_device_handle *handle, const ztex_device_info *info, FILE* fd, int bs);
100 
101 int ztex_default_gpio_ctl (libusb_device_handle *handle, int mask, int value) ;
102 int ztex_default_reset(libusb_device_handle *handle, int leave );
103 int ztex_default_lsi_set1 (libusb_device_handle *handle, uint8_t addr, uint32_t val);
104 int ztex_default_lsi_set2 (libusb_device_handle *handle, uint8_t addr, const uint32_t *val, int length);
105 int ztex_default_lsi_set3 (libusb_device_handle *handle, const uint8_t *addr, const uint32_t *val, int length);
106 int64_t ztex_default_lsi_get1 (libusb_device_handle *handle, uint8_t addr);
107 int ztex_default_lsi_get2 (libusb_device_handle *handle, uint8_t addr, uint32_t *val, int length);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif
uint8_t fast_config_ep
Endpoint for fast FPGA configuration; 0 means unsupported.
Definition: ztex.h:70
int ztex_print_device_info(char *sbuf, int sbuflen, const ztex_device_info *info)
Print device info to a string.
Definition: ztex.c:242
int ztex_get_device_info(libusb_device_handle *handle, ztex_device_info *info)
Get device information.
Definition: ztex.c:181
A structure with information about the device.
Definition: ztex.h:56
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:551
uint8_t board_series
e.g. 2 for USB-FPGA Modules 2.14b; 255 means unknown
Definition: ztex.h:64
uint8_t default_in_ep
input endpoint of default interface; 255 means not available
Definition: ztex.h:80
uint8_t board_number
e.g. 14 for USB-FPGA Modules 2.14b; 255 means unknown
Definition: ztex.h:66
uint8_t default_version1
default interface major version number; 0 means default interface not available
Definition: ztex.h:74
char * ztex_find_bitstream(const ztex_device_info *info, const char *path, const char *name)
Search for bitstream at standard locations.
Definition: ztex.c:294
int ztex_get_fpga_config(libusb_device_handle *handle)
Get device information.
Definition: ztex.c:268
int ztex_default_gpio_ctl(libusb_device_handle *handle, int mask, int value)
Reads and modifies the 4 GPIO pins.
Definition: ztex.c:501
uint8_t fx_version
2 for FX2, 3 for FX3
Definition: ztex.h:62
int ztex_default_reset(libusb_device_handle *handle, int leave)
Assert the reset signal.
Definition: ztex.c:515
uint8_t fast_config_if
Interface for fast FPGA configuration.
Definition: ztex.h:72
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:609
uint8_t default_out_ep
output endpoint of default interface; 255 means not available
Definition: ztex.h:78
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:581
uint8_t default_version2
default interface minor version number
Definition: ztex.h:76
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:627
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:532
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:326
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:112