Commit 6bfd6d80941aaf330a2b1d6b1c9b1f4d2261d7a3

Con Kolivas 2014-01-05T08:49:08

Provide a helper function for setting all pin designations on mcp2210

diff --git a/driver-bitfury.h b/driver-bitfury.h
index c5cb9ba..55eb32e 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -32,6 +32,9 @@ extern int opt_bxf_temp_target;
 #define NF1_SPIBUF_SIZE 16384
 
 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;
 };
 
diff --git a/mcp2210.c b/mcp2210.c
index 17e8e65..1e24675 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -128,6 +128,25 @@ bool mcp2210_get_gpio_pin(struct cgpu_info *cgpu, int pin, int *des)
 	return true;
 }
 
+/* Set the designation of all pins. This will reset direction and values. */
+bool mcp2210_set_gpio_pin_designations(struct cgpu_info *cgpu, struct gpio_pin *gp)
+{
+	char buf[MCP2210_BUFFER_LENGTH];
+	int i;
+
+	/* Copy the current values */
+	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 < 9; i++)
+		buf[4 + i] = gp->pin[i];
+	memset(buf + 18, 0, 45);
+	buf[0] = MCP2210_SET_GPIO_SETTING;
+	return (mcp2210_send_recv(cgpu, buf, C_MCP_SETGPIOSETTING));
+}
+
 /* Set the designation of one pin. This will reset direction and values. */
 bool mcp2210_set_gpio_pindes(struct cgpu_info *cgpu, int pin, int des)
 {
diff --git a/mcp2210.h b/mcp2210.h
index 2dc75a6..05afe65 100644
--- a/mcp2210.h
+++ b/mcp2210.h
@@ -47,6 +47,7 @@ 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);
 bool mcp2210_get_gpio_pin(struct cgpu_info *cgpu, int pin, int *des);
+bool mcp2210_set_gpio_pin_designations(struct cgpu_info *cgpu, struct gpio_pin *gp);
 bool mcp2210_set_gpio_pindes(struct cgpu_info *cgpu, int pin, int des);
 bool mcp2210_get_gpio_pinval(struct cgpu_info *cgpu, int pin, int *val);
 bool mcp2210_set_gpio_pinval(struct cgpu_info *cgpu, int pin, int val);