Provide a helper function for gettings mcp2210 spi 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
diff --git a/mcp2210.c b/mcp2210.c
index e821b84..2f653f4 100644
--- a/mcp2210.c
+++ b/mcp2210.c
@@ -233,6 +233,29 @@ bool mcp2210_spi_cancel(struct cgpu_info *cgpu)
* SubsequentDataByteDelay, BytesPerSPITransfer
*/
bool
+mcp2210_get_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int *bitrate, unsigned int *icsv,
+ unsigned int *acsv, unsigned int *cstdd, unsigned int *ldbtcsd,
+ unsigned int *sdbd, unsigned int *bpst, unsigned int *spimode)
+{
+ char buf[MCP2210_BUFFER_LENGTH];
+
+ memset(buf, 0, MCP2210_BUFFER_LENGTH);
+ buf[0] = MCP2210_GET_SPI_SETTING;
+
+ if (!mcp2210_send_recv(cgpu, buf, C_MCP_GETSPISETTING))
+ return false;
+ *bitrate = buf[7] << 24 | buf[6] << 16 | buf[5] << 8 | buf[4];
+ *icsv = (buf[9] & 0x1) << 8 | buf[8];
+ *acsv = (buf[11] & 0x1) << 8 | buf[10];
+ *cstdd = buf[13] << 8 | buf[12];
+ *ldbtcsd = buf[15] << 8 | buf[14];
+ *sdbd = buf[17] << 8 | buf[16];
+ *bpst = buf[19] << 8 | buf[18];
+ *spimode = buf[20];
+ return true;
+}
+
+bool
mcp2210_set_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int bitrate, unsigned int icsv,
unsigned int acsv, unsigned int cstdd, unsigned int ldbtcsd,
unsigned int sdbd, unsigned int bpst, unsigned int spimode)
diff --git a/mcp2210.h b/mcp2210.h
index 69105f9..d8510b4 100644
--- a/mcp2210.h
+++ b/mcp2210.h
@@ -53,6 +53,10 @@ bool mcp2210_get_gpio_pindir(struct cgpu_info *cgpu, int pin, int *dir);
bool mcp2210_set_gpio_pindir(struct cgpu_info *cgpu, int pin, int dir);
bool mcp2210_spi_cancel(struct cgpu_info *cgpu);
bool
+mcp2210_get_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int *bitrate, unsigned int *icsv,
+ unsigned int *acsv, unsigned int *cstdd, unsigned int *ldbtcsd,
+ unsigned int *sdbd, unsigned int *bpst, unsigned int *spimode);
+bool
mcp2210_set_spi_transfer_settings(struct cgpu_info *cgpu, unsigned int bitrate, unsigned int icsv,
unsigned int acsv, unsigned int cstdd, unsigned int ldbtcsd,
unsigned int sdbd, unsigned int bpst, unsigned int spimode);