]> sigrok.org Git - libsigrok.git/blob - src/hardware/ipdbg-la/protocol.h
ipdbg-la: Drop various unneeded name prefixes.
[libsigrok.git] / src / hardware / ipdbg-la / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2016 Eva Kissling <eva.kissling@bluewin.ch>
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_IPDBG_LA_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_IPDBG_LA_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 "ipdbg-la"
29
30 struct ipdbg_la_tcp {
31         char *address;
32         char *port;
33         int socket;
34 };
35
36 /** Private, per-device-instance driver context. */
37 struct dev_context {
38         uint32_t DATA_WIDTH;
39         uint32_t DATA_WIDTH_BYTES;
40         uint32_t ADDR_WIDTH;
41         uint32_t ADDR_WIDTH_BYTES;
42
43         uint64_t limit_samples;
44         uint64_t limit_samples_max;
45         uint8_t capture_ratio;
46         uint8_t *trigger_mask;
47         uint8_t *trigger_value;
48         uint8_t *trigger_mask_last;
49         uint8_t *trigger_value_last;
50         uint8_t *trigger_edge_mask;
51         uint64_t delay_value;
52         int num_stages;
53         uint64_t num_transfers;
54         uint8_t *raw_sample_buf;
55 };
56
57 int data_available(struct ipdbg_la_tcp *tcp);
58
59 SR_PRIV struct ipdbg_la_tcp *ipdbg_la_tcp_new(void);
60 SR_PRIV void ipdbg_la_tcp_free(struct ipdbg_la_tcp *tcp);
61 SR_PRIV int ipdbg_la_tcp_open(struct ipdbg_la_tcp *tcp);
62 SR_PRIV int ipdbg_la_tcp_close(struct ipdbg_la_tcp *tcp);
63 SR_PRIV int ipdbg_la_tcp_send(struct ipdbg_la_tcp *tcp,
64         const uint8_t *buf, size_t len);
65 SR_PRIV int ipdbg_la_tcp_receive_blocking(struct ipdbg_la_tcp *tcp,
66         uint8_t *buf, int bufsize);
67 SR_PRIV int ipdbg_la_tcp_receive(struct ipdbg_la_tcp *tcp,
68         uint8_t *buf);
69
70 SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi);
71
72 SR_PRIV struct dev_context *ipdbg_la_dev_new(void);
73 SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
74         struct ipdbg_la_tcp *tcp, struct dev_context *devc);
75 SR_PRIV int send_escaping(struct ipdbg_la_tcp *tcp, uint8_t *dataToSend,
76         uint32_t length);
77 SR_PRIV int ipdbg_la_send_reset(struct ipdbg_la_tcp *tcp);
78 SR_PRIV int ipdbg_la_request_id(struct ipdbg_la_tcp *tcp);
79 SR_PRIV int ipdbg_la_send_start(struct ipdbg_la_tcp *tcp);
80 SR_PRIV int ipdbg_la_send_trigger(struct dev_context *devc,
81         struct ipdbg_la_tcp *tcp);
82 SR_PRIV int ipdbg_la_send_delay(struct dev_context *devc,
83         struct ipdbg_la_tcp *tcp);
84 SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data);
85 SR_PRIV void ipdbg_la_abort_acquisition(const struct sr_dev_inst *sdi);
86 SR_PRIV int ipdbg_la_tcp_receive_blocking(struct ipdbg_la_tcp *tcp,
87         uint8_t * buf, int bufsize);
88
89 #endif