source: rtems/doc/bsp_howto/discrete.t @ 0660b4f8

4.104.114.84.95
Last change on this file since 0660b4f8 was 0660b4f8, checked in by Joel Sherrill <joel.sherrill@…>, on 11/16/99 at 19:50:56

Changed copyright date to 1999.

  • Property mode set to 100644
File size: 6.7 KB
Line 
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 Discrete Driver
10
11The Discrete driver is responsible for providing an
12interface to Discrete Input/Outputs.  The capabilities provided
13by this class of device driver are:
14
15@itemize @bullet
16@item Initialize a Discrete I/O Board
17@item Open a Particular Discrete Bitfield
18@item Close a Particular Discrete Bitfield
19@item Read from a Particular Discrete Bitfield
20@item Write to a Particular Discrete Bitfield
21@item Reset DACs
22@item Reinitialize DACS
23@end itemize
24
25Most discrete I/O devices are found on I/O cards that support many
26bits of discrete I/O on a single card.  This driver model is centered
27on the notion of reading bitfields from the card.
28
29There are currently no discrete I/O device drivers included in the
30RTEMS source tree.  The information provided in this chapter
31is based on drivers developed by OAR Corporation personnel
32for applications using RTEMS.   It is hoped that this
33driver model information can form the basis for a standard
34discrete I/O driver model that can be supported in future RTEMS
35distribution.
36
37@section Major and Minor Numbers
38
39The @b{major} number of a device driver is its index in the
40RTEMS Device Address Table.
41
42A @b{minor} number is associated with each device instance
43managed by a particular device driver.  An RTEMS minor number
44is an @code{unsigned32} entity.  Convention calls for
45dividing the bits in the minor number down into categories
46that specify a particular bitfield.  This results in categories
47like the following:
48
49@itemize @bullet
50
51@item @b{board} - indicates the board a particular bitfield is located on
52@item @b{word} - indicates the particular word of discrete bits the
53bitfield is located within
54@item @b{start} - indicates the starting bit of the bitfield
55@item @b{width} - indicates the width of the bitfield
56
57@end itemize
58
59From the above, it should be clear that a single device driver
60can support multiple copies of the same board in a single system.
61The minor number is used to distinguish the devices.
62
63By providing a way to easily access a particular bitfield from
64the device driver, the application is insulated with knowing how
65to mask fields in and out of a discrete I/O.
66
67@section Discrete I/O Driver Configuration
68
69There is not a standard discrete I/O driver configuration table but some
70fields are common across different drivers.  The discrete I/O driver
71configuration table is typically an array of structures with each
72structure containing the information for a particular board.
73The following is a list of the type of information normally required
74to configure an discrete I/O board:
75
76@table @b
77@item board_offset
78is the base address of a board.
79
80@item relay_initial_values
81is an array of the values that should be written to each output
82word on the board during initialization.  This allows the driver
83to start with the board's output  in a known state.
84
85@end table
86
87@section Initialize a Discrete I/O Board
88
89At system initialization, the discrete I/O driver's initialization entry point
90will be invoked.  As part of initialization, the driver will perform
91whatever board initializatin is required and then set all
92outputs to their configured initial state.
93
94The discrete I/O driver may register a device name for bitfields of
95particular interest to the system.  Normally this will be restricted
96to the names of each word and, if the driver supports it, an "all words".
97
98@section Open a Particular Discrete Bitfield
99
100This is the driver open call.  Usually this call does nothing other than
101validate the minor number. 
102
103With some drivers, it may be necessary to allocate memory when a particular
104device is opened.  If that is the case, then this is often the place
105to do this operation.
106
107@section Close a Particular Discrete Bitfield
108
109This is the driver close call.  Usually this call does nothing.
110
111With some drivers, it may be necessary to allocate memory when a particular
112device is opened.  If that is the case, then this is the place
113where that memory should be deallocated.
114
115@section Read from a Particular Discrete Bitfield
116
117This corresponds to the driver read call.  After validating the minor
118number and arguments, this call reads the indicated bitfield.  A
119discrete I/O devices may have to store the last value written to
120a discrete output.  If the bitfield is output only, saving the last
121written value gives the appearance that it can be read from also. 
122If the bitfield is input, then it is sampled.
123
124@b{NOTE:} Many discrete inputs have a tendency to bounce.  The application
125may have to take account for bounces.
126
127The value returned is an @code{unsigned32} number
128representing the bitfield read.  This value is stored in the
129@code{argument_block} passed in to the call.
130
131@b{NOTE:} Some discrete I/O drivers have a special minor number
132used to access all discrete I/O bits on the board.  If this special
133minor is used, then the area pointed to by @code{argument_block} must
134be the correct size.
135
136@section Write to a Particular Discrete Bitfield
137
138This corresponds to the driver write call.  After validating the minor
139number and arguments, this call writes the indicated device.  If the
140specified device is an ADC, then an error is usually returned. 
141
142The value written is an @code{unsigned32} number
143representing the value to be written to the specified
144bitfield.  This value is stored in the
145@code{argument_block} passed in to the call.
146
147@b{NOTE:} Some discrete I/O drivers have a special minor number
148used to access all discrete I/O bits on the board.  If this special
149minor is used, then the area pointed to by @code{argument_block} must
150be the correct size.
151
152@section Disable Discrete Outputs
153
154This is one of the IOCTL functions supported by the I/O control
155device driver entry point.  When this IOCTL function is invoked,
156the discrete outputs are disabled.
157
158@b{NOTE:} It may not be possible to disable/enable discrete output on all
159discrete I/O boards.
160
161@section Enable Discrete Outputs
162
163This is one of the IOCTL functions supported by the I/O control
164device driver entry point.  When this IOCTL function is invoked,
165the discrete outputs are enabled.
166
167@b{NOTE:} It may not be possible to disable/enable discrete output on all
168discrete I/O boards.
169
170@section Reinitialize Outputs
171
172This is one of the IOCTL functions supported by the I/O control
173device driver entry point.  When this IOCTL function is invoked,
174the discrete outputs are rewritten with the configured initial
175output values.
176
177@section Get Last Written Values
178
179This is one of the IOCTL functions supported by the I/O control
180device driver entry point.  When this IOCTL function is invoked,
181the following information is returned to the caller:
182
183@itemize @bullet
184@item last value written to the specified output word
185@item timestamp of when the last write was performed
186@end itemize
187
Note: See TracBrowser for help on using the repository browser.