libsigrok
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
fx2lafw.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of the sigrok project.
00003  *
00004  * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
00005  * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
00006  *
00007  * This program is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #include <glib.h>
00022 
00023 #ifndef LIBSIGROK_HARDWARE_FX2LAFW_FX2LAFW_H
00024 #define LIBSIGROK_HARDWARE_FX2LAFW_FX2LAFW_H
00025 
00026 #define USB_INTERFACE           0
00027 #define USB_CONFIGURATION       1
00028 #define NUM_TRIGGER_STAGES      4
00029 #define TRIGGER_TYPES           "01"
00030 
00031 #define MAX_RENUM_DELAY_MS      3000
00032 #define NUM_SIMUL_TRANSFERS     32
00033 #define MAX_EMPTY_TRANSFERS     (NUM_SIMUL_TRANSFERS * 2)
00034 
00035 #define FX2LAFW_REQUIRED_VERSION_MAJOR  1
00036 
00037 /* 6 delay states of up to 256 clock ticks */
00038 #define MAX_SAMPLE_DELAY        (6 * 256)
00039 
00040 /* Software trigger implementation: positive values indicate trigger stage. */
00041 #define TRIGGER_FIRED          -1
00042 
00043 struct fx2lafw_profile {
00044         uint16_t vid;
00045         uint16_t pid;
00046 
00047         const char *vendor;
00048         const char *model;
00049         const char *model_version;
00050 
00051         const char *firmware;
00052 
00053         int num_probes;
00054 };
00055 
00056 struct context {
00057         const struct fx2lafw_profile *profile;
00058 
00059         /*
00060          * Since we can't keep track of an fx2lafw device after upgrading
00061          * the firmware (it re-enumerates into a different device address
00062          * after the upgrade) this is like a global lock. No device will open
00063          * until a proper delay after the last device was upgraded.
00064          */
00065         int64_t fw_updated;
00066 
00067         /* Device/capture settings */
00068         uint64_t cur_samplerate;
00069         uint64_t limit_samples;
00070 
00071         uint8_t trigger_mask[NUM_TRIGGER_STAGES];
00072         uint8_t trigger_value[NUM_TRIGGER_STAGES];
00073         int trigger_stage;
00074         uint8_t trigger_buffer[NUM_TRIGGER_STAGES];
00075 
00076         int num_samples;
00077         int submitted_transfers;
00078 
00079         void *session_dev_id;
00080 
00081         struct sr_usb_dev_inst *usb;
00082 };
00083 
00084 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines