A1-board-selector.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef A1_BOARD_SELECTOR_H
  2. #define A1_BOARD_SELECTOR_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #define RESET_LOW_TIME_MS 200
  6. #define RESET_HI_TIME_MS 100
  7. struct board_selector {
  8. /* destructor */
  9. void (*exit)(void);
  10. /* select board and chip chain for given chain index*/
  11. bool (*select)(uint8_t chain);
  12. /* release access to selected chain */
  13. void (*release)(void);
  14. /* reset currently selected chain */
  15. bool (*reset)(void);
  16. /* reset all chains on board */
  17. bool (*reset_all)(void);
  18. /* get temperature for selected chain at given sensor */
  19. uint8_t (*get_temp)(uint8_t sensor);
  20. /* prepare board (voltage) for given sys_clock */
  21. bool (*prepare_clock)(int clock_khz);
  22. };
  23. static bool dummy_select(uint8_t b) { (void)b; return true; }
  24. static void dummy_void(void) { };
  25. static bool dummy_bool(void) { return true; }
  26. //static uint8_t dummy_u8(void) { return 0; }
  27. static uint8_t dummy_get_temp(uint8_t s) { (void)s; return 0; }
  28. static bool dummy_prepare_clock(int c) { (void)c; return true; }
  29. static const struct board_selector dummy_board_selector = {
  30. .exit = dummy_void,
  31. .select = dummy_select,
  32. .release = dummy_void,
  33. .reset = dummy_bool,
  34. .reset_all = dummy_bool,
  35. .get_temp = dummy_get_temp,
  36. .prepare_clock = dummy_prepare_clock,
  37. };
  38. /* CoinCraft Desk and Rig board selector constructors */
  39. #define CCD_MAX_CHAINS 5
  40. #define CCR_MAX_CHAINS 16
  41. extern struct board_selector *ccd_board_selector_init(void);
  42. extern struct board_selector *ccr_board_selector_init(void);
  43. #endif /* A1_BOARD_SELECTOR_H */