X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fsysclk-lwla%2Fprotocol.h;h=1e353ad6a36b9d4344d98c0f737da8e922ecabc7;hb=0812c40e361c9a75f3b4ef318a57ce8ba0479fa1;hp=21bfe72994629ce293328e28066f373dbd6d7d74;hpb=60e2fa0a03f689bf1e04f38e91473b8c231c4e26;p=libsigrok.git diff --git a/hardware/sysclk-lwla/protocol.h b/hardware/sysclk-lwla/protocol.h index 21bfe729..1e353ad6 100644 --- a/hardware/sysclk-lwla/protocol.h +++ b/hardware/sysclk-lwla/protocol.h @@ -20,7 +20,6 @@ #ifndef LIBSIGROK_HARDWARE_SYSCLK_LWLA_PROTOCOL_H #define LIBSIGROK_HARDWARE_SYSCLK_LWLA_PROTOCOL_H -/* Message logging helpers with subsystem-specific prefix string. */ #define LOG_PREFIX "sysclk-lwla" #include "lwla.h" @@ -38,13 +37,16 @@ #define USB_INTERFACE 0 #define USB_TIMEOUT 3000 /* ms */ -#define NUM_PROBES 34 -#define TRIGGER_TYPES "01fr" +#define NUM_CHANNELS 34 + +/* Bit mask covering all 34 channels. + */ +#define ALL_CHANNELS_MASK (((uint64_t)1 << NUM_CHANNELS) - 1) /** Unit and packet size for the sigrok logic datafeed. */ -#define UNIT_SIZE ((NUM_PROBES + 7) / 8) -#define PACKET_SIZE (10000 * UNIT_SIZE) /* bytes */ +#define UNIT_SIZE ((NUM_CHANNELS + 7) / 8) +#define PACKET_LENGTH 10000 /* units */ /** Size of the acquisition buffer in device memory units. */ @@ -65,21 +67,21 @@ */ #define READ_CHUNK_LEN (28 * 8) -/** Calculate the required buffer size in 16-bit units for reading a given +/** Calculate the required buffer size in 32-bit units for reading a given * number of device memory words. Rounded to a multiple of 8 device words. */ -#define LWLA1034_MEMBUF_LEN(count) (((count) + 7) / 8 * 18) +#define LWLA1034_MEMBUF_LEN(count) (((count) + 7) / 8 * 9) /** Maximum number of 16-bit words sent at a time during acquisition. * Used for allocating the libusb transfer buffer. */ #define MAX_ACQ_SEND_WORDS 8 /* 5 for memory read request plus stuffing */ -/** Maximum number of 16-bit words received at a time during acquisition. +/** Maximum number of 32-bit words received at a time during acquisition. * Round to the next multiple of the endpoint buffer size to avoid nasty * transfer overflow conditions on hiccups. */ -#define MAX_ACQ_RECV_WORDS ((READ_CHUNK_LEN / 4 * 9 + 255) / 256 * 256) +#define MAX_ACQ_RECV_LEN ((READ_CHUNK_LEN / 8 * 9 + 127) / 128 * 128) /** Maximum length of a register write sequence. */ @@ -89,13 +91,42 @@ */ #define DEFAULT_SAMPLERATE SR_MHZ(125) -/** LWLA clock sources. +/** Maximum configurable sample count limit. + */ +#define MAX_LIMIT_SAMPLES (UINT64_C(1) << 48) + +/** Maximum configurable capture duration in milliseconds. + */ +#define MAX_LIMIT_MSEC (UINT64_C(1) << 32) + +/** LWLA1034 FPGA clock configurations. + */ +enum clock_config { + CONF_CLOCK_NONE, + CONF_CLOCK_INT, + CONF_CLOCK_EXT_RISE, + CONF_CLOCK_EXT_FALL, +}; + +/** Available clock sources. */ enum clock_source { - CLOCK_SOURCE_NONE, - CLOCK_SOURCE_INT, - CLOCK_SOURCE_EXT_RISE, - CLOCK_SOURCE_EXT_FALL, + CLOCK_INTERNAL, + CLOCK_EXT_CLK, +}; + +/** Available trigger sources. + */ +enum trigger_source { + TRIGGER_CHANNELS = 0, + TRIGGER_EXT_TRG, +}; + +/** Available edge choices for the external clock and trigger inputs. + */ +enum signal_edge { + EDGE_POSITIVE = 0, + EDGE_NEGATIVE, }; /** LWLA device states. @@ -133,10 +164,15 @@ struct acquisition_state { uint64_t sample; uint64_t run_len; - /** Number of samples acquired so far. */ - uint64_t captured_samples; + /** Maximum number of samples to process. */ + uint64_t samples_max; /** Number of samples sent to the session bus. */ - uint64_t transferred_samples; + uint64_t samples_done; + + /** Maximum duration of capture, in milliseconds. */ + uint64_t duration_max; + /** Running capture duration since trigger event. */ + uint64_t duration_now; /** Capture memory fill level. */ size_t mem_addr_fill; @@ -145,7 +181,7 @@ struct acquisition_state { size_t mem_addr_next; size_t mem_addr_stop; - size_t out_offset; + size_t out_index; struct libusb_transfer *xfer_in; struct libusb_transfer *xfer_out; @@ -154,12 +190,15 @@ struct acquisition_state { enum rle_state rle; - /* Payload data buffers for outgoing and incoming transfers. */ + /** Whether to bypass the clock divider. */ + gboolean bypass_clockdiv; + + /* Payload data buffers for incoming and outgoing transfers. */ + uint32_t xfer_buf_in[MAX_ACQ_RECV_LEN]; uint16_t xfer_buf_out[MAX_ACQ_SEND_WORDS]; - uint16_t xfer_buf_in[MAX_ACQ_RECV_WORDS]; /* Payload buffer for sigrok logic packets. */ - uint8_t out_packet[PACKET_SIZE]; + uint8_t out_packet[PACKET_LENGTH * UNIT_SIZE]; }; /** Private, per-device-instance driver context. @@ -168,6 +207,9 @@ struct dev_context { /** The samplerate selected by the user. */ uint64_t samplerate; + /** The maximimum sampling duration, in milliseconds. */ + uint64_t limit_msec; + /** The maximimum number of samples to acquire. */ uint64_t limit_samples; @@ -186,10 +228,18 @@ struct dev_context { enum device_state state; - /** The currently configured clock source of the device. */ - enum clock_source cur_clock_source; - /** The clock source selected by the user. */ - enum clock_source selected_clock_source; + /** The currently active clock configuration of the device. */ + enum clock_config cur_clock_config; + + /** Clock source configuration setting. */ + enum clock_source cfg_clock_source; + /** Clock edge configuration setting. */ + enum signal_edge cfg_clock_edge; + + /** Trigger source configuration setting. */ + enum trigger_source cfg_trigger_source; + /** Trigger slope configuration setting. */ + enum signal_edge cfg_trigger_slope; /* Indicates that stopping the acquisition is currently in progress. */ gboolean stopping_in_progress; @@ -202,7 +252,8 @@ SR_PRIV struct acquisition_state *lwla_alloc_acquisition_state(void); SR_PRIV void lwla_free_acquisition_state(struct acquisition_state *acq); SR_PRIV int lwla_init_device(const struct sr_dev_inst *sdi); -SR_PRIV int lwla_set_clock_source(const struct sr_dev_inst *sdi); +SR_PRIV int lwla_convert_trigger(const struct sr_dev_inst *sdi); +SR_PRIV int lwla_set_clock_config(const struct sr_dev_inst *sdi); SR_PRIV int lwla_setup_acquisition(const struct sr_dev_inst *sdi); SR_PRIV int lwla_start_acquisition(const struct sr_dev_inst *sdi); SR_PRIV int lwla_abort_acquisition(const struct sr_dev_inst *sdi);