]> sigrok.org Git - libsigrok.git/blobdiff - hardware/chronovu-la8/protocol.c
Replace 'probe' with 'channel' in most places.
[libsigrok.git] / hardware / chronovu-la8 / protocol.c
index 35a0342c30eb34b9ca6a36da6a0b35a06e2b9f3b..85d21d992f385e4ff3987bdad680014ad5095d6b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
  *
  * Copyright (C) 2011-2012 Uwe Hermann <uwe@hermann-uwe.de>
  *
 #include "protocol.h"
 
 /* Probes are numbered 0-7. */
-SR_PRIV const char *probe_names[NUM_PROBES + 1] = {
+SR_PRIV const char *chronovu_la8_channel_names[NUM_PROBES + 1] = {
        "0", "1", "2", "3", "4", "5", "6", "7",
        NULL,
 };
 
-/* This will be initialized via config_list()/SR_CONF_SAMPLERATE. */
-SR_PRIV uint64_t supported_samplerates[255 + 1] = { 0 };
-
-/*
- * Min: 1 sample per 0.01us -> sample time is 0.084s, samplerate 100MHz
- * Max: 1 sample per 2.55us -> sample time is 21.391s, samplerate 392.15kHz
- */
-const struct sr_samplerates samplerates = {
-       .low  = 0,
-       .high = 0,
-       .step = 0,
-       .list = supported_samplerates,
-};
-
-/* Note: Continuous sampling is not supported by the hardware. */
-SR_PRIV const int hwcaps[] = {
-       SR_CONF_LOGIC_ANALYZER,
-       SR_CONF_SAMPLERATE,
-       SR_CONF_LIMIT_MSEC, /* TODO: Not yet implemented. */
-       SR_CONF_LIMIT_SAMPLES, /* TODO: Not yet implemented. */
-       0,
-};
-
 SR_PRIV void fill_supported_samplerates_if_needed(void)
 {
        int i;
 
-       /* Do nothing if supported_samplerates[] is already filled. */
-       if (supported_samplerates[0] != 0)
+       if (chronovu_la8_samplerates[0] != 0)
                return;
 
-       /* Fill supported_samplerates[] with the proper values. */
        for (i = 0; i < 255; i++)
-               supported_samplerates[254 - i] = SR_MHZ(100) / (i + 1);
-       supported_samplerates[255] = 0;
+               chronovu_la8_samplerates[254 - i] = SR_MHZ(100) / (i + 1);
 }
 
 /**
@@ -80,7 +54,7 @@ SR_PRIV int is_valid_samplerate(uint64_t samplerate)
        fill_supported_samplerates_if_needed();
 
        for (i = 0; i < 255; i++) {
-               if (supported_samplerates[i] == samplerate)
+               if (chronovu_la8_samplerates[i] == samplerate)
                        return 1;
        }
 
@@ -310,46 +284,46 @@ SR_PRIV int la8_reset(struct dev_context *devc)
        return SR_OK;
 }
 
-SR_PRIV int configure_probes(const struct sr_dev_inst *sdi)
+SR_PRIV int configure_channels(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
-       const struct sr_probe *probe;
+       const struct sr_channel *ch;
        const GSList *l;
-       uint8_t probe_bit;
+       uint8_t channel_bit;
        char *tc;
 
        devc = sdi->priv;
        devc->trigger_pattern = 0;
-       devc->trigger_mask = 0; /* Default to "don't care" for all probes. */
+       devc->trigger_mask = 0; /* Default to "don't care" for all channels. */
 
-       for (l = sdi->probes; l; l = l->next) {
-               probe = (struct sr_probe *)l->data;
+       for (l = sdi->channels; l; l = l->next) {
+               ch = (struct sr_channel *)l->data;
 
-               if (!probe) {
-                       sr_err("%s: probe was NULL.", __func__);
+               if (!ch) {
+                       sr_err("%s: channel was NULL.", __func__);
                        return SR_ERR;
                }
 
-               /* Skip disabled probes. */
-               if (!probe->enabled)
+               /* Skip disabled channels. */
+               if (!ch->enabled)
                        continue;
 
-               /* Skip (enabled) probes with no configured trigger. */
-               if (!probe->trigger)
+               /* Skip (enabled) channels with no configured trigger. */
+               if (!ch->trigger)
                        continue;
 
-               /* Note: Must only be run if probe->trigger != NULL. */
-               if (probe->index < 0 || probe->index > 7) {
-                       sr_err("%s: Invalid probe index %d, must be "
-                              "between 0 and 7.", __func__, probe->index);
+               /* Note: Must only be run if ch->trigger != NULL. */
+               if (ch->index < 0 || ch->index > 7) {
+                       sr_err("%s: Invalid channel index %d, must be "
+                              "between 0 and 7.", __func__, ch->index);
                        return SR_ERR;
                }
 
-               probe_bit = (1 << (probe->index));
+               channel_bit = (1 << (ch->index));
 
-               /* Configure the probe's trigger mask and trigger pattern. */
-               for (tc = probe->trigger; tc && *tc; tc++) {
-                       devc->trigger_mask |= probe_bit;
+               /* Configure the channel's trigger mask and trigger pattern. */
+               for (tc = ch->trigger; tc && *tc; tc++) {
+                       devc->trigger_mask |= channel_bit;
 
                        /* Sanity check, LA8 only supports low/high trigger. */
                        if (*tc != '0' && *tc != '1') {
@@ -359,7 +333,7 @@ SR_PRIV int configure_probes(const struct sr_dev_inst *sdi)
                        }
 
                        if (*tc == '1')
-                               devc->trigger_pattern |= probe_bit;
+                               devc->trigger_pattern |= channel_bit;
                }
        }
 
@@ -488,7 +462,7 @@ SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block)
                logic.length = BS;
                logic.unitsize = 1;
                logic.data = devc->final_buf + (block * BS);
-               sr_session_send(devc->session_dev_id, &packet);
+               sr_session_send(devc->cb_data, &packet);
                return;
        }
 
@@ -511,7 +485,7 @@ SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block)
                logic.length = trigger_point;
                logic.unitsize = 1;
                logic.data = devc->final_buf + (block * BS);
-               sr_session_send(devc->session_dev_id, &packet);
+               sr_session_send(devc->cb_data, &packet);
        }
 
        /* Send the SR_DF_TRIGGER packet to the session bus. */
@@ -519,7 +493,7 @@ SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block)
                (block * BS) + trigger_point);
        packet.type = SR_DF_TRIGGER;
        packet.payload = NULL;
-       sr_session_send(devc->session_dev_id, &packet);
+       sr_session_send(devc->cb_data, &packet);
 
        /* If at least one sample is located after the trigger... */
        if (trigger_point < (BS - 1)) {
@@ -532,6 +506,6 @@ SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block)
                logic.length = BS - trigger_point;
                logic.unitsize = 1;
                logic.data = devc->final_buf + (block * BS) + trigger_point;
-               sr_session_send(devc->session_dev_id, &packet);
+               sr_session_send(devc->cb_data, &packet);
        }
 }