lowlevel.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _BFG_LOWLEVEL_H
  2. #define _BFG_LOWLEVEL_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <uthash.h>
  6. struct lowlevel_device_info;
  7. typedef bool (*lowl_found_devinfo_func_t)(struct lowlevel_device_info *, void *);
  8. struct lowlevel_driver {
  9. const char *dname;
  10. struct lowlevel_device_info *(*devinfo_scan)();
  11. void (*devinfo_free)(struct lowlevel_device_info *);
  12. };
  13. struct lowlevel_device_info {
  14. char *manufacturer;
  15. char *product;
  16. char *serial;
  17. char *path;
  18. char *devid;
  19. uint16_t vid;
  20. uint16_t pid;
  21. struct lowlevel_driver *lowl;
  22. void *lowl_data;
  23. struct lowlevel_device_info *next;
  24. UT_hash_handle hh;
  25. };
  26. extern void lowlevel_scan();
  27. extern int _lowlevel_detect(lowl_found_devinfo_func_t, const char *serial, const char **product_needles, void *);
  28. #define lowlevel_detect(func, ...) _lowlevel_detect(func, NULL, (const char *[]){__VA_ARGS__, NULL}, NULL)
  29. #define lowlevel_detect_serial(func, serial) _lowlevel_detect(func, serial, (const char *[]){NULL}, NULL)
  30. extern int lowlevel_detect_id(lowl_found_devinfo_func_t, void *, const struct lowlevel_driver *, int32_t vid, int32_t pid);
  31. extern void lowlevel_scan_free();
  32. extern void lowlevel_devinfo_semicpy(struct lowlevel_device_info *dst, const struct lowlevel_device_info *src);
  33. extern void lowlevel_devinfo_free(struct lowlevel_device_info *);
  34. #ifdef USE_X6500
  35. extern struct lowlevel_driver lowl_ft232r;
  36. #endif
  37. #ifdef USE_NANOFURY
  38. extern struct lowlevel_driver lowl_mcp2210;
  39. #endif
  40. #ifdef HAVE_LIBUSB
  41. extern struct lowlevel_driver lowl_usb;
  42. #else
  43. // Dummy definition for the various "don't warn if just a lower-level interface" checks
  44. static struct lowlevel_driver lowl_usb;
  45. #endif
  46. #ifdef HAVE_FPGAUTILS
  47. extern struct lowlevel_driver lowl_vcom;
  48. #endif
  49. #endif