]> sigrok.org Git - libsigrok.git/blob - src/hardware/microchip-pickit2/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / microchip-pickit2 / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2018 Gerhard Sittig <gerhard.sittig@gmx.net>
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_MICROCHIP_PICKIT2_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_MICROCHIP_PICKIT2_PROTOCOL_H
22
23 #include <glib.h>
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
28
29 #define LOG_PREFIX "microchip-pickit2"
30
31 #define PICKIT2_CHANNEL_COUNT   3
32 #define PICKIT2_SAMPLE_COUNT    1024
33 #define PICKIT2_SAMPLE_RAWLEN   (4 * 128)
34
35 enum pickit_state {
36         STATE_IDLE,
37         STATE_CONF,
38         STATE_WAIT,
39         STATE_DATA,
40 };
41
42 struct dev_context {
43         char **channel_names;
44         enum pickit_state state;
45         const uint64_t *samplerates;
46         size_t num_samplerates;
47         size_t curr_samplerate_idx;
48         const uint64_t *captureratios;
49         size_t num_captureratios;
50         size_t curr_captureratio_idx;
51         struct sr_sw_limits sw_limits;
52         gboolean detached_kernel_driver;
53         int32_t triggers[PICKIT2_CHANNEL_COUNT];        /**@< see @ref SR_TRIGGER_ZERO et al */
54         size_t trigpos;
55         uint8_t samples_raw[PICKIT2_SAMPLE_RAWLEN];
56         uint8_t samples_conv[PICKIT2_SAMPLE_COUNT];
57 };
58
59 SR_PRIV int microchip_pickit2_setup_trigger(const struct sr_dev_inst *sdi);
60 SR_PRIV int microchip_pickit2_receive_data(int fd, int revents, void *cb_data);
61
62 #endif