fpgautils.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright 2012 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #ifndef FPGAUTILS_H
  10. #define FPGAUTILS_H
  11. #include <stdbool.h>
  12. #include <stdio.h>
  13. typedef bool(*detectone_func_t)(const char*);
  14. typedef int(*autoscan_func_t)();
  15. extern int _serial_detect(struct device_api *api, detectone_func_t, autoscan_func_t, bool force_autoscan);
  16. #define serial_detect_fauto(api, detectone, autoscan) \
  17. _serial_detect(api, detectone, autoscan, true)
  18. #define serial_detect_auto(api, detectone, autoscan) \
  19. _serial_detect(api, detectone, autoscan, false)
  20. #define serial_detect(api, detectone) \
  21. _serial_detect(api, detectone, NULL, false)
  22. extern int serial_autodetect_devserial(detectone_func_t, const char *prodname);
  23. extern int serial_autodetect_udev(detectone_func_t, const char *prodname);
  24. extern int serial_open(const char *devpath, unsigned long baud, signed short timeout, bool purge);
  25. extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
  26. #define serial_read(fd, buf, count) \
  27. _serial_read(fd, (char*)(buf), count, NULL)
  28. #define serial_read_line(fd, buf, bufsiz, eol) \
  29. _serial_read(fd, buf, bufsiz, &eol)
  30. #define serial_close(fd) close(fd)
  31. extern FILE *open_bitstream(const char *dname, const char *filename);
  32. #endif