X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbaylibre-acme%2Fprotocol.h;h=3972aa2cc6da6326fb1d5905a40e958dd7ed9668;hb=e742b88f9aef970f8d6755858c930a47f79782fa;hp=599fdd98c27d179eedd6159d3a475e0ad0f62169;hpb=dfaee1de1711cdfba7bd780b448188819691a2db;p=libsigrok.git diff --git a/src/hardware/baylibre-acme/protocol.h b/src/hardware/baylibre-acme/protocol.h index 599fdd98..3972aa2c 100644 --- a/src/hardware/baylibre-acme/protocol.h +++ b/src/hardware/baylibre-acme/protocol.h @@ -22,23 +22,74 @@ #include #include +#include #include "libsigrok.h" #include "libsigrok-internal.h" #define LOG_PREFIX "baylibre-acme" +/* We support up to 8 energy/temperature probes. */ +#define MAX_PROBES 8 + +/* + * Temperature probes can be connected to the last four ports on the + * ACME cape. When scanning, first look for temperature probes starting + * from this index. + */ +#define TEMP_PRB_START_INDEX 4 + +#define ENRG_PROBE_NAME "ina226" +#define TEMP_PROBE_NAME "tmp435" + +/* For the user we number the probes starting from 1. */ +#define PROBE_NUM(n) ((n) + 1) + +enum probe_type { + PROBE_ENRG = 1, + PROBE_TEMP, +}; + +enum channel_type { + ENRG_PWR = 1, + ENRG_CURR, + ENRG_VOL, + TEMP_IN, + TEMP_OUT, +}; + /** Private, per-device-instance driver context. */ struct dev_context { - /* Model-specific information */ + uint64_t samplerate; + uint64_t limit_samples; + uint64_t limit_msec; - /* Acquisition settings */ + uint32_t num_channels; + uint64_t samples_read; + int64_t start_time; + int64_t last_sample_fin; + int pipe_fds[2]; + GIOChannel *channel; +}; - /* Operational state */ +SR_PRIV uint8_t bl_acme_get_enrg_addr(int index); +SR_PRIV uint8_t bl_acme_get_temp_addr(int index); - /* Temporary state across callbacks */ +SR_PRIV gboolean bl_acme_is_sane(void); -}; +SR_PRIV gboolean bl_acme_detect_probe(unsigned int addr, + int prb_num, const char *prb_name); +SR_PRIV gboolean bl_acme_register_probe(struct sr_dev_inst *sdi, int type, + unsigned int addr, int prb_num); + +SR_PRIV int bl_acme_get_shunt(const struct sr_channel_group *cg, + uint64_t *shunt); +SR_PRIV int bl_acme_set_shunt(const struct sr_channel_group *cg, + uint64_t shunt); +SR_PRIV int bl_acme_read_power_state(const struct sr_channel_group *cg, + gboolean *off); +SR_PRIV int bl_acme_set_power_off(const struct sr_channel_group *cg, + gboolean off); -SR_PRIV int baylibre_acme_receive_data(int fd, int revents, void *cb_data); +SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data); #endif