Provide a helper function for setting all pin designations on mcp2210
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
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);