]> sigrok.org Git - libsigrok.git/blame - hardware/center-3xx/protocol.h
build: Portability fixes.
[libsigrok.git] / hardware / center-3xx / protocol.h
CommitLineData
4433145f
UH
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de>
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 2 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef LIBSIGROK_HARDWARE_CENTER_3XX_PROTOCOL_H
22#define LIBSIGROK_HARDWARE_CENTER_3XX_PROTOCOL_H
23
24#include <stdint.h>
4a8bbed7
UH
25#include <string.h>
26#include <ctype.h>
27#include <math.h>
4433145f
UH
28#include <glib.h>
29#include "libsigrok.h"
30#include "libsigrok-internal.h"
31
3544f848 32#define LOG_PREFIX "center-3xx"
4433145f 33
4a8bbed7
UH
34/* Note: When adding entries here, don't forget to update CENTER_DEV_COUNT. */
35enum {
36 CENTER_309,
37 VOLTCRAFT_K204,
38};
39
40#define CENTER_DEV_COUNT 2
41
42struct center_dev_info {
43 char *vendor;
44 char *device;
45 char *conn;
46 int num_channels;
47 uint32_t max_sample_points;
48 uint8_t packet_size;
49 gboolean (*packet_valid)(const uint8_t *);
50 struct sr_dev_driver *di;
51 int (*receive_data)(int, int, void *);
52};
53
54extern SR_PRIV const struct center_dev_info center_devs[CENTER_DEV_COUNT];
55
56#define SERIAL_BUFSIZE 256
57
4433145f
UH
58/** Private, per-device-instance driver context. */
59struct dev_context {
4a8bbed7
UH
60 /** The current sampling limit (in number of samples). */
61 uint64_t limit_samples;
4433145f 62
4a8bbed7
UH
63 /** The current sampling limit (in ms). */
64 uint64_t limit_msec;
4433145f 65
4a8bbed7
UH
66 /** Opaque pointer passed in by the frontend. */
67 void *cb_data;
4433145f 68
4a8bbed7
UH
69 /** The current number of already received samples. */
70 uint64_t num_samples;
4433145f 71
4a8bbed7
UH
72 int64_t starttime;
73
74 uint8_t buf[SERIAL_BUFSIZE];
75 int bufoffset;
76 int buflen;
4433145f
UH
77};
78
4a8bbed7
UH
79SR_PRIV gboolean center_3xx_packet_valid(const uint8_t *buf);
80
81SR_PRIV int receive_data_CENTER_309(int fd, int revents, void *cb_data);
82SR_PRIV int receive_data_VOLTCRAFT_K204(int fd, int revents, void *cb_data);
4433145f
UH
83
84#endif