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