OpenCores
URL https://opencores.org/ocsvn/usb_fpga_2_14/usb_fpga_2_14/trunk

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [capi/] [c/] [ztex.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*%
2
   ZTEX Core API for C with examples
3
   Copyright (C) 2009-2017 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
 
26
/** @file
27
The Core API for C.
28
An Introduction can be found in the <a href="index.html">Mainpage</a>
29
*/
30
 
31
 
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
 
42
/// @cond macros
43
/// Expands to the directory seperator of current OS
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
/// @endcond
54
 
55
/** A structure with information about the device. */
56
typedef struct {
57
        /// product string, null-terminated
58
        unsigned char  product_string[128];
59
        /// serial number string, null-terminated
60
        unsigned char  sn_string[64];
61
        /// 2 for FX2, 3 for FX3
62
        uint8_t  fx_version;
63
        /// e.g. 2 for USB-FPGA Modules 2.14b; 255 means unknown
64
        uint8_t  board_series;
65
        /// e.g. 14 for USB-FPGA Modules 2.14b; 255 means unknown
66
        uint8_t  board_number;
67
        /// e.g. 'b' for USB-FPGA Modules 2.14b; null-terminated
68
        unsigned char  board_variant[3];
69
        /// Endpoint for fast FPGA configuration; 0 means unsupported
70
        uint8_t  fast_config_ep;
71
        /// Interface for fast FPGA configuration
72
        uint8_t  fast_config_if;
73
        /// default interface major version number; 0 means default interface not available
74
        uint8_t  default_version1;
75
        /// default interface minor version number
76
        uint8_t  default_version2;
77
        /// output endpoint of default interface; 255 means not available
78
        uint8_t  default_out_ep;
79
        /// input endpoint of default interface; 255 means not available
80
        uint8_t  default_in_ep;
81
} ztex_device_info;
82
 
83
 
84
/** Scans the bus and performs certain operations on it.
85
  * @param devs A null terminated list of devices
86
  * @param op Operation to perform. <0: print bus and ignore filters, 0: find a device using the filters, >0 print all devices matching the filters
87
  * @param id_vendor,id_product Filter by USB ID's that specify the device, ignored if negative
88
  * @param busnum,devnum Filter by bus number and device address, ignored if negative
89
  * @param sn Filter by serial number, ignored if NULL
90
  * @param ps Filter by product string, ignored if NULL
91
  * @return The device index if filter result unique, otherwise -1
92
  */
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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.