ZTEX core API for C
Host software API for ZTEX FPGA Boards for C
|
The Core API for C. More...
#include <sys/types.h>
#include <libusb-1.0/libusb.h>
Go to the source code of this file.
Data Structures | |
struct | ztex_device_info |
A structure with information about the device. More... | |
Functions | |
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. More... | |
int | ztex_get_device_info (libusb_device_handle *handle, ztex_device_info *info) |
Get device information. More... | |
int | ztex_print_device_info (char *sbuf, int sbuflen, const ztex_device_info *info) |
Print device info to a string. More... | |
int | ztex_get_fpga_config (libusb_device_handle *handle) |
Get device information. More... | |
char * | ztex_find_bitstream (const ztex_device_info *info, const char *path, const char *name) |
Search for bitstream at standard locations. More... | |
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. More... | |
int | ztex_default_gpio_ctl (libusb_device_handle *handle, int mask, int value) |
Reads and modifies the 4 GPIO pins. More... | |
int | ztex_default_reset (libusb_device_handle *handle, int leave) |
Assert the reset signal. More... | |
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. More... | |
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. More... | |
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. More... | |
int64_t | ztex_default_lsi_get1 (libusb_device_handle *handle, uint8_t addr) |
Read data from the low speed interface of default firmwares. More... | |
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. More... | |
The Core API for C.
An Introduction can be found in the Mainpage
int ztex_default_gpio_ctl | ( | libusb_device_handle * | handle, |
int | mask, | ||
int | value | ||
) |
Reads and modifies the 4 GPIO pins.
handle | device handle |
mask | Bitmask for the pins which are modified. 1 means a bit is set. Only the lowest 4 bits are significant. |
value | The bit values which are to be set. Only the lowest 4 bits are significant. |
int64_t ztex_default_lsi_get1 | ( | libusb_device_handle * | handle, |
uint8_t | addr | ||
) |
Read data from the low speed interface of default firmwares.
It's implemented as a SRAM-like interface and is typically used used to read/write configuration data, debug information or other things. This function reads one register.
handle | device handle |
addr | The address. Valid values are 0 to 255. |
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.
It's implemented as a SRAM-like interface and is typically used used to read/write configuration data, debug information or other things. This function reads a sequential set of registers.
handle | device handle |
addr | The start address. Valid values are 0 to 255. Address is wrapped from 255 to 0. |
val | The array where to store the register data with a word width of 32 Bit. |
length | The amount of register to be read. |
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.
It's implemented as a SRAM-like interface and is typically used used to read/write configuration data, debug information or other things. This function sets one register.
handle | device handle |
addr | The address. Valid values are 0 to 255. |
val | The register data with a width of 32 bit. |
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.
It's implemented as a SRAM-like interface and is typically used used to read/write configuration data, debug information or other things. This function sets a sequential set of registers.
handle | device handle |
addr | The starting address address. Valid values are 0 to 255. Address is wrapped from 255 to 0. |
val | The register data array with a word width of 32 bit. |
length | The length of the data array. |
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.
It's implemented as a SRAM-like interface and is typically used used to read/write configuration data, debug information or other things. This function sets a sequential set of registers.
handle | device handle |
addr | The register addresses. Valid values are 0 to 255. |
val | The register data array with a word width of 32 bit. |
length | The length of the data array. |
int ztex_default_reset | ( | libusb_device_handle * | handle, |
int | leave | ||
) |
Assert the reset signal.
handle | device handle |
leave | if >0, the signal is left active. Otherwise only a short impulse is sent. |
char* ztex_find_bitstream | ( | const ztex_device_info * | info, |
const char * | path, | ||
const char * | name | ||
) |
Search for bitstream at standard locations.
info | device information, used for determining locations of the SDK examples, ignored if NULL |
path | additional path to search, ignored if NULL |
name | without suffix '.bit' |
int ztex_get_device_info | ( | libusb_device_handle * | handle, |
ztex_device_info * | info | ||
) |
Get device information.
handle | device handle |
info | structure where device information are stored. |
int ztex_get_fpga_config | ( | libusb_device_handle * | handle | ) |
Get device information.
handle | device handle |
int ztex_print_device_info | ( | char * | sbuf, |
int | sbuflen, | ||
const ztex_device_info * | info | ||
) |
Print device info to a string.
The output may be truncated and is always null-terminated.
sbuf | string buffer for output |
sbuflen | length of the string buffer |
info | structure where device information are stored. |
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.
devs | A null terminated list of devices |
op | Operation to perform. <0: print bus and ignore filters, 0: find a device using the filters, >0 print all devices matching the filters |
id_vendor,id_product | Filter by USB ID's that specify the device, ignored if negative |
busnum,devnum | Filter by bus number and device address, ignored if negative |
sn | Filter by serial number, ignored if NULL |
ps | Filter by product string, ignored if NULL |
devs | A null terminated list of devices |
op | Operation to perform. <0: print bus and ignore filters, 0: find a device using the filters, >0 print all devices matching the filters |
id_vendor,id_product | Filter by USB ID's that specify the device, ignored if negative |
busnum,devnum | Filter by bus number and device address, ignored if negative |
sn | Filter by serial number, ignored if NULL |
ps | Filter by product string, ignored if NULL |
sbuf | string buffer for output |
sbuflen | length of the string buffer |
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.
sbuf | string buffer for error messages |
sbuflen | length of the string buffer |
handle | device handle |
info | device information, used for determining high speed configuration settings, ignored if NULL |
fd | File to read from. I/O errors are ignored. |
bs | 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order. |