]>
Commit | Line | Data |
---|---|---|
10763937 SA |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2014 abraxa (Soeren Apel) <soeren@apelpie.net> | |
5 | * Based on the Hameg HMO driver by poljar (Damir Jelić) <poljarinho@gmail.com> | |
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 3 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, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #ifndef LIBSIGROK_HARDWARE_YOKOGAWA_DLM_PROTOCOL_H | |
22 | #define LIBSIGROK_HARDWARE_YOKOGAWA_DLM_PROTOCOL_H | |
23 | ||
24 | #include <glib.h> | |
25 | #include <stdint.h> | |
8ab929d6 | 26 | #include <stdlib.h> |
10763937 | 27 | #include <string.h> |
8ab929d6 | 28 | #include <math.h> |
10763937 SA |
29 | #include "libsigrok.h" |
30 | #include "libsigrok-internal.h" | |
8ab929d6 SA |
31 | #include "protocol_wrappers.h" |
32 | ||
33 | #define LOG_PREFIX "yokogawa-dlm" | |
34 | #define MAX_INSTRUMENT_VERSIONS 4 | |
35 | ||
af3487ec SA |
36 | #define RECEIVE_BUFFER_SIZE (4096) |
37 | ||
8ab929d6 SA |
38 | /* See Communication Interface User's Manual on p. 268 (:WAVeform:ALL:SEND?). */ |
39 | #define DLM_MAX_FRAME_LENGTH (12500) | |
40 | /* See Communication Interface User's Manual on p. 269 (:WAVeform:SEND?). */ | |
41 | #define DLM_DIVISION_FOR_WORD_FORMAT (3200) | |
42 | #define DLM_DIVISION_FOR_BYTE_FORMAT (12.5) | |
43 | ||
8ab929d6 SA |
44 | enum trigger_slopes { |
45 | SLOPE_POSITIVE, | |
46 | SLOPE_NEGATIVE | |
47 | }; | |
48 | ||
49 | struct scope_config { | |
50 | const char *model_id[MAX_INSTRUMENT_VERSIONS]; | |
51 | const char *model_name[MAX_INSTRUMENT_VERSIONS]; | |
52 | const uint8_t analog_channels; | |
53 | const uint8_t digital_channels; | |
54 | const uint8_t pods; | |
55 | ||
56 | const char *(*analog_names)[]; | |
57 | const char *(*digital_names)[]; | |
58 | ||
f254bc4b BV |
59 | const uint32_t (*devopts)[]; |
60 | const uint8_t num_devopts; | |
8ab929d6 | 61 | |
f254bc4b BV |
62 | const uint32_t (*analog_devopts)[]; |
63 | const uint8_t num_analog_devopts; | |
8ab929d6 SA |
64 | |
65 | const char *(*coupling_options)[]; | |
66 | const uint8_t num_coupling_options; | |
67 | ||
68 | const char *(*trigger_sources)[]; | |
69 | const uint8_t num_trigger_sources; | |
70 | ||
71 | const char *(*trigger_slopes)[]; | |
72 | ||
73 | const uint64_t (*timebases)[][2]; | |
74 | const uint8_t num_timebases; | |
75 | ||
76 | const uint64_t (*vdivs)[][2]; | |
77 | const uint8_t num_vdivs; | |
78 | ||
79 | const uint8_t num_xdivs; | |
80 | const uint8_t num_ydivs; | |
8ab929d6 SA |
81 | }; |
82 | ||
83 | struct analog_channel_state { | |
84 | int coupling; | |
85 | ||
86 | int vdiv; | |
87 | float vertical_offset, waveform_range, waveform_offset; | |
88 | ||
89 | gboolean state; | |
90 | }; | |
91 | ||
92 | struct scope_state { | |
93 | struct analog_channel_state *analog_states; | |
94 | gboolean *digital_states; | |
95 | gboolean *pod_states; | |
96 | ||
97 | int timebase; | |
98 | float horiz_triggerpos; | |
99 | ||
100 | int trigger_source; | |
101 | int trigger_slope; | |
102 | uint64_t sample_rate; | |
af3487ec | 103 | uint32_t samples_per_frame; |
8ab929d6 SA |
104 | }; |
105 | ||
106 | /** Private, per-device-instance driver context. */ | |
107 | struct dev_context { | |
329733d9 | 108 | const void *model_config; |
8ab929d6 SA |
109 | void *model_state; |
110 | ||
111 | struct sr_channel_group **analog_groups; | |
112 | struct sr_channel_group **digital_groups; | |
113 | ||
114 | GSList *enabled_channels; | |
115 | GSList *current_channel; | |
116 | uint64_t num_frames; | |
117 | ||
118 | uint64_t frame_limit; | |
af3487ec SA |
119 | |
120 | char receive_buffer[RECEIVE_BUFFER_SIZE]; | |
121 | gboolean data_pending; | |
8ab929d6 SA |
122 | }; |
123 | ||
124 | /*--- api.c -----------------------------------------------------------------*/ | |
125 | SR_PRIV int dlm_data_request(const struct sr_dev_inst *sdi); | |
126 | ||
127 | /*--- protocol.c ------------------------------------------------------------*/ | |
128 | SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index); | |
129 | SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index); | |
130 | SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data); | |
131 | ||
132 | SR_PRIV void dlm_scope_state_destroy(struct scope_state *state); | |
133 | SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi); | |
134 | SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi); | |
10763937 | 135 | |
af3487ec SA |
136 | SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi); |
137 | ||
10763937 | 138 | #endif |