X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fsaleae-logic16%2Fprotocol.h;h=8a1ded823900e7ae41c194f355d1a73b5f07fb15;hb=f2a189f0a7737d6abc1140b61a554c4a9f1efb70;hp=a3ae1f82146e2d6372c685ff88d90d9ce229781a;hpb=c463dcf06cdeb7f6ec0d2bafda707cce3a486bf0;p=libsigrok.git diff --git a/hardware/saleae-logic16/protocol.h b/hardware/saleae-logic16/protocol.h index a3ae1f82..8a1ded82 100644 --- a/hardware/saleae-logic16/protocol.h +++ b/hardware/saleae-logic16/protocol.h @@ -2,6 +2,8 @@ * This file is part of the libsigrok project. * * Copyright (C) 2013 Marcus Comstedt + * Copyright (C) 2013 Bert Vermeulen + * Copyright (C) 2012 Joel Holdsworth * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,27 +27,65 @@ #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with subsystem-specific prefix string. */ -#define LOG_PREFIX "saleae-logic16: " -#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args) -#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args) -#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args) -#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args) -#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args) -#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args) +#define LOG_PREFIX "saleae-logic16" + +enum voltage_range { + VOLTAGE_RANGE_UNKNOWN, + VOLTAGE_RANGE_18_33_V, /* 1.8V and 3.3V logic */ + VOLTAGE_RANGE_5_V, /* 5V logic */ +}; /** Private, per-device-instance driver context. */ struct dev_context { - /* Model-specific information */ + /* + * Since we can't keep track of a Logic16 device after upgrading + * the firmware (it renumerates into a different device address + * after the upgrade) this is like a global lock. No device will open + * until a proper delay after the last device was upgraded. + */ + int64_t fw_updated; + + /** The currently configured samplerate of the device. */ + uint64_t cur_samplerate; + + /** Maximum number of samples to capture, if nonzero. */ + uint64_t limit_samples; + + /** The currently configured input voltage of the device. */ + enum voltage_range cur_voltage_range; + + /** The input voltage selected by the user. */ + enum voltage_range selected_voltage_range; - /* Acquisition settings */ + /** Channels to use. */ + uint16_t cur_channels; - /* Operational state */ + /* EEPROM data from address 8. */ + uint8_t eeprom_data[8]; - /* Temporary state across callbacks */ + int64_t sent_samples; + int submitted_transfers; + int empty_transfer_count; + int num_channels; + int cur_channel; + uint16_t channel_masks[16]; + uint16_t channel_data[16]; + uint8_t *convbuffer; + size_t convbuffer_size; + struct soft_trigger_logic *stl; + gboolean trigger_fired; + void *cb_data; + unsigned int num_transfers; + struct libusb_transfer **transfers; + struct sr_context *ctx; }; -SR_PRIV int saleae_logic16_receive_data(int fd, int revents, void *cb_data); +SR_PRIV int logic16_setup_acquisition(const struct sr_dev_inst *sdi, + uint64_t samplerate, uint16_t channels); +SR_PRIV int logic16_start_acquisition(const struct sr_dev_inst *sdi); +SR_PRIV int logic16_abort_acquisition(const struct sr_dev_inst *sdi); +SR_PRIV int logic16_init_device(const struct sr_dev_inst *sdi); +SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer); #endif