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