1 | @c |
---|
2 | @c COPYRIGHT (c) 1988-1999. |
---|
3 | @c On-Line Applications Research Corporation (OAR). |
---|
4 | @c All rights reserved. |
---|
5 | @c |
---|
6 | @c $Id$ |
---|
7 | @c |
---|
8 | |
---|
9 | @chapter Analog Driver |
---|
10 | |
---|
11 | The Analog driver is responsible for providing an |
---|
12 | interface to Digital to Analog Converters (DACs) and |
---|
13 | Analog to Digital Converters (ADCs). The capabilities provided |
---|
14 | by this class of device driver are: |
---|
15 | |
---|
16 | @itemize @bullet |
---|
17 | @item Initialize an Analog Board |
---|
18 | @item Open a Particular Analog |
---|
19 | @item Close a Particular Analog |
---|
20 | @item Read from a Particular Analog |
---|
21 | @item Write to a Particular Analog |
---|
22 | @item Reset DACs |
---|
23 | @item Reinitialize DACS |
---|
24 | @end itemize |
---|
25 | |
---|
26 | Most analog devices are found on I/O cards that support multiple |
---|
27 | DACs or ADCs on a single card. |
---|
28 | |
---|
29 | There are currently no analog device drivers included in the |
---|
30 | RTEMS source tree. The information provided in this chapter |
---|
31 | is based on drivers developed by OAR Corporation personnel |
---|
32 | for applications using RTEMS. It is hoped that this |
---|
33 | driver model information can form the basis for a standard |
---|
34 | analog driver model that can be supported in future RTEMS |
---|
35 | distribution. |
---|
36 | |
---|
37 | @section Major and Minor Numbers |
---|
38 | |
---|
39 | The @b{major} number of a device driver is its index in the |
---|
40 | RTEMS Device Address Table. |
---|
41 | |
---|
42 | A @b{minor} number is associated with each device instance |
---|
43 | managed by a particular device driver. An RTEMS minor number |
---|
44 | is an @code{unsigned32} entity. Convention calls |
---|
45 | dividing the bits in the minor number down into categories |
---|
46 | like the following: |
---|
47 | |
---|
48 | @itemize @bullet |
---|
49 | |
---|
50 | @item @b{board} - indicates the board a particular device is located on |
---|
51 | @item @b{port} - indicates the particular device on a board. |
---|
52 | |
---|
53 | @end itemize |
---|
54 | |
---|
55 | From the above, it should be clear that a single device driver |
---|
56 | can support multiple copies of the same board in a single system. |
---|
57 | The minor number is used to distinguish the devices. |
---|
58 | |
---|
59 | @section Analog Driver Configuration |
---|
60 | |
---|
61 | There is not a standard analog driver configuration table but some |
---|
62 | fields are common across different drivers. The analog driver |
---|
63 | configuration table is typically an array of structures with each |
---|
64 | structure containing the information for a particular board. |
---|
65 | The following is a list of the type of information normally required |
---|
66 | to configure an analog board: |
---|
67 | |
---|
68 | @table @b |
---|
69 | @item board_offset |
---|
70 | is the base address of a board. |
---|
71 | |
---|
72 | @item DAC_initial_values |
---|
73 | is an array of the voltages that should be written to each DAC |
---|
74 | during initialization. This allows the driver to start the board |
---|
75 | in a known state. |
---|
76 | |
---|
77 | @end table |
---|
78 | |
---|
79 | @section Initialize an Analog Board |
---|
80 | |
---|
81 | At system initialization, the analog driver's initialization entry point |
---|
82 | will be invoked. As part of initialization, the driver will perform |
---|
83 | whatever board initialization is required and then set all |
---|
84 | outputs to their configured initial state. |
---|
85 | |
---|
86 | The analog driver may register a device name for each DAC and ADC in |
---|
87 | the system. |
---|
88 | |
---|
89 | @section Open a Particular Analog |
---|
90 | |
---|
91 | This is the driver open call. Usually this call does nothing other than |
---|
92 | validate the minor number. |
---|
93 | |
---|
94 | With some drivers, it may be necessary to allocate memory when a particular |
---|
95 | device is opened. If that is the case, then this is often the place |
---|
96 | to do this operation. |
---|
97 | |
---|
98 | @section Close a Particular Analog |
---|
99 | |
---|
100 | This is the driver close call. Usually this call does nothing. |
---|
101 | |
---|
102 | With some drivers, it may be necessary to allocate memory when a particular |
---|
103 | device is opened. If that is the case, then this is the place |
---|
104 | where that memory should be deallocated. |
---|
105 | |
---|
106 | @section Read from a Particular Analog |
---|
107 | |
---|
108 | This corresponds to the driver read call. After validating the minor |
---|
109 | number and arguments, this call reads the indicated device. Most analog |
---|
110 | devices store the last value written to a DAC. Since DACs are output |
---|
111 | only devices, saving the last written value gives the appearance that |
---|
112 | DACs can be read from also. If the device is an ADC, then it is sampled. |
---|
113 | |
---|
114 | @b{NOTE:} Many boards have multiple analog inputs but only one ADC. On |
---|
115 | these boards, it will be necessary to provide some type of mutual exclusion |
---|
116 | during reads. On these boards, there is a MUX which must be switched |
---|
117 | before sampling the ADC. After the MUX is switched, the driver must |
---|
118 | delay some short period of time (usually microseconds) before the |
---|
119 | signal is stable and can be sampled. To make matters worse, some ADCs |
---|
120 | cannot respond to wide voltage swings in a single sample. On these |
---|
121 | ADCs, one must do two samples when the voltage swing is too large. |
---|
122 | On a practical basis, this means that the driver usually ends up |
---|
123 | double sampling the ADC on these systems. |
---|
124 | |
---|
125 | The value returned is a single precision floating point number |
---|
126 | representing the voltage read. This value is stored in the |
---|
127 | @code{argument_block} passed in to the call. By returning the |
---|
128 | voltage, the caller is freed from having to know the number of |
---|
129 | bits in the analog and board dependent conversion algorithm. |
---|
130 | |
---|
131 | @section Write to a Particular Analog |
---|
132 | |
---|
133 | This corresponds to the driver write call. After validating the minor |
---|
134 | number and arguments, this call writes the indicated device. If the |
---|
135 | specified device is an ADC, then an error is usually returned. |
---|
136 | |
---|
137 | The value written is a single precision floating point number |
---|
138 | representing the voltage to be written to the specified DAC. |
---|
139 | This value is stored in the @code{argument_block} passed in to the |
---|
140 | call. By passing the voltage to the device driver, the caller is |
---|
141 | freed from having to know the number of bits in the analog |
---|
142 | and board dependent conversion algorithm. |
---|
143 | |
---|
144 | @section Reset DACs |
---|
145 | |
---|
146 | This is one of the IOCTL functions supported by the I/O control |
---|
147 | device driver entry point. When this IOCTL function is invoked, |
---|
148 | all of the DACs are written to 0.0 volts. |
---|
149 | |
---|
150 | @section Reinitialize DACS |
---|
151 | |
---|
152 | This is one of the IOCTL functions supported by the I/O control |
---|
153 | device driver entry point. When this IOCTL function is invoked, |
---|
154 | all of the DACs are written with the initial value configured |
---|
155 | for this device. |
---|
156 | |
---|
157 | @section Get Last Written Values |
---|
158 | |
---|
159 | This is one of the IOCTL functions supported by the I/O control |
---|
160 | device driver entry point. When this IOCTL function is invoked, |
---|
161 | the following information is returned to the caller: |
---|
162 | |
---|
163 | @itemize @bullet |
---|
164 | @item last value written to the specified DAC |
---|
165 | @item timestamp of when the last write was performed |
---|
166 | @end itemize |
---|
167 | |
---|