static GSList *device_instances = NULL;
static uint64_t supported_samplerates[] = {
- KHZ(200),
- KHZ(250),
- KHZ(500),
- MHZ(1),
- MHZ(5),
- MHZ(10),
- MHZ(25),
- MHZ(50),
- MHZ(100),
- MHZ(200),
+ SR_KHZ(200),
+ SR_KHZ(250),
+ SR_KHZ(500),
+ SR_MHZ(1),
+ SR_MHZ(5),
+ SR_MHZ(10),
+ SR_MHZ(25),
+ SR_MHZ(50),
+ SR_MHZ(100),
+ SR_MHZ(200),
0,
};
static struct sr_samplerates samplerates = {
- KHZ(200),
- MHZ(200),
+ SR_KHZ(200),
+ SR_MHZ(200),
0,
supported_samplerates,
};
if (supported_samplerates[i] == 0)
return SR_ERR_SAMPLERATE;
- if (samplerate <= MHZ(50)) {
+ if (samplerate <= SR_MHZ(50)) {
ret = upload_firmware(0, sigma);
sigma->num_probes = 16;
}
- if (samplerate == MHZ(100)) {
+ if (samplerate == SR_MHZ(100)) {
ret = upload_firmware(1, sigma);
sigma->num_probes = 8;
}
- else if (samplerate == MHZ(200)) {
+ else if (samplerate == SR_MHZ(200)) {
ret = upload_firmware(2, sigma);
sigma->num_probes = 4;
}
if (!probe->enabled || !probe->trigger)
continue;
- if (sigma->cur_samplerate >= MHZ(100)) {
+ if (sigma->cur_samplerate >= SR_MHZ(100)) {
/* Fast trigger support. */
if (trigger_set) {
g_warning("Asix Sigma only supports a single "
/* Check if trigger is in this chunk. */
if (triggerpos != -1) {
- if (sigma->cur_samplerate <= MHZ(50))
+ if (sigma->cur_samplerate <= SR_MHZ(50))
triggerpos -= EVENTS_PER_CLUSTER - 1;
if (triggerpos < 0)
/* If the samplerate has not been set, default to 200 KHz. */
if (sigma->cur_firmware == -1)
- set_samplerate(sdi, KHZ(200));
+ set_samplerate(sdi, SR_KHZ(200));
/* Enter trigger programming mode. */
sigma_set_register(WRITE_TRIGGER_SELECT1, 0x20, sigma);
/* 100 and 200 MHz mode. */
- if (sigma->cur_samplerate >= MHZ(100)) {
+ if (sigma->cur_samplerate >= SR_MHZ(100)) {
sigma_set_register(WRITE_TRIGGER_SELECT1, 0x81, sigma);
/* Find which pin to trigger on from mask. */
triggerselect |= 1 << 3;
/* All other modes. */
- } else if (sigma->cur_samplerate <= MHZ(50)) {
+ } else if (sigma->cur_samplerate <= SR_MHZ(50)) {
build_basic_trigger(&lut, sigma);
sigma_write_trigger_lut(&lut, sigma);
sigma_set_register(WRITE_TRIGGER_SELECT1, triggerselect, sigma);
/* Set clock select register. */
- if (sigma->cur_samplerate == MHZ(200))
+ if (sigma->cur_samplerate == SR_MHZ(200))
/* Enable 4 probes. */
sigma_set_register(WRITE_CLOCK_SELECT, 0xf0, sigma);
- else if (sigma->cur_samplerate == MHZ(100))
+ else if (sigma->cur_samplerate == SR_MHZ(100))
/* Enable 8 probes. */
sigma_set_register(WRITE_CLOCK_SELECT, 0x00, sigma);
else {
* 50 MHz mode (or fraction thereof). Any fraction down to
* 50 MHz / 256 can be used, but is not supported by sigrok API.
*/
- frac = MHZ(50) / sigma->cur_samplerate - 1;
+ frac = SR_MHZ(50) / sigma->cur_samplerate - 1;
clockselect.async = 0;
clockselect.fraction = frac;
static struct sr_samplerates samplerates = {
1,
- GHZ(1),
+ SR_GHZ(1),
1,
NULL,
};
/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
static GSList *device_instances = NULL;
-static uint64_t cur_samplerate = KHZ(200);
+static uint64_t cur_samplerate = SR_KHZ(200);
static uint64_t limit_samples = 0;
static uint64_t limit_msec = 0;
static int default_genmode = GENMODE_DEFAULT;
};
static uint64_t supported_samplerates[] = {
- 100, 200, 500, KHZ(1), KHZ(2), KHZ(5), KHZ(10), KHZ(20),
- KHZ(50), KHZ(100), KHZ(200), KHZ(500), MHZ(1), MHZ(2), MHZ(5),
- MHZ(10), MHZ(20), MHZ(50), MHZ(100), MHZ(200), 0
+ 100,
+ 200,
+ 500,
+ SR_KHZ(1),
+ SR_KHZ(2),
+ SR_KHZ(5),
+ SR_KHZ(10),
+ SR_KHZ(20),
+ SR_KHZ(50),
+ SR_KHZ(100),
+ SR_KHZ(200),
+ SR_KHZ(500),
+ SR_MHZ(1),
+ SR_MHZ(2),
+ SR_MHZ(5),
+ SR_MHZ(10),
+ SR_MHZ(20),
+ SR_MHZ(50),
+ SR_MHZ(100),
+ SR_MHZ(200),
+ 0,
};
static struct sr_samplerates samplerates = {
- 100, MHZ(200), 0, supported_samplerates,
+ 100,
+ SR_MHZ(200),
+ 0,
+ supported_samplerates,
};
static GSList *device_instances = NULL;
ops[2] = mso_trans(3, dso_trigger & 0xff);
ops[3] = mso_trans(4, (dso_trigger >> 8) & 0xff);
ops[4] = mso_trans(11,
- mso->dso_trigger_width / HZ_TO_NS(mso->cur_rate));
+ mso->dso_trigger_width / SR_HZ_TO_NS(mso->cur_rate));
ops[5] = mso_trans(15, (2 | mso->slowmode));
/* FIXME SPI/I2C Triggers */
};
static struct rate_map rate_map[] = {
- { MHZ(200), 0x0205, 0 },
- { MHZ(100), 0x0105, 0 },
- { MHZ(50), 0x0005, 0 },
- { MHZ(20), 0x0303, 0 },
- { MHZ(10), 0x0308, 0 },
- { MHZ(5), 0x030c, 0 },
- { MHZ(2), 0x0330, 0 },
- { MHZ(1), 0x0362, 0 },
- { KHZ(500), 0x03c6, 0 },
- { KHZ(200), 0x07f2, 0 },
- { KHZ(100), 0x0fe6, 0 },
- { KHZ(50), 0x1fce, 0 },
- { KHZ(20), 0x4f86, 0 },
- { KHZ(10), 0x9f0e, 0 },
- { KHZ(5), 0x03c7, 0x20 },
- { KHZ(2), 0x07f3, 0x20 },
- { KHZ(1), 0x0fe7, 0x20 },
+ { SR_MHZ(200), 0x0205, 0 },
+ { SR_MHZ(100), 0x0105, 0 },
+ { SR_MHZ(50), 0x0005, 0 },
+ { SR_MHZ(20), 0x0303, 0 },
+ { SR_MHZ(10), 0x0308, 0 },
+ { SR_MHZ(5), 0x030c, 0 },
+ { SR_MHZ(2), 0x0330, 0 },
+ { SR_MHZ(1), 0x0362, 0 },
+ { SR_KHZ(500), 0x03c6, 0 },
+ { SR_KHZ(200), 0x07f2, 0 },
+ { SR_KHZ(100), 0x0fe6, 0 },
+ { SR_KHZ(50), 0x1fce, 0 },
+ { SR_KHZ(20), 0x4f86, 0 },
+ { SR_KHZ(10), 0x9f0e, 0 },
+ { SR_KHZ(5), 0x03c7, 0x20 },
+ { SR_KHZ(2), 0x07f3, 0x20 },
+ { SR_KHZ(1), 0x0fe7, 0x20 },
{ 500, 0x1fcf, 0x20 },
{ 200, 0x4f87, 0x20 },
{ 100, 0x9f0f, 0x20 },
#define NUM_TRIGGER_STAGES 4
#define TRIGGER_TYPES "01"
#define SERIAL_SPEED B115200
-#define CLOCK_RATE MHZ(100)
+#define CLOCK_RATE SR_MHZ(100)
#define MIN_NUM_SAMPLES 4
/* Command opcodes */
static struct sr_samplerates samplerates = {
10,
- MHZ(200),
+ SR_MHZ(200),
1,
0,
};
free(serial_params);
g_slist_free(ports);
- cur_samplerate = KHZ(200);
+ cur_samplerate = SR_KHZ(200);
return final_devcnt;
}
static libusb_context *usb_context = NULL;
static uint64_t supported_samplerates[] = {
- KHZ(200),
- KHZ(250),
- KHZ(500),
- MHZ(1),
- MHZ(2),
- MHZ(4),
- MHZ(8),
- MHZ(12),
- MHZ(16),
- MHZ(24),
+ SR_KHZ(200),
+ SR_KHZ(250),
+ SR_KHZ(500),
+ SR_MHZ(1),
+ SR_MHZ(2),
+ SR_MHZ(4),
+ SR_MHZ(8),
+ SR_MHZ(12),
+ SR_MHZ(16),
+ SR_MHZ(24),
0,
};
static struct sr_samplerates samplerates = {
- KHZ(200),
- MHZ(24),
+ SR_KHZ(200),
+ SR_MHZ(24),
0,
supported_samplerates,
};
static uint64_t supported_samplerates[] = {
100,
500,
- KHZ(1),
- KHZ(5),
- KHZ(25),
- KHZ(50),
- KHZ(100),
- KHZ(200),
- KHZ(400),
- KHZ(800),
- MHZ(1),
- MHZ(10),
- MHZ(25),
- MHZ(50),
- MHZ(80),
- MHZ(100),
- MHZ(150),
- MHZ(200),
+ SR_KHZ(1),
+ SR_KHZ(5),
+ SR_KHZ(25),
+ SR_KHZ(50),
+ SR_KHZ(100),
+ SR_KHZ(200),
+ SR_KHZ(400),
+ SR_KHZ(800),
+ SR_MHZ(1),
+ SR_MHZ(10),
+ SR_MHZ(25),
+ SR_MHZ(50),
+ SR_MHZ(80),
+ SR_MHZ(100),
+ SR_MHZ(150),
+ SR_MHZ(200),
0,
};
static int set_configuration_samplerate(uint64_t samplerate)
{
g_message("%s(%" PRIu64 ")", __FUNCTION__, samplerate);
- if (samplerate > MHZ(1))
- analyzer_set_freq(samplerate / MHZ(1), FREQ_SCALE_MHZ);
- else if (samplerate > KHZ(1))
- analyzer_set_freq(samplerate / KHZ(1), FREQ_SCALE_KHZ);
+ if (samplerate > SR_MHZ(1))
+ analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
+ else if (samplerate > SR_KHZ(1))
+ analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
else
analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
/* timescale */
/* VCD can only handle 1/10/100 (s - fs), so scale up first */
- if (ctx->samplerate > MHZ(1))
- ctx->period = GHZ(1);
- else if (ctx->samplerate > KHZ(1))
- ctx->period = MHZ(1);
+ if (ctx->samplerate > SR_MHZ(1))
+ ctx->period = SR_GHZ(1);
+ else if (ctx->samplerate > SR_KHZ(1))
+ ctx->period = SR_MHZ(1);
else
- ctx->period = KHZ(1);
+ ctx->period = SR_KHZ(1);
if (!(frequency_s = sr_period_string(ctx->period))) {
g_string_free(ctx->header, TRUE);
free(ctx);
#define SR_MAX_PROBENAME_LEN 32
/* Handy little macros */
-#define KHZ(n) ((n) * 1000)
-#define MHZ(n) ((n) * 1000000)
-#define GHZ(n) ((n) * 1000000000)
+#define SR_KHZ(n) ((n) * 1000)
+#define SR_MHZ(n) ((n) * 1000000)
+#define SR_GHZ(n) ((n) * 1000000000)
-#define HZ_TO_NS(n) (1000000000 / (n))
+#define SR_HZ_TO_NS(n) (1000000000 / (n))
typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data);
if (!o)
return NULL;
- if (samplerate >= GHZ(1))
+ if (samplerate >= SR_GHZ(1))
r = snprintf(o, 30, "%" PRIu64 " GHz", samplerate / 1000000000);
- else if (samplerate >= MHZ(1))
+ else if (samplerate >= SR_MHZ(1))
r = snprintf(o, 30, "%" PRIu64 " MHz", samplerate / 1000000);
- else if (samplerate >= KHZ(1))
+ else if (samplerate >= SR_KHZ(1))
r = snprintf(o, 30, "%" PRIu64 " kHz", samplerate / 1000);
else
r = snprintf(o, 30, "%" PRIu64 " Hz", samplerate);
if (!o)
return NULL;
- if (frequency >= GHZ(1))
+ if (frequency >= SR_GHZ(1))
r = snprintf(o, 30, "%" PRIu64 " ns", frequency / 1000000000);
- else if (frequency >= MHZ(1))
+ else if (frequency >= SR_MHZ(1))
r = snprintf(o, 30, "%" PRIu64 " us", frequency / 1000000);
- else if (frequency >= KHZ(1))
+ else if (frequency >= SR_KHZ(1))
r = snprintf(o, 30, "%" PRIu64 " ms", frequency / 1000);
else
r = snprintf(o, 30, "%" PRIu64 " s", frequency);
break;
case 'k':
case 'K':
- multiplier = KHZ(1);
+ multiplier = SR_KHZ(1);
break;
case 'm':
case 'M':
- multiplier = MHZ(1);
+ multiplier = SR_MHZ(1);
break;
case 'g':
case 'G':
- multiplier = GHZ(1);
+ multiplier = SR_GHZ(1);
break;
default:
val = 0;