drivers: Use NUM_CHANNELS in favor of hardcoded values.
This commit is contained in:
parent
bd633efa32
commit
b3fd09937c
|
@ -233,7 +233,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
||||||
/* Logic channels, all in one channel group. */
|
/* Logic channels, all in one channel group. */
|
||||||
cg = g_malloc0(sizeof(struct sr_channel_group));
|
cg = g_malloc0(sizeof(struct sr_channel_group));
|
||||||
cg->name = g_strdup("Logic");
|
cg->name = g_strdup("Logic");
|
||||||
for (j = 0; j < 16; j++) {
|
for (j = 0; j < NUM_CHANNELS; j++) {
|
||||||
sprintf(channel_name, "%d", j);
|
sprintf(channel_name, "%d", j);
|
||||||
ch = sr_channel_new(sdi, j, SR_CHANNEL_LOGIC,
|
ch = sr_channel_new(sdi, j, SR_CHANNEL_LOGIC,
|
||||||
TRUE, channel_name);
|
TRUE, channel_name);
|
||||||
|
|
|
@ -530,7 +530,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ch = 0; ch < 2; ch++) {
|
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
|
||||||
if (!devc->ch_enabled[ch])
|
if (!devc->ch_enabled[ch])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
|
||||||
/* TODO: Check malloc return value. */
|
/* TODO: Check malloc return value. */
|
||||||
analog.data = g_try_malloc(num_samples * sizeof(float));
|
analog.data = g_try_malloc(num_samples * sizeof(float));
|
||||||
|
|
||||||
for (int ch = 0; ch < 2; ch++) {
|
for (int ch = 0; ch < NUM_CHANNELS; ch++) {
|
||||||
if (!devc->ch_enabled[ch])
|
if (!devc->ch_enabled[ch])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
#define NUM_CHANNELS 2
|
|
||||||
|
|
||||||
static int send_begin(const struct sr_dev_inst *sdi)
|
static int send_begin(const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
struct sr_usb_dev_inst *usb;
|
struct sr_usb_dev_inst *usb;
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
/* All models have this for their "fast" mode. */
|
/* All models have this for their "fast" mode. */
|
||||||
#define FRAMESIZE_SMALL (10 * 1024)
|
#define FRAMESIZE_SMALL (10 * 1024)
|
||||||
|
|
||||||
|
#define NUM_CHANNELS 2
|
||||||
|
|
||||||
enum control_requests {
|
enum control_requests {
|
||||||
CTRL_READ_EEPROM = 0xa2,
|
CTRL_READ_EEPROM = 0xa2,
|
||||||
CTRL_GETSPEED = 0xb2,
|
CTRL_GETSPEED = 0xb2,
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#define UNKNOWN_ADDRESS 0xff
|
#define UNKNOWN_ADDRESS 0xff
|
||||||
#define MAX_RENUM_DELAY_MS 3000
|
#define MAX_RENUM_DELAY_MS 3000
|
||||||
|
|
||||||
|
#define NUM_CHANNELS 16
|
||||||
|
|
||||||
static const uint32_t drvopts[] = {
|
static const uint32_t drvopts[] = {
|
||||||
SR_CONF_LOGIC_ANALYZER,
|
SR_CONF_LOGIC_ANALYZER,
|
||||||
};
|
};
|
||||||
|
@ -89,7 +91,7 @@ static struct sr_dev_inst *create_device(struct sr_usb_dev_inst *usb,
|
||||||
sdi->inst_type = SR_INST_USB;
|
sdi->inst_type = SR_INST_USB;
|
||||||
sdi->conn = usb;
|
sdi->conn = usb;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||||
snprintf(channel_name, sizeof(channel_name), "D%i", i);
|
snprintf(channel_name, sizeof(channel_name), "D%i", i);
|
||||||
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
|
sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue