]> sigrok.org Git - sigrok-firmware-fx2lafw.git/commitdiff
Add support for setting Sainsmart AC/DC coupling
authorBenjamin Larsson <redacted>
Sun, 3 Apr 2016 15:39:07 +0000 (17:39 +0200)
committerUwe Hermann <redacted>
Wed, 4 May 2016 16:16:05 +0000 (18:16 +0200)
sainsmart_dds120.c

index aa1190ae4a4ff951ff3b6a2bef52bbc4be30808f..b964d1588eee6b0da8b2b894ac39ad12d77fb843 100644 (file)
@@ -150,6 +150,26 @@ static BOOL set_voltage(BYTE channel, BYTE val)
        return TRUE;
 }
 
+
+/**
+ * Each LSB in the nibble of the byte controls the coupling per channel.
+ *
+ * Setting PE3 disables AC coupling capacitor on CH0.
+ * Setting PE0 disables AC coupling capacitor on CH1.
+ */
+static void set_coupling(BYTE coupling_cfg)
+{
+       if (coupling_cfg & 0x01)
+               IOE |= 0x08;
+       else
+               IOE &= ~0x08;
+
+       if (coupling_cfg & 0x10)
+               IOE |= 0x01;
+       else
+               IOE &= ~0x01;
+}
+
 static BOOL set_numchannels(BYTE numchannels)
 {
        if (numchannels == 1 || numchannels == 2) {
@@ -365,7 +385,7 @@ BOOL handle_vendorcommand(BYTE cmd)
        stop_sampling();
 
        /* Clear EP0BCH/L for each valid command. */
-       if (cmd >= 0xe0 && cmd <= 0xe4) {
+       if (cmd >= 0xe0 && cmd <= 0xe5) {
                EP0BCH = 0;
                EP0BCL = 0;
                while (EP0CS & bmEPBUSY);
@@ -386,6 +406,9 @@ BOOL handle_vendorcommand(BYTE cmd)
        case 0xe4:
                set_numchannels(EP0BUF[0]);
                return TRUE;
+       case 0xe5:
+               set_coupling(EP0BUF[0]);
+               return TRUE;
        }
 
        return FALSE; /* Not handled by handlers. */