]> sigrok.org Git - libsigrok.git/blobdiff - hardware/saleae-logic/saleae-logic.c
Add SR_ prefix to the KHZ/MHZ/GHZ macros.
[libsigrok.git] / hardware / saleae-logic / saleae-logic.c
index b66fd30d9743387c0cb80c4388daedb985906af1..23ba69a9aa52f4f3b900d5a9941444ea056bb1e9 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/time.h>
@@ -25,7 +26,6 @@
 #include <libusb.h>
 #include <sigrok.h>
 #include <sigrok-internal.h>
-#include "config.h"
 
 #define USB_VENDOR                 0x0925
 #define USB_PRODUCT                    0x3881
@@ -68,27 +68,27 @@ static GSList *device_instances = NULL;
  * upgrade -- this is like a global lock. No device will open until a proper
  * delay after the last device was upgraded.
  */
-GTimeVal firmware_updated = { 0, 0 };
+static GTimeVal firmware_updated = { 0, 0 };
 
 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 samplerates samplerates = {
-       KHZ(200),
-       MHZ(24),
+static struct sr_samplerates samplerates = {
+       SR_KHZ(200),
+       SR_MHZ(24),
        0,
        supported_samplerates,
 };
@@ -101,7 +101,7 @@ static uint8_t trigger_mask[NUM_TRIGGER_STAGES] = { 0 };
 static uint8_t trigger_value[NUM_TRIGGER_STAGES] = { 0 };
 static uint8_t trigger_buffer[NUM_TRIGGER_STAGES] = { 0 };
 
-int trigger_stage = TRIGGER_FIRED;
+static int trigger_stage = TRIGGER_FIRED;
 
 static int hw_set_configuration(int device_index, int capability, void *value);
 static void hw_stop_acquisition(int device_index, gpointer session_device_id);
@@ -112,7 +112,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id);
  * @return 1 if the device's configuration profile match the Logic firmware's
  *         configuration, 0 otherwise.
  */
-int check_conf_profile(libusb_device *dev)
+static int check_conf_profile(libusb_device *dev)
 {
        struct libusb_device_descriptor des;
        struct libusb_config_descriptor *conf_dsc = NULL;
@@ -166,7 +166,7 @@ int check_conf_profile(libusb_device *dev)
        return ret;
 }
 
-struct sr_device_instance *sl_open_device(int device_index)
+static struct sr_device_instance *sl_open_device(int device_index)
 {
        struct sr_device_instance *sdi;
        libusb_device **devlist;
@@ -214,7 +214,7 @@ struct sr_device_instance *sl_open_device(int device_index)
        return sdi;
 }
 
-int upload_firmware(libusb_device *dev)
+static int upload_firmware(libusb_device *dev)
 {
        int ret;
 
@@ -243,7 +243,7 @@ static void close_device(struct sr_device_instance *sdi)
 
 static int configure_probes(GSList *probes)
 {
-       struct probe *probe;
+       struct sr_probe *probe;
        GSList *l;
        int probe_bit, stage, i;
        char *tc;
@@ -256,7 +256,7 @@ static int configure_probes(GSList *probes)
 
        stage = -1;
        for (l = probes; l; l = l->next) {
-               probe = (struct probe *)l->data;
+               probe = (struct sr_probe *)l->data;
                if (probe->enabled == FALSE)
                        continue;
                probe_bit = 1 << (probe->index - 1);
@@ -291,7 +291,7 @@ static int configure_probes(GSList *probes)
  * API callbacks
  */
 
-static int hw_init(char *deviceinfo)
+static int hw_init(const char *deviceinfo)
 {
        struct sr_device_instance *sdi;
        struct libusb_device_descriptor des;
@@ -609,7 +609,7 @@ void receive_transfer(struct libusb_transfer *transfer)
                                         */
                                        packet.type = SR_DF_TRIGGER;
                                        packet.length = 0;
-                                       session_bus(user_data, &packet);
+                                       sr_session_bus(user_data, &packet);
 
                                        /*
                                         * Send the samples that triggered it, since we're
@@ -619,7 +619,7 @@ void receive_transfer(struct libusb_transfer *transfer)
                                        packet.length = trigger_stage;
                                        packet.unitsize = 1;
                                        packet.payload = trigger_buffer;
-                                       session_bus(user_data, &packet);
+                                       sr_session_bus(user_data, &packet);
 
                                        trigger_stage = TRIGGER_FIRED;
                                        break;
@@ -652,7 +652,7 @@ void receive_transfer(struct libusb_transfer *transfer)
                packet.length = cur_buflen - trigger_offset;
                packet.unitsize = 1;
                packet.payload = cur_buf + trigger_offset;
-               session_bus(user_data, &packet);
+               sr_session_bus(user_data, &packet);
                g_free(cur_buf);
 
                num_samples += cur_buflen;
@@ -704,8 +704,8 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
 
        lupfd = libusb_get_pollfds(usb_context);
        for (i = 0; lupfd[i]; i++)
-               source_add(lupfd[i]->fd, lupfd[i]->events, 40, receive_data,
-                          NULL);
+               sr_source_add(lupfd[i]->fd, lupfd[i]->events, 40, receive_data,
+                             NULL);
        free(lupfd);
 
        packet->type = SR_DF_HEADER;
@@ -717,7 +717,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        header->protocol_id = SR_PROTO_RAW;
        header->num_logic_probes = NUM_PROBES;
        header->num_analog_probes = 0;
-       session_bus(session_device_id, packet);
+       sr_session_bus(session_device_id, packet);
        g_free(header);
        g_free(packet);
 
@@ -733,7 +733,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
        device_index = device_index;
 
        packet.type = SR_DF_END;
-       session_bus(session_device_id, &packet);
+       sr_session_bus(session_device_id, &packet);
 
        receive_transfer(NULL);