]> sigrok.org Git - libsigrok.git/blobdiff - hardware/openbench-logic-sniffer/ols.c
Add SR_ prefix to the KHZ/MHZ/GHZ macros.
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.c
index dd1fbdb2d1c526a61489ab8e470007e4d1fc0627..8f8f5cb2d8981519979a6a9661786593a4350c4f 100644 (file)
@@ -49,7 +49,7 @@
 #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 */
@@ -91,9 +91,9 @@ static int capabilities[] = {
        0,
 };
 
-static struct samplerates samplerates = {
+static struct sr_samplerates samplerates = {
        10,
-       MHZ(200),
+       SR_MHZ(200),
        1,
        0,
 };
@@ -147,7 +147,7 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data)
 
 static int configure_probes(GSList *probes)
 {
-       struct probe *probe;
+       struct sr_probe *probe;
        GSList *l;
        int probe_bit, stage, i;
        char *tc;
@@ -160,7 +160,7 @@ static int configure_probes(GSList *probes)
 
        num_stages = 0;
        for (l = probes; l; l = l->next) {
-               probe = (struct probe *)l->data;
+               probe = (struct sr_probe *)l->data;
                if (!probe->enabled)
                        continue;
 
@@ -219,7 +219,7 @@ static uint32_t reverse32(uint32_t in)
        return out;
 }
 
-static int hw_init(char *deviceinfo)
+static int hw_init(const char *deviceinfo)
 {
        struct sr_device_instance *sdi;
        GSList *ports, *l;
@@ -321,7 +321,7 @@ static int hw_init(char *deviceinfo)
        free(serial_params);
        g_slist_free(ports);
 
-       cur_samplerate = samplerates.low;
+       cur_samplerate = SR_KHZ(200);
 
        return final_devcnt;
 }
@@ -506,8 +506,8 @@ static int receive_data(int fd, int revents, void *user_data)
                 * longer than it takes to send a byte, that means it's
                 * finished. We'll double that to 30ms to be sure...
                 */
-               source_remove(fd);
-               source_add(fd, G_IO_IN, 30, receive_data, user_data);
+               sr_source_remove(fd);
+               sr_source_add(fd, G_IO_IN, 30, receive_data, user_data);
                raw_sample_buf = malloc(limit_samples * 4);
                /* fill with 1010... for debugging */
                memset(raw_sample_buf, 0x82, limit_samples * 4);
@@ -618,24 +618,24 @@ static int receive_data(int fd, int revents, void *user_data)
                                packet.length = trigger_at * 4;
                                packet.unitsize = 4;
                                packet.payload = raw_sample_buf;
-                               session_bus(user_data, &packet);
+                               sr_session_bus(user_data, &packet);
                        }
 
                        packet.type = SR_DF_TRIGGER;
                        packet.length = 0;
-                       session_bus(user_data, &packet);
+                       sr_session_bus(user_data, &packet);
 
                        packet.type = SR_DF_LOGIC;
                        packet.length = (limit_samples * 4) - (trigger_at * 4);
                        packet.unitsize = 4;
                        packet.payload = raw_sample_buf + trigger_at * 4;
-                       session_bus(user_data, &packet);
+                       sr_session_bus(user_data, &packet);
                } else {
                        packet.type = SR_DF_LOGIC;
                        packet.length = limit_samples * 4;
                        packet.unitsize = 4;
                        packet.payload = raw_sample_buf;
-                       session_bus(user_data, &packet);
+                       sr_session_bus(user_data, &packet);
                }
                free(raw_sample_buf);
 
@@ -643,7 +643,7 @@ static int receive_data(int fd, int revents, void *user_data)
                serial_close(fd);
                packet.type = SR_DF_END;
                packet.length = 0;
-               session_bus(user_data, &packet);
+               sr_session_bus(user_data, &packet);
        }
 
        return TRUE;
@@ -755,8 +755,8 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
        if (send_shortcommand(sdi->serial->fd, CMD_RUN) != SR_OK)
                return SR_ERR;
 
-       source_add(sdi->serial->fd, G_IO_IN, -1, receive_data,
-                  session_device_id);
+       sr_source_add(sdi->serial->fd, G_IO_IN, -1, receive_data,
+                     session_device_id);
 
        /* Send header packet to the session bus. */
        packet = g_malloc(sizeof(struct sr_datafeed_packet));
@@ -772,7 +772,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);
 
@@ -788,7 +788,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
 
        packet.type = SR_DF_END;
        packet.length = 0;
-       session_bus(session_device_id, &packet);
+       sr_session_bus(session_device_id, &packet);
 }
 
 struct sr_device_plugin ols_plugin_info = {