avalon.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the Free
  4. * Software Foundation; either version 3 of the License, or (at your option)
  5. * any later version. See COPYING for more details.
  6. */
  7. #ifndef AVALON_H
  8. #define AVALON_H
  9. struct avalon_task {
  10. uint8_t reset :1;
  11. uint8_t flush_fifo :1;
  12. uint8_t fan_eft :1;
  13. uint8_t timer_eft :1;
  14. uint8_t chip_num :4;
  15. uint8_t fan_pwm_data;
  16. uint8_t timeout_data;
  17. uint8_t miner_num; // Word[0]
  18. uint8_t nonce_elf :1;
  19. uint32_t miner_ctrl :31;
  20. uint32_t pad0; //Word[2:1]
  21. uint32_t midstate[8];
  22. uint32_t data[3];
  23. // nonce_range: Word[??:14]
  24. } __attribute__((packed));
  25. struct avalon_result {
  26. uint32_t data[3];
  27. uint32_t midstate[8];
  28. uint32_t nonce;
  29. uint32_t reserved;
  30. } __attribute__((packed));
  31. #define AVALON_IO_SPEED 115200
  32. #define AVALON_READ_SIZE 48
  33. #define AVALON_READ_FAULT_DECISECONDS 1
  34. #define TIME_FACTOR 10
  35. #define AVA_GETS_ERROR -1
  36. #define AVA_GETS_OK 0
  37. #define AVA_GETS_RESTART 1
  38. #define AVA_GETS_TIMEOUT 2
  39. #define avalon_open2(devpath, baud, purge) serial_open(devpath, baud, AVALON_READ_FAULT_DECISECONDS, purge)
  40. #define avalon_open(devpath, baud) avalon_open2(devpath, baud, false)
  41. #define avalon_close(fd) close(fd)
  42. #endif /* AVALON_H */