]> sigrok.org Git - libsigrok.git/blobdiff - sigrok.h
Change all sigrok_ prefixes to sr_.
[libsigrok.git] / sigrok.h
index 59d6b1a3082978d361b7692ba67a892c7cf56f1b..c25380af7ba8cc108484a679f4fe637089497020 100644 (file)
--- a/sigrok.h
+++ b/sigrok.h
@@ -27,6 +27,9 @@
 #include <glib.h>
 #include <libusb.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
  * Status/error codes returned by libsigrok functions.
  * or reused for different #defines later. You can only add new #defines and
  * return codes, but never remove or redefine existing ones.
  */
-#define SIGROK_OK                 0 /* No error */
-#define SIGROK_ERR               -1 /* Generic/unspecified error */
-#define SIGROK_ERR_MALLOC        -2 /* Malloc/calloc/realloc error */
-#define SIGROK_ERR_SAMPLERATE    -3 /* Incorrect samplerate */
+#define SR_OK                 0 /* No error */
+#define SR_ERR               -1 /* Generic/unspecified error */
+#define SR_ERR_MALLOC        -2 /* Malloc/calloc/realloc error */
+#define SR_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 ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
 #endif
 
-
 typedef int (*receive_data_callback) (int fd, int revents, void *user_data);
 
-
 /* Data types used by hardware plugins for set_configuration() */
 enum {
        T_UINT64,
        T_CHAR,
+       T_NULL,
 };
 
 enum {
@@ -91,8 +92,6 @@ struct protocol {
        int stackindex;
 };
 
-
-
 /* datafeed_packet.type values */
 enum {
        DF_HEADER,
@@ -119,42 +118,49 @@ struct datafeed_header {
        int num_logic_probes;
 };
 
+struct analog_probe {
+       uint8_t att;
+       uint8_t res;    /* Needs to be a power of 2, FIXME */
+       uint16_t val;   /* Max hardware ADC width is 16bits */
+};
 
+struct analog_sample {
+       uint8_t num_probes; /* Max hardware probes is 256 */
+       struct analog_probe probes[];
+};
 
-struct input {
-       struct input_format *format;
-       void *param;
-       void *internal;
+struct sr_input {
+       struct sr_input_format *format;
+       char *param;
+       struct device *vdevice;
 };
 
-struct input_format {
+struct sr_input_format {
        char *extension;
        char *description;
        int (*format_match) (const char *filename);
-       int (*in_loadfile) (const char *filename);
+       int (*init) (struct sr_input *in);
+       int (*loadfile) (struct sr_input *in, const char *filename);
 };
 
-
-
-struct output {
-       struct output_format *format;
+struct sr_output {
+       struct sr_output_format *format;
        struct device *device;
        char *param;
        void *internal;
 };
 
-struct output_format {
+struct sr_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,
+       int (*init) (struct sr_output *o);
+       int (*data) (struct sr_output *o, char *data_in, uint64_t length_in,
                     char **data_out, uint64_t *length_out);
-       int (*event) (struct output *o, int event_type, char **data_out,
+       int (*event) (struct sr_output *o, int event_type, char **data_out,
                      uint64_t *length_out);
 };
 
-
 struct analyzer {
        char *name;
        char *filename;
@@ -164,7 +170,6 @@ struct analyzer {
         */
 };
 
-
 /* Size of a chunk in units */
 #define DATASTORE_CHUNKSIZE 512000
 
@@ -175,7 +180,6 @@ struct datastore {
        GSList *chunklist;
 };
 
-
 /*
  * This represents a generic device connected to the system.
  * For device-specific information, ask the plugin. The plugin_index refers
@@ -208,16 +212,22 @@ struct probe {
 
 extern GSList *devices;
 
-
 /* Hardware plugin capabilities */
 enum {
-       HWCAP_DUMMY,            /* Used to terminate lists */
+       HWCAP_DUMMY,             /* Used to terminate lists */
+       /* device classes */
        HWCAP_LOGIC_ANALYZER,
-       HWCAP_SAMPLERATE,       /* Change samplerate */
-       HWCAP_PROBECONFIG,      /* Configure probe mask */
-       HWCAP_CAPTURE_RATIO,    /* Set pre/post-trigger capture ratio */
-       HWCAP_LIMIT_MSEC,       /* Set a time limit for sample acquisition */
-       HWCAP_LIMIT_SAMPLES,    /* Set a limit on number of samples */
+
+       /* device options */
+       HWCAP_SAMPLERATE,        /* Change samplerate */
+       HWCAP_PROBECONFIG,       /* Configure probe mask */
+       HWCAP_CAPTURE_RATIO,     /* Set pre/post-trigger capture ratio */
+       HWCAP_PATTERN_MODE,      /* Pattern generator mode */
+
+       /* acquisition modes */
+       HWCAP_LIMIT_MSEC,        /* Set a time limit for sample acquisition */
+       HWCAP_LIMIT_SAMPLES,     /* Set a limit on number of samples */
+       HWCAP_CONTINUOUS,
 };
 
 struct hwcap_option {
@@ -227,8 +237,7 @@ struct hwcap_option {
        char *shortname;
 };
 
-
-struct sigrok_device_instance {
+struct sr_device_instance {
        int index;
        int status;
        int instance_type;
@@ -242,7 +251,7 @@ struct sigrok_device_instance {
        };
 };
 
-/* sigrok_device_instance types */
+/* sr_device_instance types */
 enum {
        USB_INSTANCE,
        SERIAL_INSTANCE,
@@ -277,7 +286,7 @@ enum {
 
 /* Device info IDs */
 enum {
-       /* struct sigrok_device_instance for this specific device */
+       /* struct sr_device_instance for this specific device */
        DI_INSTANCE,
        /* The number of probes connected to this device */
        DI_NUM_PROBES,
@@ -287,6 +296,8 @@ enum {
        DI_TRIGGER_TYPES,
        /* The currently set samplerate in Hz (uint64_t) */
        DI_CUR_SAMPLERATE,
+       /* Supported pattern generator modes */
+       DI_PATTERNMODES,
 };
 
 /*
@@ -331,10 +342,16 @@ struct session {
        GSList *devices;
        /* List of struct analyzer* */
        GSList *analyzers;
-       /* Datafeed callbacks */
+       /* list of receive_data_callback */
        GSList *datafeed_callbacks;
        GTimeVal starttime;
+       gboolean running;
 };
 
 #include "sigrok-proto.h"
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif