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