forked from Ivasoft/DSView
the step 1 of code refactoring
This commit is contained in:
@@ -17,9 +17,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../libsigrok.h"
|
||||
#include "../../libsigrok-internal.h"
|
||||
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include "command.h"
|
||||
#include "dsl.h"
|
||||
#include <assert.h>
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#ifndef LIBDSL_HARDWARE_COMMAND_H
|
||||
#define LIBDSL_HARDWARE_COMMAND_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok.h"
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok-internal.h"
|
||||
|
||||
/* Protocol commands */
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../libsigrok.h"
|
||||
#include "../../libsigrok-internal.h"
|
||||
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include "dsl.h"
|
||||
#include "command.h"
|
||||
#include "../../log.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../libsigrok.h"
|
||||
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include "command.h"
|
||||
#include "dsl.h"
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#undef LOG_PREFIX
|
||||
#define LOG_PREFIX "DSL Hardware: "
|
||||
|
||||
extern struct ds_trigger *trigger;
|
||||
|
||||
static const int32_t probeOptions[] = {
|
||||
@@ -76,6 +79,18 @@ static struct sr_dev_mode mode_list[] = {
|
||||
{DSO, "Oscilloscope", "示波器", "osc", "osc.svg"},
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
};
|
||||
|
||||
|
||||
SR_PRIV void dsl_probe_init(struct sr_dev_inst *sdi)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#ifndef LIBDSL_HARDWARE_DSL_H
|
||||
#define LIBDSL_HARDWARE_DSL_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok.h"
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include "command.h"
|
||||
|
||||
@@ -36,15 +35,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#undef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#undef max
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
#undef LOG_PREFIX
|
||||
#define LOG_PREFIX "DSL Hardware: "
|
||||
|
||||
|
||||
|
||||
#define USB_INTERFACE 0
|
||||
#define USB_CONFIGURATION 1
|
||||
#define NUM_TRIGGER_STAGES 16
|
||||
@@ -1052,16 +1043,7 @@ static const struct DSL_profile supported_DSCope[] = {
|
||||
{ 0, 0, LIBUSB_SPEED_UNKNOWN, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
DSL_ERROR = -1,
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../libsigrok.h"
|
||||
|
||||
#include "../../libsigrok-internal.h"
|
||||
|
||||
#include "dsl.h"
|
||||
@@ -28,6 +28,14 @@
|
||||
#undef LOG_PREFIX
|
||||
#define LOG_PREFIX "dslogic: "
|
||||
|
||||
static const char *maxHeights[] = {
|
||||
"1X",
|
||||
"2X",
|
||||
"3X",
|
||||
"4X",
|
||||
"5X",
|
||||
};
|
||||
|
||||
enum {
|
||||
/** Buffer mode */
|
||||
OP_BUFFER = 0,
|
||||
@@ -87,14 +95,6 @@ static const char *filters[] = {
|
||||
"1 Sample Clock",
|
||||
};
|
||||
|
||||
static const char *maxHeights[] = {
|
||||
"1X",
|
||||
"2X",
|
||||
"3X",
|
||||
"4X",
|
||||
"5X",
|
||||
};
|
||||
|
||||
static const int32_t hwoptions[] = {
|
||||
SR_CONF_OPERATION_MODE,
|
||||
SR_CONF_BUFFER_OPTIONS,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/*
|
||||
* Helper functions for the Cypress EZ-USB / FX2 series chips.
|
||||
*/
|
||||
#include "../../libsigrok.h"
|
||||
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../libsigrok.h"
|
||||
#include "../../libsigrok-internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
@@ -21,6 +21,22 @@
|
||||
*/
|
||||
|
||||
#include "demo.h"
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
|
||||
#endif
|
||||
|
||||
#include "../../log.h"
|
||||
|
||||
/* Message logging helpers with subsystem-specific prefix string. */
|
||||
@@ -68,6 +84,97 @@ static const uint8_t probeCoupling[] = {
|
||||
SR_AC_COUPLING,
|
||||
};
|
||||
|
||||
static const char *maxHeights[] = {
|
||||
"1X",
|
||||
"2X",
|
||||
"3X",
|
||||
"4X",
|
||||
"5X",
|
||||
};
|
||||
|
||||
/* We name the probes 0-7 on our demo driver. */
|
||||
static const char *probe_names[] = {
|
||||
"0", "1", "2", "3",
|
||||
"4", "5", "6", "7",
|
||||
"8", "9", "10", "11",
|
||||
"12", "13", "14", "15",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *probeMapUnits[] = {
|
||||
"V",
|
||||
"A",
|
||||
"°C",
|
||||
"°F",
|
||||
"g",
|
||||
"m",
|
||||
"m/s",
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
};
|
||||
|
||||
static struct sr_dev_mode mode_list[] = {
|
||||
{LOGIC, "Logic Analyzer", "逻辑分析仪", "la", "la.svg"},
|
||||
{ANALOG, "Data Acquisition", "数据记录仪", "daq", "daq.svg"},
|
||||
{DSO, "Oscilloscope", "示波器", "osc", "osc.svg"},
|
||||
};
|
||||
|
||||
/* hardware Capabilities */
|
||||
#define CAPS_MODE_LOGIC (1 << 0)
|
||||
#define CAPS_MODE_ANALOG (1 << 1)
|
||||
#define CAPS_MODE_DSO (1 << 2)
|
||||
|
||||
#define CAPS_FEATURE_NONE 0
|
||||
// zero calibration ability
|
||||
#define CAPS_FEATURE_ZERO (1 << 4)
|
||||
/* end */
|
||||
|
||||
static const struct DEMO_profile supported_Demo[] = {
|
||||
/*
|
||||
* Demo
|
||||
*/
|
||||
{"DreamSourceLab", "Demo Device", NULL,
|
||||
{CAPS_MODE_LOGIC | CAPS_MODE_ANALOG | CAPS_MODE_DSO,
|
||||
CAPS_FEATURE_NONE,
|
||||
(1 << DEMO_LOGIC100x16) |
|
||||
(1 << DEMO_ANALOG10x2) |
|
||||
(1 << DEMO_DSO200x2),
|
||||
SR_Mn(100),
|
||||
SR_Kn(20),
|
||||
0,
|
||||
vdivs10to2000,
|
||||
0,
|
||||
DEMO_LOGIC100x16,
|
||||
PATTERN_SINE,
|
||||
SR_NS(500)}
|
||||
},
|
||||
|
||||
{ 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
};
|
||||
|
||||
static const struct DEMO_channels channel_modes[] = {
|
||||
// LA Stream
|
||||
{DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
|
||||
SR_KHZ(10), SR_MHZ(100), "Use 16 Channels (Max 20MHz)"},
|
||||
|
||||
// DAQ
|
||||
{DEMO_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, 2, 8, SR_MHZ(1), SR_Mn(1),
|
||||
SR_HZ(10), SR_MHZ(10), "Use Channels 0~1 (Max 10MHz)"},
|
||||
|
||||
// OSC
|
||||
{DEMO_DSO200x2, DSO, SR_CHANNEL_DSO, 2, 8, SR_MHZ(100), SR_Kn(10),
|
||||
SR_HZ(100), SR_MHZ(200), "Use Channels 0~1 (Max 200MHz)"}
|
||||
};
|
||||
|
||||
|
||||
/* Private, per-device-instance driver context. */
|
||||
/* TODO: struct context as with the other drivers. */
|
||||
|
||||
@@ -22,47 +22,8 @@
|
||||
#define LIBDSL_HARDWARE_DEMO_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "../../libsigrok.h"
|
||||
#include "../../libsigrok-internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
|
||||
#endif
|
||||
|
||||
#undef min
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#undef max
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
/* hardware Capabilities */
|
||||
#define CAPS_MODE_LOGIC (1 << 0)
|
||||
#define CAPS_MODE_ANALOG (1 << 1)
|
||||
#define CAPS_MODE_DSO (1 << 2)
|
||||
|
||||
#define CAPS_FEATURE_NONE 0
|
||||
// zero calibration ability
|
||||
#define CAPS_FEATURE_ZERO (1 << 4)
|
||||
/* end */
|
||||
|
||||
static struct sr_dev_mode mode_list[] = {
|
||||
{LOGIC, "Logic Analyzer", "逻辑分析仪", "la", "la.svg"},
|
||||
{ANALOG, "Data Acquisition", "数据记录仪", "daq", "daq.svg"},
|
||||
{DSO, "Oscilloscope", "示波器", "osc", "osc.svg"},
|
||||
};
|
||||
|
||||
|
||||
/* Supported patterns which we can generate */
|
||||
enum DEMO_PATTERN {
|
||||
PATTERN_SINE = 0,
|
||||
@@ -135,43 +96,6 @@ struct DEMO_channels {
|
||||
const char *descr;
|
||||
};
|
||||
|
||||
static const struct DEMO_channels channel_modes[] = {
|
||||
// LA Stream
|
||||
{DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
|
||||
SR_KHZ(10), SR_MHZ(100), "Use 16 Channels (Max 20MHz)"},
|
||||
|
||||
// DAQ
|
||||
{DEMO_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, 2, 8, SR_MHZ(1), SR_Mn(1),
|
||||
SR_HZ(10), SR_MHZ(10), "Use Channels 0~1 (Max 10MHz)"},
|
||||
|
||||
// OSC
|
||||
{DEMO_DSO200x2, DSO, SR_CHANNEL_DSO, 2, 8, SR_MHZ(100), SR_Kn(10),
|
||||
SR_HZ(100), SR_MHZ(200), "Use Channels 0~1 (Max 200MHz)"}
|
||||
};
|
||||
|
||||
static const struct DEMO_profile supported_Demo[] = {
|
||||
/*
|
||||
* Demo
|
||||
*/
|
||||
{"DreamSourceLab", "Demo Device", NULL,
|
||||
{CAPS_MODE_LOGIC | CAPS_MODE_ANALOG | CAPS_MODE_DSO,
|
||||
CAPS_FEATURE_NONE,
|
||||
(1 << DEMO_LOGIC100x16) |
|
||||
(1 << DEMO_ANALOG10x2) |
|
||||
(1 << DEMO_DSO200x2),
|
||||
SR_Mn(100),
|
||||
SR_Kn(20),
|
||||
0,
|
||||
vdivs10to2000,
|
||||
0,
|
||||
DEMO_LOGIC100x16,
|
||||
PATTERN_SINE,
|
||||
SR_NS(500)}
|
||||
},
|
||||
|
||||
{ 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
|
||||
};
|
||||
|
||||
struct demo_context {
|
||||
const struct DEMO_profile *profile;
|
||||
|
||||
@@ -246,43 +170,7 @@ static const uint64_t samplerates[] = {
|
||||
SR_GHZ(10),
|
||||
};
|
||||
|
||||
static const char *probeMapUnits[] = {
|
||||
"V",
|
||||
"A",
|
||||
"°C",
|
||||
"°F",
|
||||
"g",
|
||||
"m",
|
||||
"m/s",
|
||||
};
|
||||
|
||||
/* We name the probes 0-7 on our demo driver. */
|
||||
static const char *probe_names[] = {
|
||||
"0", "1", "2", "3",
|
||||
"4", "5", "6", "7",
|
||||
"8", "9", "10", "11",
|
||||
"12", "13", "14", "15",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
};
|
||||
|
||||
static const char *maxHeights[] = {
|
||||
"1X",
|
||||
"2X",
|
||||
"3X",
|
||||
"4X",
|
||||
"5X",
|
||||
};
|
||||
|
||||
static const int const_dc = 1.95 / 10 * 255;
|
||||
static const int sinx[] = {
|
||||
|
||||
Reference in New Issue
Block a user