source: multiio/pcmmio/original/mio_io.h @ da59d43

Last change on this file since da59d43 was c99627b, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 8, 2009 at 7:09:54 PM

2009-06-08 Joel Sherrill <joel.sherrill@…>

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