]> sigrok.org Git - libsigrok.git/blame - src/hardware/zketech-ebd-usb/protocol.h
zketech-ebd-usb: First version of the driver.
[libsigrok.git] / src / hardware / zketech-ebd-usb / protocol.h
CommitLineData
c527132a
SBO
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2018 Sven Bursch-Osewold <sb_git@bursch.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_ZKETECH_EBD_USB_PROTOCOL_H
21#define LIBSIGROK_HARDWARE_ZKETECH_EBD_USB_PROTOCOL_H
22
23#include <stdint.h>
24#include <glib.h>
25#include <libsigrok/libsigrok.h>
26#include "libsigrok-internal.h"
27
28#define LOG_PREFIX "zketech-ebd-usb"
29
9890fb1f
SBO
30#define MSGLEN 19
31#define MSGCHECKSUMPOS 17
32#define MSGFRAMEBEGIN 0xfa
33#define MSGFRAMEBEGINPOS 0
34#define MSGFRAMEEND 0xf8
35#define MSGFRAMEENDPOS 18
36
c527132a 37struct dev_context {
9890fb1f
SBO
38 struct sr_sw_limits limits;
39 GMutex rw_mutex;
40 float current_limit;
41 gboolean running;
42 gboolean load_activated;
c527132a
SBO
43};
44
9890fb1f
SBO
45SR_PRIV float zketech_ebd_usb_value_decode(uint8_t b1, uint8_t b2, float divisor);
46SR_PRIV void zketech_ebd_usb_value_encode(float voltage, uint8_t *b1, uint8_t *b2, float divisor);
47
48/* Communication via serial. */
49SR_PRIV int zketech_ebd_usb_send(struct sr_serial_dev_inst *serial, uint8_t buf[], size_t count);
50SR_PRIV int zketech_ebd_usb_sendcfg(struct sr_serial_dev_inst *serial, struct dev_context *devc);
51SR_PRIV int zketech_ebd_usb_read_chars(struct sr_serial_dev_inst *serial,
52 int count, uint8_t *buf);
53
54/* Commands. */
55SR_PRIV int zketech_ebd_usb_init(struct sr_serial_dev_inst *serial, struct dev_context *devc);
56SR_PRIV int zketech_ebd_usb_loadstart(struct sr_serial_dev_inst *serial, struct dev_context *devc);
c527132a 57SR_PRIV int zketech_ebd_usb_receive_data(int fd, int revents, void *cb_data);
9890fb1f
SBO
58SR_PRIV int zketech_ebd_usb_stop(struct sr_serial_dev_inst *serial, struct dev_context *devc);
59SR_PRIV int zketech_ebd_usb_loadstop(struct sr_serial_dev_inst *serial, struct dev_context *devc);
60
61/* Configuration. */
62SR_PRIV int zketech_ebd_usb_get_current_limit(const struct sr_dev_inst *sdi,
63 float *current);
64SR_PRIV int zketech_ebd_usb_set_current_limit(const struct sr_dev_inst *sdi,
65 float current);
66SR_PRIV gboolean zketech_ebd_usb_current_is0(struct dev_context *devc);
67
68SR_PRIV void zketech_ebd_usb_buffer_debug(const char *message, uint8_t buf[], size_t count);
c527132a
SBO
69
70#endif