2 * This file is part of the libsigrok project.
4 * Copyright (C) 2015 Bartosz Golaszewski <bgolaszewski@baylibre.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBSIGROK_HARDWARE_BAYLIBRE_ACME_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_BAYLIBRE_ACME_PROTOCOL_H
26 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
29 #define LOG_PREFIX "baylibre-acme"
31 /* We support up to 8 energy/temperature probes. */
35 * Temperature probes can be connected to the last four ports on the
36 * ACME cape. When scanning, first look for temperature probes starting
39 #define TEMP_PRB_START_INDEX 4
41 #define ENRG_PROBE_NAME "ina226"
42 #define TEMP_PROBE_NAME "tmp435"
44 /* For the user we number the probes starting from 1. */
45 #define PROBE_NUM(n) ((n) + 1)
52 /** Private, per-device-instance driver context. */
55 uint64_t limit_samples;
58 uint32_t num_channels;
59 uint64_t samples_read;
60 uint64_t samples_missed;
62 int64_t last_sample_fin;
67 SR_PRIV uint8_t bl_acme_get_enrg_addr(int index);
68 SR_PRIV uint8_t bl_acme_get_temp_addr(int index);
70 SR_PRIV gboolean bl_acme_is_sane(void);
72 SR_PRIV gboolean bl_acme_detect_probe(unsigned int addr,
73 int prb_num, const char *prb_name);
74 SR_PRIV gboolean bl_acme_register_probe(struct sr_dev_inst *sdi, int type,
75 unsigned int addr, int prb_num);
77 SR_PRIV int bl_acme_get_probe_type(const struct sr_channel_group *cg);
78 SR_PRIV int bl_acme_probe_has_pws(const struct sr_channel_group *cg);
80 SR_PRIV void bl_acme_maybe_set_update_interval(const struct sr_dev_inst *sdi,
83 SR_PRIV int bl_acme_get_shunt(const struct sr_channel_group *cg,
85 SR_PRIV int bl_acme_set_shunt(const struct sr_channel_group *cg,
87 SR_PRIV int bl_acme_read_power_state(const struct sr_channel_group *cg,
89 SR_PRIV int bl_acme_set_power_off(const struct sr_channel_group *cg,
92 SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data);
94 SR_PRIV int bl_acme_open_channel(struct sr_channel *ch);
96 SR_PRIV void bl_acme_close_channel(struct sr_channel *ch);