ft232r.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 BFGMINER_FT232R_H
  10. #define BFGMINER_FT232R_H
  11. #include <stdbool.h>
  12. #include <stdint.h>
  13. #include <libusb.h>
  14. #include "lowlevel.h"
  15. enum ft232r_reset_purge {
  16. FTDI_PURGE_RX = 1,
  17. FTDI_PURGE_TX = 2,
  18. FTDI_PURGE_BOTH = 3,
  19. };
  20. struct ft232r_device_handle;
  21. extern struct ft232r_device_handle *ft232r_open(const struct lowlevel_device_info *);
  22. extern struct ft232r_device_handle *ft232h_open_mpsse(const struct lowlevel_device_info *);
  23. extern void ft232r_close(struct ft232r_device_handle *);
  24. extern bool ft232r_purge_buffers(struct ft232r_device_handle *, enum ft232r_reset_purge);
  25. extern bool ft232r_set_bitmode(struct ft232r_device_handle *, uint8_t mask, uint8_t mode);
  26. extern ssize_t ft232r_flush(struct ft232r_device_handle *);
  27. extern ssize_t ft232r_write(struct ft232r_device_handle *, const void *data, size_t count);
  28. extern ssize_t ft232r_write_all(struct ft232r_device_handle *, const void *data, size_t count);
  29. extern ssize_t ft232r_read(struct ft232r_device_handle *, void *buf, size_t count);
  30. extern ssize_t ft232r_read_all(struct ft232r_device_handle *, void *data, size_t count);
  31. extern bool ft232r_get_pins(struct ft232r_device_handle *, uint8_t *pins);
  32. extern bool ft232r_set_cbus_bits(struct ft232r_device_handle *dev, bool sc, bool cs);
  33. extern bool ft232r_get_cbus_bits(struct ft232r_device_handle *dev, bool *out_sio0, bool *out_sio1);
  34. extern bool ft232h_mpsse_set_axbus(struct ft232r_device_handle *, uint8_t value, uint8_t directions, bool adbus);
  35. #define ft232h_mpsse_set_acbus(ftdi, val, dir) ft232h_mpsse_set_axbus(ftdi, val, dir, false)
  36. #define ft232h_mpsse_set_adbus(ftdi, val, dir) ft232h_mpsse_set_axbus(ftdi, val, dir, true)
  37. #endif