CMR handle baud options
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/driver-icarus.c b/driver-icarus.c
index f1d90e9..c6c3e2f 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -244,9 +244,10 @@ static void _transfer(struct cgpu_info *icarus, uint8_t request_type, uint8_t bR
#define transfer(icarus, request_type, bRequest, wValue, wIndex, cmd) \
_transfer(icarus, request_type, bRequest, wValue, wIndex, NULL, 0, cmd)
-// TODO: handle baud
-static void icarus_initialise(struct cgpu_info *icarus, __maybe_unused int baud)
+static void icarus_initialise(struct cgpu_info *icarus, int baud)
{
+ uint16_t wValue, wIndex;
+
if (icarus->usbinfo.nodev)
return;
@@ -276,15 +277,32 @@ static void icarus_initialise(struct cgpu_info *icarus, __maybe_unused int baud)
if (icarus->usbinfo.nodev)
return;
- // TODO: Get the baud settings for the 2 CMRs
- if (icarus->usbdev->ident != IDENT_CMR1 &&
- icarus->usbdev->ident != IDENT_CMR2) {
- // Set the baud
- transfer(icarus, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, FTDI_VALUE_BAUD_BLT,
- (FTDI_INDEX_BAUD_BLT & 0xff00) | icarus->usbdev->found->interface,
- C_SETBAUD);
+ // default to BLT/LLT 115200
+ wValue = FTDI_VALUE_BAUD_BLT;
+ wIndex = FTDI_INDEX_BAUD_BLT;
+
+ if (icarus->usbdev->ident == IDENT_CMR1 ||
+ icarus->usbdev->ident == IDENT_CMR2) {
+ switch (baud) {
+ case 115200:
+ wValue = FTDI_VALUE_BAUD_CMR_115;
+ wIndex = FTDI_INDEX_BAUD_CMR_115;
+ break;
+ case 57600:
+ wValue = FTDI_VALUE_BAUD_CMR_57;
+ wIndex = FTDI_INDEX_BAUD_CMR_57;
+ break;
+ default:
+ quit(1, "icarus_intialise() invalid baud (%d) for Cairnsmore1", baud);
+ break;
+ }
}
+ // Set the baud
+ transfer(icarus, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, wValue,
+ (wIndex & 0xff00) | icarus->usbdev->found->interface,
+ C_SETBAUD);
+
if (icarus->usbinfo.nodev)
return;
diff --git a/usbutils.c b/usbutils.c
index f2b25f8..7094ac3 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -256,7 +256,7 @@ static struct usb_find_devices find_dev[] = {
.interface = 0,
.timeout = ICARUS_TIMEOUT_MS,
.epcount = ARRAY_SIZE(cmr1_eps),
- .eps = cmr_eps },
+ .eps = cmr1_eps },
{
.drv = DRV_ICARUS,
.name = "CMR",
@@ -269,7 +269,7 @@ static struct usb_find_devices find_dev[] = {
.interface = 0,
.timeout = ICARUS_TIMEOUT_MS,
.epcount = ARRAY_SIZE(cmr2_eps),
- .eps = cmr_eps },
+ .eps = cmr2_eps },
#endif
#ifdef USE_ZTEX
// This is here so cgminer -n shows them
diff --git a/usbutils.h b/usbutils.h
index 4bc27c6..f5c332c 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -40,6 +40,13 @@
#define FTDI_VALUE_BAUD_BLT 0x001a
#define FTDI_INDEX_BAUD_BLT 0x0000
+// CMR = 115200 & 57600
+#define FTDI_VALUE_BAUD_CMR_115 0xc068
+#define FTDI_INDEX_BAUD_CMR_115 0x0200
+
+#define FTDI_VALUE_BAUD_CMR_57 0x80d0
+#define FTDI_INDEX_BAUD_CMR_57 0x0200
+
// Data control
#define FTDI_VALUE_DATA_BFL 0
#define FTDI_VALUE_DATA_BAS FTDI_VALUE_DATA_BFL