]> sigrok.org Git - libsigrok.git/blame - src/hardware/manson-hcs-3xxx/protocol.h
Remove some unneeded double-spaces.
[libsigrok.git] / src / hardware / manson-hcs-3xxx / protocol.h
CommitLineData
8f4e922f
UH
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2014 Uwe Hermann <uwe@hermann-uwe.de>
25abc8dd 5 * Copyright (C) 2014 Matthias Heidbrink <m-sigrok@heidbrink.biz>
8f4e922f
UH
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
d9251a2c
UH
22/**
23 * @file
24 *
25 * <em>Manson HCS-3xxx Series</em> power supply driver
26 *
27 * @internal
28 */
9740d9bf 29
8f4e922f
UH
30#ifndef LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
31#define LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H
32
33#include <stdint.h>
b5e92647
UH
34#include <string.h>
35#include <math.h>
8f4e922f 36#include <glib.h>
c1aae900 37#include <libsigrok/libsigrok.h>
8f4e922f
UH
38#include "libsigrok-internal.h"
39
40#define LOG_PREFIX "manson-hcs-3xxx"
41
b5e92647 42enum {
25abc8dd
MH
43 MANSON_HCS_3100,
44 MANSON_HCS_3102,
45 MANSON_HCS_3104,
46 MANSON_HCS_3150,
b5e92647
UH
47 MANSON_HCS_3200,
48 MANSON_HCS_3202,
49 MANSON_HCS_3204,
25abc8dd
MH
50 MANSON_HCS_3300,
51 MANSON_HCS_3302,
52 MANSON_HCS_3304,
53 MANSON_HCS_3400,
54 MANSON_HCS_3402,
55 MANSON_HCS_3404,
56 MANSON_HCS_3600,
57 MANSON_HCS_3602,
58 MANSON_HCS_3604,
b5e92647
UH
59};
60
9740d9bf 61/** Information on a single model. */
b5e92647 62struct hcs_model {
25abc8dd 63 int model_id; /**< Model info */
2c240774
UH
64 const char *name; /**< Model name */
65 const char *id; /**< Model ID, like delivered by interface */
25abc8dd
MH
66 double voltage[3]; /**< Min, max, step */
67 double current[3]; /**< Min, max, step */
b5e92647
UH
68};
69
8f4e922f
UH
70/** Private, per-device-instance driver context. */
71struct dev_context {
f3f19d11 72 const struct hcs_model *model; /**< Model information. */
b5e92647 73
a655b3fd 74 struct sr_sw_limits limits;
b5e92647
UH
75 int64_t req_sent_at;
76 gboolean reply_pending;
77
9740d9bf 78 float current; /**< Last current value [A] read from device. */
5437a0ad
MH
79 float current_max; /**< Output current set. */
80 float current_max_device;/**< Device-provided maximum output current. */
811d6255 81 float voltage; /**< Last voltage value [V] read from device. */
5437a0ad
MH
82 float voltage_max; /**< Output voltage set. */
83 float voltage_max_device;/**< Device-provided maximum output voltage. */
9740d9bf
MH
84 gboolean cc_mode; /**< Device is in constant current mode (otherwise constant voltage). */
85
86 gboolean output_enabled; /**< Is the output enabled? */
b5e92647
UH
87
88 char buf[50];
89 int buflen;
8f4e922f
UH
90};
91
9740d9bf 92SR_PRIV int hcs_parse_volt_curr_mode(struct sr_dev_inst *sdi, char **tokens);
c442ffda 93SR_PRIV int hcs_read_reply(struct sr_serial_dev_inst *serial, int lines, char *buf, int buflen);
9740d9bf 94SR_PRIV int hcs_send_cmd(struct sr_serial_dev_inst *serial, const char *cmd, ...);
b5e92647 95SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data);
8f4e922f
UH
96
97#endif