X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Flink-mso19%2Fprotocol.h;h=48502c5aca28648cef856b602ae258bfa0cc5263;hp=61c811006489dcb72792c572465350dbce64e4b5;hb=ba7dd8bbb8168cba432a844259a3e239aa5f36d7;hpb=00b44ccb8b2482c2c4c7e832ed11f7460f289e15 diff --git a/hardware/link-mso19/protocol.h b/hardware/link-mso19/protocol.h index 61c81100..48502c5a 100644 --- a/hardware/link-mso19/protocol.h +++ b/hardware/link-mso19/protocol.h @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrok project. * * Copyright (C) 2011 Daniel Ribeiro * Copyright (C) 2012 Renato Caldas @@ -25,24 +25,18 @@ #include #include #include +#include #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with driver-specific prefix string. */ -#define DRIVER_LOG_DOMAIN "mso19: " -#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) -#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) -#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) -#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) -#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) -#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) +#define LOG_PREFIX "link-mso19" #define USB_VENDOR "3195" #define USB_PRODUCT "f190" -#define NUM_PROBES 8 +#define NUM_PROBES (1 + 8) #define NUM_TRIGGER_STAGES 4 -#define TRIGGER_TYPES "01" //the first r/f is used for the whole group +#define TRIGGER_TYPE "01" //the first r/f is used for the whole group #define SERIALCOMM "460800/8n1/flow=2" #define SERIALCONN "/dev/ttyUSB0" #define CLOCK_RATE SR_MHZ(100) @@ -122,7 +116,7 @@ struct dev_context { double dso_trigger_voltage; uint16_t dso_trigger_width; struct mso_prototrig protocol_trigger; - void *session_dev_id; + void *cb_data; uint16_t buffer_n; char buffer[4096]; }; @@ -133,29 +127,21 @@ SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t * info); SR_PRIV int mso_reset_adc(struct sr_dev_inst *sdi); SR_PRIV int mso_clkrate_out(struct sr_serial_dev_inst *serial, uint16_t val); -SR_PRIV int mso_configure_rate(struct sr_dev_inst *sdi, uint32_t rate); +SR_PRIV int mso_configure_rate(const struct sr_dev_inst *sdi, uint32_t rate); SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data); -SR_PRIV int mso_configure_trigger(struct sr_dev_inst *sdi); -SR_PRIV int mso_configure_threshold_level(struct sr_dev_inst *sdi); +SR_PRIV int mso_configure_trigger(const struct sr_dev_inst *sdi); +SR_PRIV int mso_configure_threshold_level(const struct sr_dev_inst *sdi); SR_PRIV int mso_read_buffer(struct sr_dev_inst *sdi); -SR_PRIV int mso_arm(struct sr_dev_inst *sdi); +SR_PRIV int mso_arm(const struct sr_dev_inst *sdi); SR_PRIV int mso_force_capture(struct sr_dev_inst *sdi); -SR_PRIV int mso_dac_out(struct sr_dev_inst *sdi, uint16_t val); +SR_PRIV int mso_dac_out(const struct sr_dev_inst *sdi, uint16_t val); SR_PRIV inline uint16_t mso_calc_raw_from_mv(struct dev_context *devc); SR_PRIV int mso_reset_fsm(struct sr_dev_inst *sdi); SR_PRIV int mso_toggle_led(struct sr_dev_inst *sdi, int state); -SR_PRIV int mso_configure_probes(const struct sr_dev_inst *sdi); +SR_PRIV int mso_configure_channels(const struct sr_dev_inst *sdi); SR_PRIV void stop_acquisition(const struct sr_dev_inst *sdi); -/* serial protocol */ -#define mso_trans(a, v) \ - (((v) & 0x3f) | (((v) & 0xc0) << 6) | (((a) & 0xf) << 8) | \ - ((~(v) & 0x20) << 1) | ((~(v) & 0x80) << 7)) - -SR_PRIV static const char mso_head[] = { 0x40, 0x4c, 0x44, 0x53, 0x7e }; -SR_PRIV static const char mso_foot[] = { 0x7e }; - /* bank agnostic registers */ #define REG_CTL2 15 @@ -191,7 +177,7 @@ struct rate_map { uint8_t slowmode; }; -static struct rate_map rate_map[] = { +static const struct rate_map rate_map[] = { { SR_MHZ(200), 0x0205, 0 }, { SR_MHZ(100), 0x0105, 0 }, { SR_MHZ(50), 0x0005, 0 }, @@ -215,7 +201,7 @@ static struct rate_map rate_map[] = { }; /* FIXME: Determine corresponding voltages */ -static uint16_t la_threshold_map[] = { +static const uint16_t la_threshold_map[] = { 0x8600, 0x8770, 0x88ff,