Add a helper function for getting all mcp2210 gpio settings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/driver-bitfury.h b/driver-bitfury.h
index c5cb9ba..2621e50 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -31,10 +31,6 @@ extern int opt_bxf_temp_target;
#define NF1_SPIBUF_SIZE 16384
-struct mcp_settings {
- unsigned int bitrate, icsv, acsv, cstdd, ldbtcsd, sdbd, bpst, spimode;
-};
-
struct bitfury_info {
struct cgpu_info *base_cgpu;
struct thr_info *thr;
diff --git a/mcp2210.c b/mcp2210.c
index 9a085de..41842c8 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -63,6 +63,28 @@ bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds cmd)
return true;
}
+bool mcp2210_get_gpio_settings(struct cgpu_info *cgpu, struct mcp_settings *mcp)
+{
+ char buf[MCP2210_BUFFER_LENGTH];
+ int i;
+
+ memset(buf, 0, MCP2210_BUFFER_LENGTH);
+ buf[0] = MCP2210_GET_GPIO_SETTING;
+ if (!mcp2210_send_recv(cgpu, buf, C_MCP_GETGPIOSETTING))
+ return false;
+
+ for (i = 0; i < 8; i++) {
+ mcp->designation.pin[i] = !!(buf[4 + i]);
+ mcp->value.pin[i] = !!(buf[13] & (0x01u << i));
+ mcp->direction.pin[i] = !!(buf[15] & (0x01u << i));
+ }
+ mcp->designation.pin[8] = !!(buf[12]);
+ mcp->value.pin[8] = buf[14] & 0x01u;
+ mcp->direction.pin[8] = buf[16] & 0x01u;
+
+ return true;
+}
+
/* Get all the pin designations and store them in a gpio_pin struct */
bool mcp2210_get_gpio_pindes(struct cgpu_info *cgpu, struct gpio_pin *gp)
{
diff --git a/mcp2210.h b/mcp2210.h
index 04c80c9..cbbe298 100644
--- a/mcp2210.h
+++ b/mcp2210.h
@@ -42,7 +42,15 @@ struct gpio_pin {
int pin[9];
};
+struct mcp_settings {
+ struct gpio_pin designation;
+ struct gpio_pin value;
+ struct gpio_pin direction;
+ unsigned int bitrate, icsv, acsv, cstdd, ldbtcsd, sdbd, bpst, spimode;
+};
+
bool mcp2210_send_recv(struct cgpu_info *cgpu, char *buf, enum usb_cmds cmd);
+bool mcp2210_get_gpio_settings(struct cgpu_info *cgpu, struct mcp_settings *mcp);
bool mcp2210_get_gpio_pindes(struct cgpu_info *cgpu, struct gpio_pin *gp);
bool mcp2210_get_gpio_pinvals(struct cgpu_info *cgpu, struct gpio_pin *gp);
bool mcp2210_get_gpio_pindirs(struct cgpu_info *cgpu, struct gpio_pin *gp);