source: rtems-docs/bsp_howto/analog.rst @ 548f844

4.115
Last change on this file since 548f844 was b350509, checked in by Amar Takhar <amar@…>, on 01/17/16 at 05:47:50

Split document into seperate files by section.

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