X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdevantech-eth008%2Fprotocol.h;h=7a687c7149076d03d46a4a0c3f9f7d79183f4a7a;hb=204dd31fa1074a78fbe3bf04208776a4a3615a1c;hp=ecf1656389c326579c058255f5fac6c45f0e913b;hpb=c12ca361e724ed1e04c659420d74dd68efe345a9;p=libsigrok.git diff --git a/src/hardware/devantech-eth008/protocol.h b/src/hardware/devantech-eth008/protocol.h index ecf16563..7a687c71 100644 --- a/src/hardware/devantech-eth008/protocol.h +++ b/src/hardware/devantech-eth008/protocol.h @@ -20,16 +20,64 @@ #ifndef LIBSIGROK_HARDWARE_DEVANTECH_ETH008_PROTOCOL_H #define LIBSIGROK_HARDWARE_DEVANTECH_ETH008_PROTOCOL_H -#include #include #include +#include + #include "libsigrok-internal.h" #define LOG_PREFIX "devantech-eth008" +/* + * See developer notes in the protocol.c source file for details on the + * feature set and communication protocol variants across the series. + * This 'model' description tells their discriminating properties apart. + */ +struct devantech_eth008_model { + uint8_t code; /**!< model ID */ + const char *name; /**!< model name */ + size_t ch_count_do; /**!< digital output channel count */ + size_t ch_count_di; /**!< digital input channel count */ + size_t ch_count_ai; /**!< analog input channel count */ + uint8_t min_serno_fw; /**!< min FW version to get serial nr */ + size_t width_do; /**!< digital output image width */ + size_t width_di; /**!< digital input image width */ + uint32_t mask_do_missing; /**!< missing digital output channels */ +}; + +struct channel_group_context { + size_t index; + size_t number; + enum devantech_eth008_channel_type { + DV_CH_DIGITAL_OUTPUT, + DV_CH_DIGITAL_INPUT, + DV_CH_ANALOG_INPUT, + DV_CH_SUPPLY_VOLTAGE, + } ch_type; +}; + struct dev_context { + uint8_t model_code, hardware_version, firmware_version; + const struct devantech_eth008_model *model; + uint32_t mask_do; + uint32_t curr_do; + uint32_t curr_di; }; -SR_PRIV int devantech_eth008_receive_data(int fd, int revents, void *cb_data); +SR_PRIV int devantech_eth008_get_model(struct sr_serial_dev_inst *serial, + uint8_t *model_code, uint8_t *hw_version, uint8_t *fw_version); +SR_PRIV int devantech_eth008_get_serno(struct sr_serial_dev_inst *serial, + char *text_buffer, size_t text_length); +SR_PRIV int devantech_eth008_cache_state(const struct sr_dev_inst *sdi); +SR_PRIV int devantech_eth008_query_do(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, gboolean *on); +SR_PRIV int devantech_eth008_setup_do(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, gboolean on); +SR_PRIV int devantech_eth008_query_di(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, gboolean *on); +SR_PRIV int devantech_eth008_query_ai(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, uint16_t *adc_value); +SR_PRIV int devantech_eth008_query_supply(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, uint16_t *millivolts); #endif