libbitfury.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __LIBBITFURY_H__
  2. #define __LIBBITFURY_H__
  3. #include "miner.h"
  4. #include "spidevc.h"
  5. #define BITFURY_STAT_N 1024
  6. struct bitfury_payload {
  7. unsigned char midstate[32];
  8. unsigned int junk[8];
  9. unsigned m7;
  10. unsigned ntime;
  11. unsigned nbits;
  12. unsigned nnonce;
  13. };
  14. struct bitfury_device {
  15. struct spi_port *spi;
  16. unsigned char osc6_bits;
  17. unsigned newbuf[17];
  18. unsigned oldbuf[17];
  19. struct work * work;
  20. struct work * owork;
  21. struct work * o2work;
  22. int job_switched;
  23. uint32_t atrvec[20];
  24. struct bitfury_payload payload;
  25. struct bitfury_payload opayload;
  26. struct bitfury_payload o2payload;
  27. unsigned int results[16];
  28. int results_n;
  29. time_t stat_ts[BITFURY_STAT_N];
  30. unsigned int stat_counter;
  31. unsigned int future_nonce;
  32. unsigned int old_nonce;
  33. struct timespec timer1;
  34. struct timespec timer2;
  35. struct timespec otimer1;
  36. struct timespec otimer2;
  37. struct timespec predict1;
  38. struct timespec predict2;
  39. unsigned int counter1, counter2;
  40. unsigned int ocounter1, ocounter2;
  41. int rate; //per msec
  42. int osc_slow;
  43. int osc_fast;
  44. int req1_done, req2_done;
  45. double mhz;
  46. double ns;
  47. unsigned slot;
  48. unsigned fasync;
  49. };
  50. int libbitfury_readHashData(unsigned int *res);
  51. extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second_run);
  52. void work_to_payload(struct bitfury_payload *p, struct work *w);
  53. extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
  54. struct timespec t_diff(struct timespec start, struct timespec end);
  55. extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);
  56. extern void send_shutdown(struct spi_port *, int slot, int chip_n);
  57. extern void send_freq(struct spi_port *, int slot, int chip_n, int bits);
  58. extern int libbitfury_detectChips1(struct spi_port *);
  59. #endif /* __LIBBITFURY_H__ */