]>
Commit | Line | Data |
---|---|---|
fa0d6afe BV |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2014 Bert Vermeulen <bert@biot.com> | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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/>. | |
18 | */ | |
19 | ||
20 | #ifndef LIBSIGROK_HARDWARE_ATTEN_PPS3XXX_PROTOCOL_H | |
21 | #define LIBSIGROK_HARDWARE_ATTEN_PPS3XXX_PROTOCOL_H | |
22 | ||
23 | #include <stdint.h> | |
24 | #include <glib.h> | |
25 | #include "libsigrok.h" | |
26 | #include "libsigrok-internal.h" | |
27 | ||
28 | /* Message logging helpers with subsystem-specific prefix string. */ | |
29 | #define LOG_PREFIX "atten-pps3xxx" | |
30 | ||
33c40990 BV |
31 | /* Packets to/from the device. */ |
32 | #define PACKET_SIZE 24 | |
33 | ||
34 | enum { | |
35 | PPS_3203T_3S, | |
36 | PPS_3203T_2S, | |
37 | PPS_3205T_3S, | |
38 | PPS_3205T_2S, | |
39 | PPS_3003S, | |
40 | PPS_3005S, | |
41 | }; | |
42 | ||
43 | /* Maximum number of output channels handled by this driver. */ | |
44 | #define MAX_CHANNELS 3 | |
45 | ||
46 | #define CHANMODE_INDEPENDENT 1 << 0 | |
47 | #define CHANMODE_SERIES 1 << 1 | |
48 | #define CHANMODE_PARALLEL 1 << 2 | |
49 | ||
50 | struct channel_spec { | |
51 | /* Min, max, step. */ | |
52 | gdouble voltage[3]; | |
53 | gdouble current[3]; | |
54 | }; | |
55 | ||
56 | struct pps_model { | |
57 | int modelid; | |
58 | char *name; | |
59 | int channel_modes; | |
60 | int num_channels; | |
61 | struct channel_spec channels[MAX_CHANNELS]; | |
62 | }; | |
63 | ||
64 | struct per_channel_config { | |
65 | /* Received from device. */ | |
66 | gdouble output_voltage_last; | |
67 | gdouble output_current_last; | |
68 | gboolean output_enabled; | |
69 | /* Set by frontend. */ | |
70 | gdouble output_voltage_max; | |
71 | gdouble output_current_max; | |
72 | gboolean output_enabled_set; | |
73 | }; | |
74 | ||
fa0d6afe BV |
75 | /** Private, per-device-instance driver context. */ |
76 | struct dev_context { | |
77 | /* Model-specific information */ | |
33c40990 | 78 | struct pps_model *model; |
fa0d6afe | 79 | |
33c40990 BV |
80 | /* Acquisition state */ |
81 | gboolean acquisition_running; | |
fa0d6afe BV |
82 | |
83 | /* Operational state */ | |
33c40990 BV |
84 | struct per_channel_config *config; |
85 | /* Received from device. */ | |
86 | int channel_mode; | |
87 | gboolean over_current_protection; | |
88 | /* Set by frontend. */ | |
89 | int channel_mode_set; | |
90 | gboolean over_current_protection_set; | |
fa0d6afe BV |
91 | |
92 | /* Temporary state across callbacks */ | |
33c40990 BV |
93 | uint8_t packet[PACKET_SIZE]; |
94 | int packet_size; | |
fa0d6afe BV |
95 | |
96 | }; | |
97 | ||
98 | SR_PRIV int atten_pps3xxx_receive_data(int fd, int revents, void *cb_data); | |
33c40990 BV |
99 | SR_PRIV void send_packet(const struct sr_dev_inst *sdi, uint8_t *packet); |
100 | SR_PRIV void send_config(const struct sr_dev_inst *sdi); | |
fa0d6afe BV |
101 | |
102 | #endif |