source: multiio/pcmmio/original/mio_io.h @ 2bae2aa

basewinsystems
Last change on this file since 2bae2aa was 2bae2aa, checked in by Joel Sherrill <joel.sherrill@…>, on 06/08/09 at 14:52:43

Initial import.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/* Filename : $RCSfile$
2 *
3 * The declarations here have to be in a header file,
4 * because they need to be known both to the kernel
5 * module (in chardev.c) and the process calling ioctl
6 * (ioctl.c)
7 */
8
9/* $Log$
10*
11*/
12
13#ifndef CHARDEV_H
14#define CHARDEV_H
15
16#include <linux/ioctl.h>
17
18
19/* These are the IOCTL value the pcmmio driver recognizes */
20
21#define WRITE_DAC_DATA          _IOWR(MAJOR_NUM, 0, int)
22
23#define READ_DAC_STATUS         _IOWR(MAJOR_NUM, 1, int)
24
25#define WRITE_DAC_COMMAND       _IOWR(MAJOR_NUM, 2, int)
26
27#define WRITE_ADC_COMMAND       _IOWR(MAJOR_NUM, 3, int)
28
29#define READ_ADC_DATA           _IOWR(MAJOR_NUM, 4, int)
30
31#define READ_ADC_STATUS         _IOWR(MAJOR_NUM, 5, int)
32
33#define WRITE_DIO_BYTE          _IOWR(MAJOR_NUM, 6, int)
34
35#define READ_DIO_BYTE           _IOWR(MAJOR_NUM, 7, int)
36
37#define MIO_WRITE_REG           _IOWR(MAJOR_NUM, 8, int)
38
39#define MIO_READ_REG            _IOWR(MAJOR_NUM, 9, int)
40
41#define WAIT_A2D_INT_1          _IOWR(MAJOR_NUM, 10, int)
42
43#define WAIT_A2D_INT_2          _IOWR(MAJOR_NUM, 11, int)
44
45#define WAIT_DAC_INT_1          _IOWR(MAJOR_NUM, 12, int)
46
47#define WAIT_DAC_INT_2          _IOWR(MAJOR_NUM, 13, int)
48
49#define WAIT_DIO_INT            _IOWR(MAJOR_NUM, 14, int)
50
51#define READ_IRQ_ASSIGNED       _IOWR(MAJOR_NUM, 15, int)
52
53#define DIO_GET_INT                     _IOWR(MAJOR_NUM, 16, int)
54
55
56/* The name of the device file */
57
58#define DEVICE_FILE_NAME "pcmmio"
59
60
61#endif
62
63/* These are the error codes doe mio_error_code */
64
65#define MIO_SUCCESS 0
66#define MIO_OPEN_ERROR 1
67#define MIO_TIMEOUT_ERROR 2
68#define MIO_BAD_CHANNEL_NUMBER 3
69#define MIO_BAD_MODE_NUMBER 4
70#define MIO_BAD_RANGE 5
71#define MIO_COMMAND_WRITE_FAILURE 6
72#define MIO_READ_DATA_FAILURE 7
73#define MIO_MISSING_IRQ 8
74#define MIO_ILLEGAL_VOLTAGE 9
75
76
77/* These are DAC specific defines */
78
79#define DAC_BUSY 0x80
80
81#define DAC_SPAN_UNI5  0
82#define DAC_SPAN_UNI10 1
83#define DAC_SPAN_BI5   2
84#define DAC_SPAN_BI10  3
85#define DAC_SPAN_BI2   4
86#define DAC_SPAN_BI7   5
87
88/* These are ADC specific defines */
89
90#define ADC_SINGLE_ENDED 0x80
91#define ADC_DIFFERENTIAL 0x00
92
93#define ADC_UNIPOLAR  0x08
94#define ADC_BIPOLAR   0x00
95
96#define ADC_TOP_5V        0x00
97#define ADC_TOP_10V       0x04
98
99#define ADC_CH0_SELECT 0x00
100#define ADC_CH1_SELECT 0x40
101#define ADC_CH2_SELECT 0x10
102#define ADC_CH3_SELECT 0x50
103#define ADC_CH4_SELECT 0x20
104#define ADC_CH5_SELECT 0x60
105#define ADC_CH6_SELECT 0x30
106#define ADC_CH7_SELECT 0x70
107
108/* These are DIO specific defines */
109
110#define FALLING 1
111#define RISING  0
112
113#ifdef LIB_DEFINED
114
115/* These are used by the library functions */
116
117int mio_error_code;
118char mio_error_string[128];
119float adc_bitval[16] = {.00, .00, .00, .00, .00, .00, 00, .00,
120                                                           .00, .00, .00, .00, .00, .00, .00, .00 };
121
122unsigned short adc_adjust[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
123
124float adc_offset[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
125                                                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
126
127#else
128
129
130/* The rest of this file is made up of global variables available to application
131   code and the function prototypes for all available functions
132*/
133
134
135extern int mio_error_code;
136extern char mio_error_string[128];
137extern float adc_bitval[16];
138
139extern unsigned short adc_adjust[16];
140
141extern float adc_offset[16];
142
143#endif
144
145
146int disable_dio_interrupt(void);
147int enable_dio_interrupt(void);
148int disable_dac_interrupt(int dac_num);
149int enable_dac_interrupt(int dac_num);
150int disable_adc_interrupt(int adc_num);
151int enable_adc_interrupt(int adc_num);
152int set_dac_span(int channel, unsigned char span_value);
153int wait_dac_ready(int channel);
154int set_dac_output(int channel, unsigned short dac_value);
155int set_dac_voltage(int channel, float voltage);
156int set_dac_voltage(int channel, float voltage);
157unsigned char read_dio_byte(int offset);
158unsigned char mio_read_reg(int offset);
159int mio_write_reg(int offset, unsigned char value);
160int write_dio_byte(int offset, unsigned char value);
161int write_dac_command(int dac_num,unsigned char value);
162int adc_start_conversion(int channel);
163float adc_get_channel_voltage(int channel);
164int adc_convert_all_channels(unsigned short *buffer);
165float adc_convert_to_volts(int channel, unsigned short value);
166int adc_convert_single_repeated(int channel, unsigned short count, unsigned short *buffer);
167int adc_buffered_channel_conversions(unsigned char *input_channel_buffer,unsigned short *buffer);
168int adc_wait_ready(int channel);
169int write_adc_command(int adc_num,unsigned char value);
170int buffered_dac_output(unsigned char *cmd_buff,unsigned short *data_buff);
171int write_dac_data(int dac_num, unsigned short value);
172unsigned char dac_read_status(int dac_num);
173unsigned char adc_read_status(int adc_num);
174int adc_set_channel_mode(int channel, int input_mode,int duplex,int range);
175unsigned short adc_read_conversion_data(int channel);
176float adc_auto_get_channel_voltage(int channel);
177int dio_read_bit(int bit_number);
178int dio_write_bit(int bit_number, int val);
179int dio_set_bit(int bit_number);
180int dio_clr_bit(int bit_number);
181int dio_enab_bit_int(int bit_number, int polarity);
182int dio_disab_bit_int(int bit_number);
183int dio_clr_int(int bit_number);
184int dio_get_int(void);
185int wait_adc_int(int adc_num);
186int wait_dac_int(int dac_num);
187int wait_dio_int(void);
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
Note: See TracBrowser for help on using the repository browser.