]>
Commit | Line | Data |
---|---|---|
06a3e78a DJ |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2013 poljar (Damir Jelić) <poljarinho@gmail.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_HAMEG_HMO_PROTOCOL_H | |
21 | #define LIBSIGROK_HARDWARE_HAMEG_HMO_PROTOCOL_H | |
22 | ||
06a3e78a | 23 | #include <glib.h> |
13f2b9d7 DJ |
24 | #include <stdint.h> |
25 | #include <string.h> | |
c1aae900 | 26 | #include <libsigrok/libsigrok.h> |
06a3e78a DJ |
27 | #include "libsigrok-internal.h" |
28 | ||
3544f848 | 29 | #define LOG_PREFIX "hameg-hmo" |
06a3e78a | 30 | |
a12456f1 GT |
31 | #define DIGITAL_CHANNELS_PER_POD 8 |
32 | ||
33 | #define MAX_INSTRUMENT_VERSIONS 10 | |
34 | #define MAX_COMMAND_SIZE 128 | |
35 | #define MAX_ANALOG_CHANNEL_COUNT 4 | |
36 | #define MAX_DIGITAL_CHANNEL_COUNT 16 | |
37 | #define MAX_DIGITAL_GROUP_COUNT 2 | |
13f2b9d7 | 38 | |
13f2b9d7 DJ |
39 | struct scope_config { |
40 | const char *name[MAX_INSTRUMENT_VERSIONS]; | |
41 | const uint8_t analog_channels; | |
42 | const uint8_t digital_channels; | |
a12456f1 | 43 | uint8_t digital_pods; |
13f2b9d7 DJ |
44 | |
45 | const char *(*analog_names)[]; | |
46 | const char *(*digital_names)[]; | |
47 | ||
f254bc4b BV |
48 | const uint32_t (*devopts)[]; |
49 | const uint8_t num_devopts; | |
13f2b9d7 | 50 | |
6b82c3e5 UH |
51 | const uint32_t (*devopts_cg_analog)[]; |
52 | const uint8_t num_devopts_cg_analog; | |
13f2b9d7 | 53 | |
e131be0a GT |
54 | const uint32_t (*devopts_cg_digital)[]; |
55 | const uint8_t num_devopts_cg_digital; | |
56 | ||
13f2b9d7 DJ |
57 | const char *(*coupling_options)[]; |
58 | const uint8_t num_coupling_options; | |
59 | ||
e131be0a GT |
60 | const char *(*logic_threshold)[]; |
61 | const uint8_t num_logic_threshold; | |
aac30633 | 62 | const gboolean logic_threshold_for_pod; |
e131be0a | 63 | |
13f2b9d7 DJ |
64 | const char *(*trigger_sources)[]; |
65 | const uint8_t num_trigger_sources; | |
66 | ||
67 | const char *(*trigger_slopes)[]; | |
692716f5 | 68 | const uint8_t num_trigger_slopes; |
13f2b9d7 DJ |
69 | |
70 | const uint64_t (*timebases)[][2]; | |
71 | const uint8_t num_timebases; | |
72 | ||
73 | const uint64_t (*vdivs)[][2]; | |
74 | const uint8_t num_vdivs; | |
75 | ||
29a9b1a0 GT |
76 | unsigned int num_xdivs; |
77 | const unsigned int num_ydivs; | |
13f2b9d7 DJ |
78 | |
79 | const char *(*scpi_dialect)[]; | |
80 | }; | |
81 | ||
82 | struct analog_channel_state { | |
83 | int coupling; | |
84 | ||
8de2dc3b | 85 | int vdiv; |
13f2b9d7 DJ |
86 | float vertical_offset; |
87 | ||
88 | gboolean state; | |
448e81b1 | 89 | char probe_unit; |
13f2b9d7 DJ |
90 | }; |
91 | ||
e131be0a GT |
92 | struct digital_pod_state { |
93 | gboolean state; | |
94 | ||
95 | int threshold; | |
96 | float user_threshold; | |
97 | }; | |
98 | ||
13f2b9d7 DJ |
99 | struct scope_state { |
100 | struct analog_channel_state *analog_channels; | |
101 | gboolean *digital_channels; | |
e131be0a | 102 | struct digital_pod_state *digital_pods; |
13f2b9d7 | 103 | |
8de2dc3b | 104 | int timebase; |
13f2b9d7 DJ |
105 | float horiz_triggerpos; |
106 | ||
107 | int trigger_source; | |
108 | int trigger_slope; | |
396af5ad | 109 | char trigger_pattern[MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT]; |
4fa4db2c | 110 | |
97a00074 GT |
111 | gboolean high_resolution; |
112 | gboolean peak_detection; | |
113 | ||
14a2f74d | 114 | uint64_t sample_rate; |
13f2b9d7 DJ |
115 | }; |
116 | ||
06a3e78a | 117 | struct dev_context { |
329733d9 | 118 | const void *model_config; |
13f2b9d7 | 119 | void *model_state; |
06a3e78a | 120 | |
562b7ae5 SA |
121 | struct sr_channel_group **analog_groups; |
122 | struct sr_channel_group **digital_groups; | |
06a3e78a | 123 | |
ba7dd8bb UH |
124 | GSList *enabled_channels; |
125 | GSList *current_channel; | |
d779dcac | 126 | uint64_t num_samples; |
13f2b9d7 | 127 | uint64_t num_frames; |
06a3e78a | 128 | |
d779dcac | 129 | uint64_t samples_limit; |
13f2b9d7 | 130 | uint64_t frame_limit; |
e06875b2 GS |
131 | |
132 | size_t pod_count; | |
133 | GByteArray *logic_data; | |
06a3e78a DJ |
134 | }; |
135 | ||
13f2b9d7 DJ |
136 | SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi); |
137 | SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi); | |
719eff68 | 138 | SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data); |
13f2b9d7 | 139 | |
719eff68 UH |
140 | SR_PRIV struct scope_state *hmo_scope_state_new(struct scope_config *config); |
141 | SR_PRIV void hmo_scope_state_free(struct scope_state *state); | |
142 | SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi); | |
14a2f74d | 143 | SR_PRIV int hmo_update_sample_rate(const struct sr_dev_inst *sdi); |
06a3e78a DJ |
144 | |
145 | #endif |