((unsigned)((const uint8_t*)(x))[1] << 8) | \
(unsigned)((const uint8_t*)(x))[0])
+/**
+ * Write a 8 bits integer to memory.
+ * @param p a pointer to the output memory
+ * @param x the input integer
+ */
+#define W8(p, x) do { ((uint8_t*)(p))[0] = (uint8_t) (x); } while(0)
+
+/**
+ * Write a 16 bits integer to memory stored as big endian.
+ * @param p a pointer to the output memory
+ * @param x the input integer
+ */
+#define WB16(p, x) do { ((uint8_t*)(p))[1] = (uint8_t) (x); \
+ ((uint8_t*)(p))[0] = (uint8_t)((x)>>8); } while(0)
+
+/**
+ * Write a 16 bits integer to memory stored as little endian.
+ * @param p a pointer to the output memory
+ * @param x the input integer
+ */
+#define WL16(p, x) do { ((uint8_t*)(p))[0] = (uint8_t) (x); \
+ ((uint8_t*)(p))[1] = (uint8_t)((x)>>8); } while(0)
+
+/**
+ * Write a 32 bits integer to memory stored as big endian.
+ * @param p a pointer to the output memory
+ * @param x the input integer
+ */
+#define WB32(p, x) do { ((uint8_t*)(p))[3] = (uint8_t) (x); \
+ ((uint8_t*)(p))[2] = (uint8_t)((x)>>8); \
+ ((uint8_t*)(p))[1] = (uint8_t)((x)>>16); \
+ ((uint8_t*)(p))[0] = (uint8_t)((x)>>24); } while(0)
+
+/**
+ * Write a 32 bits integer to memory stored as little endian.
+ * @param p a pointer to the output memory
+ * @param x the input integer
+ */
+#define WL32(p, x) do { ((uint8_t*)(p))[0] = (uint8_t) (x); \
+ ((uint8_t*)(p))[1] = (uint8_t)((x)>>8); \
+ ((uint8_t*)(p))[2] = (uint8_t)((x)>>16); \
+ ((uint8_t*)(p))[3] = (uint8_t)((x)>>24); } while(0)
+
/* Portability fixes for FreeBSD. */
#ifdef __FreeBSD__
#define LIBUSB_CLASS_APPLICATION 0xfe
const char *name;
const char *prefix;
int priv_size;
- int (*dev_inst_new)(void *priv, const char *resource, char **params,
- const char *serialcomm);
+ int (*dev_inst_new)(void *priv, struct drv_context *drvc,
+ const char *resource, char **params, const char *serialcomm);
int (*open)(void *priv);
int (*source_add)(void *priv, int events,
int timeout, sr_receive_data_callback_t cb, void *cb_data);
void *priv;
};
-SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource,
- const char *serialcomm);
+SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc,
+ const char *resource, const char *serialcomm);
SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi);
SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
int timeout, sr_receive_data_callback_t cb, void *cb_data);