ols: add test mode support
ols allows both external and internal test patterns at ~20khz which are helpful for unit tests and demos. pattern=internal -> route pattern internally to all 32 pins (input otherwise disabled) pattern=external -> generates pattern on unbuffered pins 16:31 (which can be looped back to the buffered pins 0:15) Signed-off-by: Matt Ranostay <mranostay@gmail.com>
This commit is contained in:
parent
503133bb5f
commit
967760a893
|
@ -32,9 +32,25 @@ static const int32_t hwcaps[] = {
|
||||||
SR_CONF_TRIGGER_TYPE,
|
SR_CONF_TRIGGER_TYPE,
|
||||||
SR_CONF_CAPTURE_RATIO,
|
SR_CONF_CAPTURE_RATIO,
|
||||||
SR_CONF_LIMIT_SAMPLES,
|
SR_CONF_LIMIT_SAMPLES,
|
||||||
|
SR_CONF_PATTERN_MODE,
|
||||||
SR_CONF_RLE,
|
SR_CONF_RLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define STR_PATTERN_EXTERNAL "external"
|
||||||
|
#define STR_PATTERN_INTERNAL "internal"
|
||||||
|
|
||||||
|
/* Supported methods of test pattern outputs */
|
||||||
|
enum {
|
||||||
|
/**
|
||||||
|
* Capture pins 31:16 (unbuffered wing) output a test pattern
|
||||||
|
* that can captured on pins 0:15.
|
||||||
|
*/
|
||||||
|
PATTERN_EXTERNAL,
|
||||||
|
|
||||||
|
/** Route test pattern internally to capture buffer. */
|
||||||
|
PATTERN_INTERNAL,
|
||||||
|
};
|
||||||
|
|
||||||
/* Probes are numbered 0-31 (on the PCB silkscreen). */
|
/* Probes are numbered 0-31 (on the PCB silkscreen). */
|
||||||
SR_PRIV const char *ols_probe_names[NUM_PROBES + 1] = {
|
SR_PRIV const char *ols_probe_names[NUM_PROBES + 1] = {
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
|
||||||
|
@ -235,6 +251,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
|
||||||
case SR_CONF_LIMIT_SAMPLES:
|
case SR_CONF_LIMIT_SAMPLES:
|
||||||
*data = g_variant_new_uint64(devc->limit_samples);
|
*data = g_variant_new_uint64(devc->limit_samples);
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_PATTERN_MODE:
|
||||||
|
if (devc->flag_reg & FLAG_EXTERNAL_TEST_MODE)
|
||||||
|
*data = g_variant_new_string(STR_PATTERN_EXTERNAL);
|
||||||
|
else if (devc->flag_reg & FLAG_INTERNAL_TEST_MODE)
|
||||||
|
*data = g_variant_new_string(STR_PATTERN_INTERNAL);
|
||||||
|
break;
|
||||||
case SR_CONF_RLE:
|
case SR_CONF_RLE:
|
||||||
*data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE);
|
*data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE);
|
||||||
break;
|
break;
|
||||||
|
@ -250,6 +272,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int ret;
|
int ret;
|
||||||
uint64_t tmp_u64;
|
uint64_t tmp_u64;
|
||||||
|
const char *stropt;
|
||||||
|
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
@ -278,6 +301,19 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
|
||||||
} else
|
} else
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_PATTERN_MODE:
|
||||||
|
stropt = g_variant_get_string(data, NULL);
|
||||||
|
ret = SR_OK;
|
||||||
|
if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
|
||||||
|
sr_info("Enabling internal test mode.");
|
||||||
|
devc->flag_reg |= FLAG_INTERNAL_TEST_MODE;
|
||||||
|
} else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
|
||||||
|
sr_info("Enabling external test mode.");
|
||||||
|
devc->flag_reg |= FLAG_EXTERNAL_TEST_MODE;
|
||||||
|
} else {
|
||||||
|
ret = SR_ERR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SR_CONF_RLE:
|
case SR_CONF_RLE:
|
||||||
if (g_variant_get_boolean(data)) {
|
if (g_variant_get_boolean(data)) {
|
||||||
sr_info("Enabling RLE.");
|
sr_info("Enabling RLE.");
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
/* Command opcodes */
|
/* Command opcodes */
|
||||||
#define CMD_RESET 0x00
|
#define CMD_RESET 0x00
|
||||||
#define CMD_RUN 0x01
|
#define CMD_RUN 0x01
|
||||||
|
#define CMD_TESTMODE 0x03
|
||||||
#define CMD_ID 0x02
|
#define CMD_ID 0x02
|
||||||
#define CMD_METADATA 0x04
|
#define CMD_METADATA 0x04
|
||||||
#define CMD_SET_FLAGS 0x82
|
#define CMD_SET_FLAGS 0x82
|
||||||
|
@ -74,6 +75,8 @@
|
||||||
#define FLAG_CLOCK_EXTERNAL 0x40
|
#define FLAG_CLOCK_EXTERNAL 0x40
|
||||||
#define FLAG_CLOCK_INVERTED 0x80
|
#define FLAG_CLOCK_INVERTED 0x80
|
||||||
#define FLAG_RLE 0x0100
|
#define FLAG_RLE 0x0100
|
||||||
|
#define FLAG_EXTERNAL_TEST_MODE 0x0400
|
||||||
|
#define FLAG_INTERNAL_TEST_MODE 0x0800
|
||||||
|
|
||||||
/* Private, per-device-instance driver context. */
|
/* Private, per-device-instance driver context. */
|
||||||
struct dev_context {
|
struct dev_context {
|
||||||
|
|
Loading…
Reference in New Issue