]> sigrok.org Git - libsigrok.git/blobdiff - sigrok.h
Add HZ_TO_NS macro
[libsigrok.git] / sigrok.h
index a1531bf73af178cf02ef5d86466d04833b234466..ebbfcb89e32fd9b9c63d826992cefa6b69e0e8b2 100644 (file)
--- a/sigrok.h
+++ b/sigrok.h
 #define SIGROK_ERR_MALLOC              -2 /* Malloc/calloc/realloc error */
 #define SIGROK_ERR_SAMPLERATE          -3 /* Incorrect samplerate */
 
+/* limited by uint64_t */
+#define MAX_NUM_PROBES 64
+#define MAX_PROBENAME_LEN 32
+
+
 /* Handy little macros */
 #define KHZ(n) ((n) * 1000)
 #define MHZ(n) ((n) * 1000000)
 #define GHZ(n) ((n) * 1000000000)
 
+#define HZ_TO_NS(n) (1000000000 / (n))
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 #endif
 
+#ifndef ARRAY_AND_SIZE
+#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
+#endif
+
 /* Data types, used by hardware plugins for set_configuration() */
 enum {
        T_UINT64,
@@ -84,17 +95,15 @@ enum {
        DF_HEADER,
        DF_END,
        DF_TRIGGER,
-       DF_LOGIC8,
-       DF_LOGIC16,
-       DF_LOGIC24,
-       DF_LOGIC32,
-       DF_LOGIC48,
-       DF_LOGIC64,
+       DF_LOGIC,
+       DF_ANALOG,
+       DF_PD,
 };
 
 struct datafeed_packet {
        uint16_t type;
        uint64_t length;
+       uint16_t unitsize;
        void *payload;
 };
 
@@ -103,7 +112,8 @@ struct datafeed_header {
        struct timeval starttime;
        uint64_t samplerate;
        int protocol_id;
-       int num_probes;
+       int num_analog_probes;
+       int num_logic_probes;
 };
 
 /*
@@ -118,8 +128,8 @@ struct input {
 struct input_format {
        char *extension;
        char *description;
-       int (*format_match) (char *filename);
-       int (*in_loadfile) (char *filename);
+       int (*format_match) (const char *filename);
+       int (*in_loadfile) (const char *filename);
 };
 
 struct input_format **input_list(void);
@@ -138,6 +148,7 @@ struct output {
 struct output_format {
        char *extension;
        char *description;
+       int df_type;
        int (*init) (struct output *o);
        int (*data) (struct output *o, char *data_in, uint64_t length_in,
                     char **data_out, uint64_t *length_out);
@@ -153,6 +164,7 @@ int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
                  uint64_t *length_out);
 
 char *sigrok_samplerate_string(uint64_t samplerate);
+char *sigrok_period_string(uint64_t frequency);
 
 /*--- analyzer.c ------------------------------------------------------------*/
 
@@ -210,8 +222,14 @@ struct device {
        struct datastore *datastore;
 };
 
+enum {
+       PROBE_TYPE_LOGIC,
+       PROBE_TYPE_ANALOG,
+};
+
 struct probe {
        int index;
+       int type;
        gboolean enabled;
        char *name;
        char *trigger;
@@ -261,6 +279,7 @@ struct sigrok_device_instance {
        char *vendor;
        char *model;
        char *version;
+       void *priv;
        union {
                struct usb_device_instance *usb;
                struct serial_device_instance *serial;