From: Uwe Hermann Date: Thu, 10 Mar 2016 22:24:16 +0000 (+0100) Subject: hantek_6022be.c: Simplify handle_vendorcommand(). X-Git-Tag: sigrok-firmware-fx2lafw-0.1.4~37 X-Git-Url: http://sigrok.org/gitweb/?p=sigrok-firmware-fx2lafw.git;a=commitdiff_plain;h=38e32023c4b2dc92d51d969e1958bd1ee941804f hantek_6022be.c: Simplify handle_vendorcommand(). --- diff --git a/hantek_6022be.c b/hantek_6022be.c index d3d85e27..190ba89e 100644 --- a/hantek_6022be.c +++ b/hantek_6022be.c @@ -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; }