source: rtems-docs/bsp_howto/analog.rst @ 2b175c3

4.115
Last change on this file since 2b175c3 was 6d7a4d2, checked in by Chris Johns <chrisj@…>, on 06/17/16 at 05:05:41

Update the BSP howto.

Closes #2590.

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