source: multiio/pcmmio/mio_io.h @ 13bdbee

base
Last change on this file since 13bdbee was 13bdbee, checked in by Joel Sherrill <joel.sherrill@…>, on 03/17/11 at 15:04:30

Initial import.

  • Property mode set to 100644
File size: 5.5 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/* $Id$ */
10
11#ifndef CHARDEV_H
12#define CHARDEV_H
13
14#if defined(__linux__)
15#include <linux/ioctl.h>
16
17
18/* These are the IOCTL value the pcmmio driver recognizes */
19
20#define WRITE_DAC_DATA          _IOWR(MAJOR_NUM, 0, int)
21
22#define READ_DAC_STATUS         _IOWR(MAJOR_NUM, 1, int)
23
24#define WRITE_DAC_COMMAND       _IOWR(MAJOR_NUM, 2, int)
25
26#define WRITE_ADC_COMMAND       _IOWR(MAJOR_NUM, 3, int)
27
28#define READ_ADC_DATA           _IOWR(MAJOR_NUM, 4, int)
29
30#define READ_ADC_STATUS         _IOWR(MAJOR_NUM, 5, int)
31
32#define WRITE_DIO_BYTE          _IOWR(MAJOR_NUM, 6, int)
33
34#define READ_DIO_BYTE           _IOWR(MAJOR_NUM, 7, int)
35
36#define MIO_WRITE_REG           _IOWR(MAJOR_NUM, 8, int)
37
38#define MIO_READ_REG            _IOWR(MAJOR_NUM, 9, int)
39
40#define WAIT_A2D_INT_1          _IOWR(MAJOR_NUM, 10, int)
41
42#define WAIT_A2D_INT_2          _IOWR(MAJOR_NUM, 11, int)
43
44#define WAIT_DAC_INT_1          _IOWR(MAJOR_NUM, 12, int)
45
46#define WAIT_DAC_INT_2          _IOWR(MAJOR_NUM, 13, int)
47
48#define WAIT_DIO_INT            _IOWR(MAJOR_NUM, 14, int)
49
50#define READ_IRQ_ASSIGNED       _IOWR(MAJOR_NUM, 15, int)
51
52#define DIO_GET_INT                     _IOWR(MAJOR_NUM, 16, int)
53
54
55/* The name of the device file */
56
57#define DEVICE_FILE_NAME "pcmmio"
58
59#endif
60
61#endif
62
63/* These are the error codes for 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/* part of the porting layer */
146int check_handle(void);
147int mio_read_irq_assigned(void);
148
149int disable_dio_interrupt(void);
150int enable_dio_interrupt(void);
151int disable_dac_interrupt(int dac_num);
152int enable_dac_interrupt(int dac_num);
153int disable_adc_interrupt(int adc_num);
154int enable_adc_interrupt(int adc_num);
155int set_dac_span(int channel, unsigned char span_value);
156int wait_dac_ready(int channel);
157int set_dac_output(int channel, unsigned short dac_value);
158int set_dac_voltage(int channel, float voltage);
159unsigned char read_dio_byte(int offset);
160unsigned char mio_read_reg(int offset);
161int mio_write_reg(int offset, unsigned char value);
162int write_dio_byte(int offset, unsigned char value);
163int write_dac_command(int dac_num,unsigned char value);
164int adc_start_conversion(int channel);
165float adc_get_channel_voltage(int channel);
166int adc_convert_all_channels(unsigned short *buffer);
167float adc_convert_to_volts(int channel, unsigned short value);
168int adc_convert_single_repeated(int channel, unsigned short count, unsigned short *buffer);
169int adc_buffered_channel_conversions(unsigned char *input_channel_buffer,unsigned short *buffer);
170int adc_wait_ready(int channel);
171int write_adc_command(int adc_num,unsigned char value);
172int buffered_dac_output(unsigned char *cmd_buff,unsigned short *data_buff);
173int write_dac_data(int dac_num, unsigned short value);
174unsigned char dac_read_status(int dac_num);
175unsigned char adc_read_status(int adc_num);
176int adc_set_channel_mode(int channel, int input_mode,int duplex,int range);
177unsigned short adc_read_conversion_data(int channel);
178float adc_auto_get_channel_voltage(int channel);
179int dio_read_bit(int bit_number);
180int dio_write_bit(int bit_number, int val);
181int dio_set_bit(int bit_number);
182int dio_clr_bit(int bit_number);
183int dio_enab_bit_int(int bit_number, int polarity);
184int dio_disab_bit_int(int bit_number);
185int dio_clr_int(int bit_number);
186int dio_get_int(void);
187int dio_get_int_with_timestamp(
188  unsigned long long *timestamp
189);
190int wait_adc_int(int adc_num);
191int wait_dac_int(int dac_num);
192int wait_dio_int(void);
193
194#if defined(__rtems__)
195  void pcmmio_initialize(
196    unsigned short _base_port,
197    unsigned short _irq
198  );
199
200  void flush_buffered_ints(void);
201  int wait_adc_int_with_timeout(int adc_num, int milliseconds);
202  int wait_dac_int_with_timeout(int dac_num, int milliseconds);
203  int wait_dio_int_with_timeout(int milliseconds);
204  int wait_dio_int_with_timestamp(
205    int                 milliseconds,
206    unsigned long long *timestamp
207  );
208  int dio_get_missed_interrupts(void);
209#endif
210
Note: See TracBrowser for help on using the repository browser.