fpgautils.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 <stdint.h>
  13. #include <stdio.h>
  14. typedef bool(*detectone_func_t)(const char*);
  15. typedef int(*autoscan_func_t)();
  16. extern int _serial_detect(const char*dname, detectone_func_t, autoscan_func_t, bool force_autoscan);
  17. #define serial_detect_fauto(dname, detectone, autoscan) \
  18. _serial_detect(dname, detectone, autoscan, true)
  19. #define serial_detect_auto(dname, detectone, autoscan) \
  20. _serial_detect(dname, detectone, autoscan, false)
  21. #define serial_detect(dname, detectone) \
  22. _serial_detect(dname, detectone, NULL, false)
  23. extern int serial_autodetect_devserial(detectone_func_t, const char*prodname);
  24. extern int serial_autodetect_udev (detectone_func_t, const char*prodname);
  25. extern int serial_open(const char*devpath, unsigned long baud, uint8_t timeout, bool purge);
  26. extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char*eol);
  27. #define serial_read(fd, buf, count) \
  28. _serial_read(fd, (char*)(buf), count, NULL)
  29. #define serial_read_line(fd, buf, bufsiz, eol) \
  30. _serial_read(fd, buf, count, &eol)
  31. #define serial_close(fd) close(fd)
  32. extern FILE*open_bitstream(const char*dname, const char*filename);
  33. #endif