-
Notifications
You must be signed in to change notification settings - Fork 1
/
usb-1208LS.h
118 lines (96 loc) · 4.84 KB
/
usb-1208LS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
*
* Copyright (c) 2004-2005 Warren Jasper <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef USB_1208LS_H
#define USB_1208LS_H
#ifdef __cplusplus
extern "C" {
#endif
#define USB1208LS_PID (0x007A)
#define DIO_PORTA (0x01)
#define DIO_PORTB (0x04)
#define DIO_AUXPORT (0x10)
#define DIO_DIR_IN (0x01)
#define DIO_DIR_OUT (0x00)
#define MINILAB_CLOCK (6000000L) // 6 MHz clock
#define LS_DELAY (1500)
/* Commands and Codes for USB 1208-LS HID reports */
#define DCONFIG (0x0D) // Configure digital port
#define DIN (0x00) // Read digital port
#define DOUT (0x01) // Write digital port
#define DBIT_IN (0x02) // Read digital port bit
#define DBIT_OUT (0x03) // Write digital port bit
#define AIN (0x06) // Read analog input channel
#define AIN_SCAN (0x0E) // Scan analog channels
#define AIN_STOP (0x10) // Stop scan
#define ALOAD_QUEUE (0x07) // Load the channel/gain queue
#define AOUT (0x08) // Write analog output channel
#define CINIT (0x05) // Initialize counter
#define CIN (0x04) // Read Counter
#define MEM_READ (0x09) // Read Memory
#define MEM_WRITE (0x0A) // Write Memory
#define BLINK_LED (0x0B) // Causes LED to blink
#define RESET (0x11) // Reset USB interface
#define SET_TRIGGER (0x14) // Configure external trigger
#define SET_ID (0x0C) // Set the user ID
#define GET_ID (0x0F) // Get the user ID
#define OFFSET_ADJUSTMENT (0x1F00) // Offset Adjustment for the A/D 0x1F00 - 0x1F4F
#define SE_GAIN_ADJUSTMENT (0x1F50) // Single Ended Gain Adjustment for A/D 0x1F50 - 0x1F5F
#define DE_GAIN_ADJUSTMENT (0x1F60) // Differential Gain Adjustment for A/D 0x1F60 - 0x1F67
#define CAL_PIN_VOLTAGE (0x1FA0) // Calibration pin voltage 0x1FA0 - 0x1FA3
#define EXT_TRIG_FAILING_EDGE 0;
#define EXT_TRIG_RAISING_EDGE 1;
// Gain Ranges
#define SE_10_00V (0x8) // Single Ended +/- 10.0 V
#define BP_20_00V (0x00) // Differential +/- 20.0 V
#define BP_10_00V (0x10) // Differential +/- 10.0 V
#define BP_5_00V (0x20) // Differential +/- 5.00 V
#define BP_4_00V (0x30) // Differential +/- 4.00 V
#define BP_2_50V (0x40) // Differential +/- 2.50 V
#define BP_2_00V (0x50) // Differential +/- 2.00 V
#define BP_1_25V (0x60) // Differential +/- 1.25 V
#define BP_1_00V (0x70) // Differential +/- 1.00 V
// Option values for AInScan
#define AIN_EXECUTION 0x1 // 1 = single execution, 0 = continuous execution
#define AIN_BURST_MODE 0x2 // 1 = Burst Mode
#define AIN_TRANSFER 0x4 // 1 = Block Transfer Mode
#define AIN_TRIGGER 0x8 // 1 = Use External Trigger
/* function prototypes for the USB-1208LS */
void usbDConfigPort_USB1208LS(HIDInterface* hid, __u8 port, __u8 direction);
void usbDIn_USB1208LS(HIDInterface* hid, __u8 port, __u8* din_value);
void usbDOut_USB1208LS(HIDInterface* hid, __u8 port, __u8 value);
__u8 usbDBitIn_USB1208LS(HIDInterface* hid, __u8 port, __u8 bit);
void usbDBitOut_USB1208LS(HIDInterface* hid, __u8 port, __u8 bit, __u8 value);
signed short usbAIn_USB1208LS(HIDInterface* hid, __u8 channel, __u8 range);
void usbAInScan_USB1208LS(HIDInterface* hid, __u16 count, int rate, __u8 low_channel, __u8 high_channel, __u8 options, __s16 value[], __u8 gainLoadQueue[]);
void usbAInLoadQueue_USB1208LS(HIDInterface* hid, __u8 chanCount, __u8 chanLoadQueue[], __u8 gainLoadQueue[]);
void usbAOut_USB1208LS(HIDInterface* hid, __u8 channel, __u16 value);
void usbAInStop_USB1208LS(HIDInterface* hid);
void usbInitCounter_USB1208LS(HIDInterface* hid);
__u32 usbReadCounter_USB1208LS(HIDInterface* hid);
void usbReadMemory_USB1208LS(HIDInterface* hid, __u16 address, __u8 *data, __u8 count);
void usbBlink_USB1208LS(HIDInterface* hid);
void usbReset_USB1208LS(HIDInterface* hid);
void usbSetTrigger_USB1208LS(HIDInterface* hid, __u8 type, __u8 chan);
__u8 usbGetID_USB1208LS(HIDInterface* hid);
void usbSetID_USB1208LS(HIDInterface* hid, __u8 id);
float volts_LS(const int gain, const signed short num);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
#endif //USB_1208LS_H