]>
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" | |
7048bb1f | 34 | #define MAX_INSTRUMENT_VERSIONS 8 |
8ab929d6 | 35 | |
1a46cc62 | 36 | #define RECEIVE_BUFFER_SIZE 4096 |
af3487ec | 37 | |
8ab929d6 | 38 | /* See Communication Interface User's Manual on p. 268 (:WAVeform:ALL:SEND?). */ |
1a46cc62 | 39 | #define DLM_MAX_FRAME_LENGTH 12500 |
8ab929d6 | 40 | /* See Communication Interface User's Manual on p. 269 (:WAVeform:SEND?). */ |
1a46cc62 UH |
41 | #define DLM_DIVISION_FOR_WORD_FORMAT 3200 |
42 | #define DLM_DIVISION_FOR_BYTE_FORMAT 12.5 | |
8ab929d6 | 43 | |
a9308652 | 44 | #define DLM_DIG_CHAN_INDEX_OFFS 32 |
6fd78a9f | 45 | |
8ab929d6 SA |
46 | enum trigger_slopes { |
47 | SLOPE_POSITIVE, | |
48 | SLOPE_NEGATIVE | |
49 | }; | |
50 | ||
f3c60fb6 SA |
51 | extern const char *dlm_trigger_slopes[3]; |
52 | extern const uint64_t dlm_timebases[36][2]; | |
53 | extern const uint64_t dlm_vdivs[17][2]; | |
54 | ||
8ab929d6 SA |
55 | struct scope_config { |
56 | const char *model_id[MAX_INSTRUMENT_VERSIONS]; | |
57 | const char *model_name[MAX_INSTRUMENT_VERSIONS]; | |
58 | const uint8_t analog_channels; | |
59 | const uint8_t digital_channels; | |
60 | const uint8_t pods; | |
61 | ||
62 | const char *(*analog_names)[]; | |
63 | const char *(*digital_names)[]; | |
64 | ||
8ab929d6 SA |
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 | ||
8ab929d6 SA |
71 | const uint8_t num_xdivs; |
72 | const uint8_t num_ydivs; | |
8ab929d6 SA |
73 | }; |
74 | ||
75 | struct analog_channel_state { | |
76 | int coupling; | |
77 | ||
78 | int vdiv; | |
79 | float vertical_offset, waveform_range, waveform_offset; | |
80 | ||
81 | gboolean state; | |
82 | }; | |
83 | ||
84 | struct scope_state { | |
85 | struct analog_channel_state *analog_states; | |
86 | gboolean *digital_states; | |
87 | gboolean *pod_states; | |
88 | ||
89 | int timebase; | |
90 | float horiz_triggerpos; | |
91 | ||
92 | int trigger_source; | |
93 | int trigger_slope; | |
94 | uint64_t sample_rate; | |
af3487ec | 95 | uint32_t samples_per_frame; |
8ab929d6 SA |
96 | }; |
97 | ||
98 | /** Private, per-device-instance driver context. */ | |
99 | struct dev_context { | |
329733d9 | 100 | const void *model_config; |
8ab929d6 SA |
101 | void *model_state; |
102 | ||
103 | struct sr_channel_group **analog_groups; | |
104 | struct sr_channel_group **digital_groups; | |
105 | ||
106 | GSList *enabled_channels; | |
107 | GSList *current_channel; | |
108 | uint64_t num_frames; | |
109 | ||
110 | uint64_t frame_limit; | |
af3487ec SA |
111 | |
112 | char receive_buffer[RECEIVE_BUFFER_SIZE]; | |
113 | gboolean data_pending; | |
8ab929d6 SA |
114 | }; |
115 | ||
c65a021c SA |
116 | SR_PRIV int dlm_channel_state_set(const struct sr_dev_inst *sdi, |
117 | const int ch_index, gboolean state); | |
8ab929d6 | 118 | SR_PRIV int dlm_data_request(const struct sr_dev_inst *sdi); |
8ab929d6 SA |
119 | SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index); |
120 | SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index); | |
121 | SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data); | |
8ab929d6 SA |
122 | SR_PRIV void dlm_scope_state_destroy(struct scope_state *state); |
123 | SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi); | |
124 | SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi); | |
af3487ec SA |
125 | SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi); |
126 | ||
10763937 | 127 | #endif |