ft232r.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 void ft232r_close(struct ft232r_device_handle *);
  23. extern bool ft232r_purge_buffers(struct ft232r_device_handle *, enum ft232r_reset_purge);
  24. extern bool ft232r_set_bitmode(struct ft232r_device_handle *, uint8_t mask, uint8_t mode);
  25. extern ssize_t ft232r_flush(struct ft232r_device_handle *);
  26. extern ssize_t ft232r_write(struct ft232r_device_handle *, const void *data, size_t count);
  27. extern ssize_t ft232r_write_all(struct ft232r_device_handle *, const void *data, size_t count);
  28. extern ssize_t ft232r_read(struct ft232r_device_handle *, void *buf, size_t count);
  29. extern ssize_t ft232r_read_all(struct ft232r_device_handle *, void *data, size_t count);
  30. extern bool ft232r_get_pins(struct ft232r_device_handle *, uint8_t *pins);
  31. extern bool ft232r_set_cbus_bits(struct ft232r_device_handle *dev, bool sc, bool cs);
  32. extern bool ft232r_get_cbus_bits(struct ft232r_device_handle *dev, bool *out_sio0, bool *out_sio1);
  33. #endif