]>
Commit | Line | Data |
---|---|---|
c527132a SBO |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2018 Sven Bursch-Osewold <sb_git@bursch.com> | |
ab3e9c8a | 5 | * Copyright (C) 2019 King Kévin <kingkevin@cuvoodoo.info> |
c527132a SBO |
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_ZKETECH_EBD_USB_PROTOCOL_H | |
22 | #define LIBSIGROK_HARDWARE_ZKETECH_EBD_USB_PROTOCOL_H | |
23 | ||
24 | #include <stdint.h> | |
25 | #include <glib.h> | |
26 | #include <libsigrok/libsigrok.h> | |
27 | #include "libsigrok-internal.h" | |
28 | ||
29 | #define LOG_PREFIX "zketech-ebd-usb" | |
30 | ||
ab3e9c8a | 31 | #define MSG_MAX_LEN 19 |
ec4806dc | 32 | #define MSG_FRAME_BEGIN 0xfa |
ec4806dc | 33 | #define MSG_FRAME_END 0xf8 |
9890fb1f | 34 | |
c527132a | 35 | struct dev_context { |
9890fb1f SBO |
36 | struct sr_sw_limits limits; |
37 | GMutex rw_mutex; | |
38 | float current_limit; | |
4df6f174 | 39 | float uvc_threshold; |
9890fb1f SBO |
40 | gboolean running; |
41 | gboolean load_activated; | |
c527132a SBO |
42 | }; |
43 | ||
9890fb1f | 44 | /* Communication via serial. */ |
4df6f174 FS |
45 | SR_PRIV int ebd_read_message(struct sr_serial_dev_inst *serial, size_t length, |
46 | uint8_t *buf); | |
9890fb1f SBO |
47 | |
48 | /* Commands. */ | |
4df6f174 FS |
49 | SR_PRIV int ebd_init(struct sr_serial_dev_inst *serial, |
50 | struct dev_context *devc); | |
51 | SR_PRIV int ebd_loadstart(struct sr_serial_dev_inst *serial, | |
52 | struct dev_context *devc); | |
330a32b2 | 53 | SR_PRIV int ebd_receive_data(int fd, int revents, void *cb_data); |
4df6f174 FS |
54 | SR_PRIV int ebd_stop(struct sr_serial_dev_inst *serial, |
55 | struct dev_context *devc); | |
56 | SR_PRIV int ebd_loadtoggle(struct sr_serial_dev_inst *serial, | |
57 | struct dev_context *devc); | |
9890fb1f SBO |
58 | |
59 | /* Configuration. */ | |
330a32b2 UH |
60 | SR_PRIV int ebd_get_current_limit(const struct sr_dev_inst *sdi, float *current); |
61 | SR_PRIV int ebd_set_current_limit(const struct sr_dev_inst *sdi, float current); | |
4df6f174 FS |
62 | SR_PRIV int ebd_get_uvc_threshold(const struct sr_dev_inst *sdi, float *voltage); |
63 | SR_PRIV int ebd_set_uvc_threshold(const struct sr_dev_inst *sdi, float voltage); | |
330a32b2 | 64 | SR_PRIV gboolean ebd_current_is0(struct dev_context *devc); |
9890fb1f | 65 | |
c527132a | 66 | #endif |