]> sigrok.org Git - sigrok-firmware-fx2lafw.git/commitdiff
hantek_6022be.c: Simplify handle_vendorcommand().
authorUwe Hermann <redacted>
Thu, 10 Mar 2016 22:24:16 +0000 (23:24 +0100)
committerUwe Hermann <redacted>
Thu, 10 Mar 2016 22:33:03 +0000 (23:33 +0100)
hantek_6022be.c

index d3d85e27b829a8ccd3db5eec245e49314c0ec982..190ba89e713d3fbc9d89204c88be6383f25c1355 100644 (file)
@@ -349,31 +349,26 @@ BOOL handle_vendorcommand(BYTE cmd)
        PC1 = 1;
        ledcounter = 1000;
 
-       switch (cmd) {
-       case 0xe0:
-       case 0xe1:
+       /* Clear EP0BCH/L for each valid command. */
+       if (cmd >= 0xe0 && cmd <= 0xe4) {
                EP0BCH = 0;
                EP0BCL = 0;
                while (EP0CS & bmEPBUSY);
+       }
+
+       switch (cmd) {
+       case 0xe0:
+       case 0xe1:
                set_voltage(cmd - 0xe0, EP0BUF[0]);
                return TRUE;
        case 0xe2:
-               EP0BCH = 0;
-               EP0BCL = 0;
-               while (EP0CS & bmEPBUSY);
                set_samplerate(EP0BUF[0]);
                return TRUE;
        case 0xe3:
-               EP0BCH = 0;
-               EP0BCL = 0;
-               while (EP0CS & bmEPBUSY);
                if (EP0BUF[0] == 1)
                        start_sampling();
                return TRUE;
        case 0xe4:
-               EP0BCH = 0;
-               EP0BCL = 0;
-               while (EP0CS & bmEPBUSY);
                set_numchannels(EP0BUF[0]);
                return TRUE;
        }