]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blobdiff - hantek_6022be.c
hw/hantek-6022be/dscr.a51: License header cosmetics.
[sigrok-firmware-fx2lafw.git] / hantek_6022be.c
index 1f58a608271f1fb1926377a9b7d45529faa850e4..190ba89e713d3fbc9d89204c88be6383f25c1355 100644 (file)
@@ -184,7 +184,7 @@ static void start_sampling(void)
 static void select_interface(BYTE alt)
 {
        const BYTE *pPacketSize = \
-               (USBCS & bmHSM ? &highspd_dscr : &fullspd_dscr)
+               ((USBCS & bmHSM) ? &highspd_dscr : &fullspd_dscr)
                + (9 + (16 * alt) + 9 + 4);
 
        altiface = alt;
@@ -216,18 +216,18 @@ static const struct samplerate_info {
        BYTE out0;
        BYTE ifcfg;
 } samplerates[] = {
-       { 48,0x80,   0, 3, 0, 0x00, 0xea },
-       { 30,0x80,   0, 3, 0, 0x00, 0xaa },
-       { 24,   1,   0, 2, 1, 0x40, 0xca },
-       { 16,   1,   1, 2, 0, 0x40, 0xca },
-       { 12,   2,   1, 2, 0, 0x40, 0xca },
-       {  8,   3,   2, 2, 0, 0x40, 0xca },
-       {  4,   6,   5, 2, 0, 0x40, 0xca },
-       {  2,  12,  11, 2, 0, 0x40, 0xca },
-       {  1,  24,  23, 2, 0, 0x40, 0xca },
-       { 50,  48,  47, 2, 0, 0x40, 0xca },
-       { 20, 120, 119, 2, 0, 0x40, 0xca },
-       { 10, 240, 239, 2, 0, 0x40, 0xca },
+       { 48, 0x80,   0, 3, 0, 0x00, 0xea },
+       { 30, 0x80,   0, 3, 0, 0x00, 0xaa },
+       { 24,    1,   0, 2, 1, 0x40, 0xca },
+       { 16,    1,   1, 2, 0, 0x40, 0xca },
+       { 12,    2,   1, 2, 0, 0x40, 0xca },
+       {  8,    3,   2, 2, 0, 0x40, 0xca },
+       {  4,    6,   5, 2, 0, 0x40, 0xca },
+       {  2,   12,  11, 2, 0, 0x40, 0xca },
+       {  1,   24,  23, 2, 0, 0x40, 0xca },
+       { 50,   48,  47, 2, 0, 0x40, 0xca },
+       { 20,  120, 119, 2, 0, 0x40, 0xca },
+       { 10,  240, 239, 2, 0, 0x40, 0xca },
 };
 
 static BOOL set_samplerate(BYTE rate)
@@ -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;
        }