X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=libsigrok-internal.h;h=6e665c58a52a6f2b2afc6cbaa9a4ff8f8e247ab6;hb=ea2d6d994f28c11b7b3d0232bd1a3dbbbf67a401;hp=d7d740d822000685f5d56fc4ef24a6da9e26f851;hpb=c09392d092f4b4c8d979b968bacb9f9056dc45e6;p=libsigrok.git diff --git a/libsigrok-internal.h b/libsigrok-internal.h index d7d740d8..6e665c58 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -50,6 +50,13 @@ #define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a) #endif +/** + * Read a 8 bits integer out of memory. + * @param x a pointer to the input memory + * @return the corresponding integer + */ +#define R8(x) ((unsigned)((const uint8_t*)(x))[0]) + /** * Read a 16 bits big endian integer out of memory. * @param x a pointer to the input memory @@ -86,6 +93,49 @@ ((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 @@ -174,6 +224,14 @@ SR_PRIV int sr_err(const char *format, ...); /*--- device.c --------------------------------------------------------------*/ +/** Values for the changes argument of sr_dev_driver.config_probe_set. */ +enum { + /** The enabled state of the probe has been changed. */ + SR_PROBE_SET_ENABLED = 1 << 0, + /** The trigger setup of the probe has been changed. */ + SR_PROBE_SET_TRIGGER = 1 << 1, +}; + SR_PRIV struct sr_probe *sr_probe_new(int index, int type, gboolean enabled, const char *name);