1 | Analog Driver |
---|
2 | ############# |
---|
3 | |
---|
4 | The Analog driver is responsible for providing an |
---|
5 | interface to Digital to Analog Converters (DACs) and |
---|
6 | Analog to Digital Converters (ADCs). The capabilities provided |
---|
7 | by this class of device driver are: |
---|
8 | |
---|
9 | - Initialize an Analog Board |
---|
10 | |
---|
11 | - Open a Particular Analog |
---|
12 | |
---|
13 | - Close a Particular Analog |
---|
14 | |
---|
15 | - Read from a Particular Analog |
---|
16 | |
---|
17 | - Write to a Particular Analog |
---|
18 | |
---|
19 | - Reset DACs |
---|
20 | |
---|
21 | - Reinitialize DACS |
---|
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 | Major and Minor Numbers |
---|
34 | ======================= |
---|
35 | |
---|
36 | The *major* number of a device driver is its index in the |
---|
37 | RTEMS Device Address Table. |
---|
38 | |
---|
39 | A *minor* number is associated with each device instance |
---|
40 | managed by a particular device driver. An RTEMS minor number |
---|
41 | is an ``unsigned32`` entity. Convention calls for |
---|
42 | dividing the bits in the minor number down into categories |
---|
43 | like the following: |
---|
44 | |
---|
45 | - *board* - indicates the board a particular device is located on |
---|
46 | |
---|
47 | - *port* - indicates the particular device on a board. |
---|
48 | |
---|
49 | From the above, it should be clear that a single device driver |
---|
50 | can support multiple copies of the same board in a single system. |
---|
51 | The minor number is used to distinguish the devices. |
---|
52 | |
---|
53 | Analog Driver Configuration |
---|
54 | =========================== |
---|
55 | |
---|
56 | There is not a standard analog driver configuration table but some |
---|
57 | fields are common across different drivers. The analog driver |
---|
58 | configuration table is typically an array of structures with each |
---|
59 | structure containing the information for a particular board. |
---|
60 | The following is a list of the type of information normally required |
---|
61 | to configure an analog board: |
---|
62 | |
---|
63 | *board_offset* |
---|
64 | is the base address of a board. |
---|
65 | |
---|
66 | *DAC_initial_values* |
---|
67 | is an array of the voltages that should be written to each DAC |
---|
68 | during initialization. This allows the driver to start the board |
---|
69 | in a known state. |
---|
70 | |
---|
71 | Initialize an Analog Board |
---|
72 | ========================== |
---|
73 | |
---|
74 | At system initialization, the analog driverâs initialization entry point |
---|
75 | will be invoked. As part of initialization, the driver will perform |
---|
76 | whatever board initialization is required and then set all |
---|
77 | outputs to their configured initial state. |
---|
78 | |
---|
79 | The analog driver may register a device name for each DAC and ADC in |
---|
80 | the system. |
---|
81 | |
---|
82 | Open a Particular Analog |
---|
83 | ======================== |
---|
84 | |
---|
85 | This is the driver open call. Usually this call does nothing other than |
---|
86 | validate the minor number. |
---|
87 | |
---|
88 | With some drivers, it may be necessary to allocate memory when a particular |
---|
89 | device is opened. If that is the case, then this is often the place |
---|
90 | to do this operation. |
---|
91 | |
---|
92 | Close a Particular Analog |
---|
93 | ========================= |
---|
94 | |
---|
95 | This is the driver close call. Usually this call does nothing. |
---|
96 | |
---|
97 | With some drivers, it may be necessary to allocate memory when a particular |
---|
98 | device is opened. If that is the case, then this is the place |
---|
99 | where that memory should be deallocated. |
---|
100 | |
---|
101 | Read from a Particular Analog |
---|
102 | ============================= |
---|
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 | *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``argument_block`` passed in to the call. By returning the |
---|
123 | voltage, the caller is freed from having to know the number of |
---|
124 | bits in the analog and board dependent conversion algorithm. |
---|
125 | |
---|
126 | Write to a Particular Analog |
---|
127 | ============================ |
---|
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 ``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 | Reset DACs |
---|
141 | ========== |
---|
142 | |
---|
143 | This is one of the IOCTL functions supported by the I/O control |
---|
144 | device driver entry point. When this IOCTL function is invoked, |
---|
145 | all of the DACs are written to 0.0 volts. |
---|
146 | |
---|
147 | Reinitialize DACS |
---|
148 | ================= |
---|
149 | |
---|
150 | This is one of the IOCTL functions supported by the I/O control |
---|
151 | device driver entry point. When this IOCTL function is invoked, |
---|
152 | all of the DACs are written with the initial value configured |
---|
153 | for this device. |
---|
154 | |
---|
155 | Get Last Written Values |
---|
156 | ======================= |
---|
157 | |
---|
158 | This is one of the IOCTL functions supported by the I/O control |
---|
159 | device driver entry point. When this IOCTL function is invoked, |
---|
160 | the following information is returned to the caller: |
---|
161 | |
---|
162 | - last value written to the specified DAC |
---|
163 | |
---|
164 | - timestamp of when the last write was performed |
---|
165 | |
---|
166 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
167 | |
---|
168 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
169 | |
---|
170 | .. COMMENT: All rights reserved. |
---|
171 | |
---|