mcp2210.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2014 Con Kolivas
  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 MCP2210_H
  10. #define MCP2210_H
  11. #define MCP2210_BUFFER_LENGTH 64
  12. #define MCP2210_TRANSFER_MAX 60
  13. #define MCP2210_PIN_GPIO 0x0
  14. #define MCP2210_PIN_CS 0x1
  15. #define MCP2210_PIN_DEDICATED 0x2
  16. #define MCP2210_GPIO_PIN_LOW 0
  17. #define MCP2210_GPIO_PIN_HIGH 1
  18. #define MCP2210_GPIO_OUTPUT 0
  19. #define MCP2210_GPIO_INPUT 1
  20. #define MCP2210_SPI_CANCEL 0x11
  21. #define MCP2210_GET_GPIO_SETTING 0x20
  22. #define MCP2210_SET_GPIO_SETTING 0x21
  23. #define MCP2210_SET_GPIO_PIN_VAL 0x30
  24. #define MCP2210_GET_GPIO_PIN_VAL 0x31
  25. #define MCP2210_SET_GPIO_PIN_DIR 0x32
  26. #define MCP2210_GET_GPIO_PIN_DIR 0x33
  27. #define MCP2210_SET_SPI_SETTING 0X40
  28. #define MCP2210_GET_SPI_SETTING 0X41
  29. #define MCP2210_SPI_TRANSFER 0x42
  30. #define MCP2210_SPI_TRANSFER_SUCCESS 0x00
  31. #define MCP2210_SPI_TRANSFER_ERROR_NA 0xF7 // SPI not available due to external owner
  32. #define MCP2210_SPI_TRANSFER_ERROR_IP 0xF8 // SPI not available due to transfer in progress
  33. struct gpio_pin {
  34. uint8_t pin[9];
  35. };
  36. struct mcp_settings {
  37. struct gpio_pin designation;
  38. struct gpio_pin value;
  39. struct gpio_pin direction;
  40. unsigned int bitrate, icsv, acsv, cstdd, ldbtcsd, sdbd, bpst, spimode;
  41. };
  42. bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds cmd);
  43. bool mcp2210_get_gpio_settings(struct cgpu_info *cgpu, struct mcp_settings *mcp);
  44. bool mcp2210_set_gpio_settings(struct cgpu_info *cgpu, struct mcp_settings *mcp);
  45. bool mcp2210_get_gpio_pindes(struct cgpu_info *cgpu, struct gpio_pin *gp);
  46. bool mcp2210_get_gpio_pinvals(struct cgpu_info *cgpu, struct gpio_pin *gp);
  47. bool mcp2210_get_gpio_pindirs(struct cgpu_info *cgpu, struct gpio_pin *gp);
  48. bool mcp2210_get_gpio_pin(struct cgpu_info *cgpu, int pin, int *des);
  49. bool mcp2210_get_gpio_pinval(struct cgpu_info *cgpu, int pin, int *val);
  50. bool mcp2210_get_gpio_pindir(struct cgpu_info *cgpu, int pin, int *dir);
  51. bool mcp2210_spi_cancel(struct cgpu_info *cgpu);
  52. bool
  53. mcp2210_get_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int *bitrate, unsigned int *icsv,
  54. unsigned int *acsv, unsigned int *cstdd, unsigned int *ldbtcsd,
  55. unsigned int *sdbd, unsigned int *bpst, unsigned int *spimode);
  56. bool
  57. mcp2210_set_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int bitrate, unsigned int icsv,
  58. unsigned int acsv, unsigned int cstdd, unsigned int ldbtcsd,
  59. unsigned int sdbd, unsigned int bpst, unsigned int spimode);
  60. bool mcp2210_spi_transfer(struct cgpu_info *cgpu, struct mcp_settings *mcp,
  61. char *data, unsigned int *length);
  62. #endif /* MCP2210_H */