X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpce-322a%2Fprotocol.h;h=338e37e3af454b7d676194eb685d88814ad64544;hb=49f7cb24259851b1b8b5c5fc863343c90a7366a4;hp=679d2a041daefb1d4ae66eaf40d3aee6073be690;hpb=5a2c71ccd7c46b18583dd068a8508e9d93ed9190;p=libsigrok.git diff --git a/src/hardware/pce-322a/protocol.h b/src/hardware/pce-322a/protocol.h index 679d2a04..338e37e3 100644 --- a/src/hardware/pce-322a/protocol.h +++ b/src/hardware/pce-322a/protocol.h @@ -2,6 +2,7 @@ * This file is part of the libsigrok project. * * Copyright (C) 2016 George Hopkins + * Copyright (C) 2016 Matthieu Guillaumin * * 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 @@ -28,6 +29,8 @@ #define LOG_PREFIX "pce-322a" #define BUFFER_SIZE 13 +#define MEM_USAGE_BUFFER_SIZE 9 +#define MEM_DATA_BUFFER_SIZE 11 enum { CMD_CONNECT = 0xacff, @@ -53,25 +56,44 @@ enum { MEAS_RANGE_80_130 = 3, }; -/** Private, per-device-instance driver context. */ +enum { + DATA_SOURCE_LIVE, + DATA_SOURCE_MEMORY, +}; + +enum { + MEM_STATE_REQUEST_MEMORY_USAGE, + MEM_STATE_GET_MEMORY_USAGE, + MEM_STATE_REQUEST_MEMORY_BLOCK, + MEM_STATE_GET_MEMORY_BLOCK, +}; + struct dev_context { - /* Model-specific information */ uint64_t cur_mqflags; uint8_t cur_meas_range; - /* Acquisition settings */ + uint8_t cur_data_source; uint64_t limit_samples; - /* Operational state */ uint64_t num_samples; - /* Temporary state across callbacks */ + /* Memory reading state */ + uint8_t memory_state; /* State for requesting memory usage before memory blocks. */ + uint16_t memory_block_usage; /* Store number of memory blocks used. */ + uint8_t memory_last_block_usage; /* Store size of last memory block. */ + uint16_t memory_block_counter; /* Number of memory blocks retrieved so far. */ + uint8_t memory_block_cursor; /* Number of bytes retrieved in current memory block. */ + uint8_t buffer[BUFFER_SIZE]; int buffer_len; + int buffer_skip; /* Number of bytes to skip in memory mode. */ }; SR_PRIV int pce_322a_connect(const struct sr_dev_inst *sdi); SR_PRIV int pce_322a_disconnect(const struct sr_dev_inst *sdi); +SR_PRIV int pce_322a_memory_status(const struct sr_dev_inst *sdi); +SR_PRIV int pce_322a_memory_clear(const struct sr_dev_inst *sdi); +SR_PRIV int pce_322a_memory_block(const struct sr_dev_inst *sdi, uint16_t memblk); SR_PRIV int pce_322a_receive_data(int fd, int revents, void *cb_data); SR_PRIV uint64_t pce_322a_weight_freq_get(const struct sr_dev_inst *sdi); SR_PRIV int pce_322a_weight_freq_set(const struct sr_dev_inst *sdi, uint64_t freqw);