libztex.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __LIBZTEX_H__
  2. #define __LIBZTEX_H__
  3. #include <libusb.h>
  4. #define LIBZTEX_MAX_DESCRIPTORS 512
  5. #define LIBZTEX_SNSTRING_LEN 10
  6. #define LIBZTEX_IDVENDOR 0x221A
  7. #define LIBZTEX_IDPRODUCT 0x0100
  8. struct libztex_fpgastate {
  9. bool fpgaConfigured;
  10. unsigned char fpgaChecksum;
  11. uint16_t fpgaBytes;
  12. unsigned char fpgaInitB;
  13. unsigned char fpgaFlashResult;
  14. bool fpgaFlashBitSwap;
  15. };
  16. struct libztex_device {
  17. bool valid;
  18. struct libusb_device_descriptor descriptor;
  19. libusb_device_handle *hndl;
  20. unsigned char usbbus;
  21. unsigned char usbaddress;
  22. unsigned char snString[LIBZTEX_SNSTRING_LEN+1];
  23. unsigned char productId[4];
  24. unsigned char fwVersion;
  25. unsigned char interfaceVersion;
  26. unsigned char interfaceCapabilities[6];
  27. unsigned char moduleReserved[12];
  28. uint8_t numNonces;
  29. uint16_t offsNonces;
  30. uint16_t freqM1;
  31. uint8_t freqM;
  32. uint8_t freqMaxM;
  33. uint8_t freqMDefault;
  34. char repr[64];
  35. };
  36. struct libztex_dev_list {
  37. struct libztex_device *dev;
  38. struct libztex_dev_list *next;
  39. };
  40. struct libztex_hash_data {
  41. uint32_t goldenNonce;
  42. uint32_t nonce;
  43. uint32_t hash7;
  44. };
  45. extern int libztex_scanDevices (struct libztex_dev_list ***devs);
  46. extern void libztex_freeDevList (struct libztex_dev_list **devs);
  47. extern void libztex_destroy_device (struct libztex_device* ztex);
  48. extern int libztex_configureFpga (struct libztex_device *dev);
  49. extern int libztex_setFreq (struct libztex_device *ztex, uint16_t freq);
  50. extern int libztex_sendHashData (struct libztex_device *ztex, unsigned char *sendbuf);
  51. extern int libztex_readHashData (struct libztex_device *ztex, struct libztex_hash_data nonces[]);
  52. #endif /* __LIBZTEX_H__ */