1 | /** |
---|
2 | * @file multiio.h |
---|
3 | * |
---|
4 | * This include file contains all the prototypes and definitions |
---|
5 | * for the multiio user interface. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef __multiio_h |
---|
20 | #define __multiio_h |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <sys/types.h> |
---|
27 | |
---|
28 | /** |
---|
29 | * @brief multiio supported types |
---|
30 | */ |
---|
31 | typedef enum { |
---|
32 | MULTIIO_DAC, |
---|
33 | MULTIIO_ADC, |
---|
34 | MULTIIO_DOUT, |
---|
35 | MULTIIO_DIN, |
---|
36 | MULTIIO_THERMO |
---|
37 | } rtems_multio_type; |
---|
38 | |
---|
39 | /** |
---|
40 | * @brief multiio control structure. |
---|
41 | */ |
---|
42 | typedef struct { |
---|
43 | |
---|
44 | /** |
---|
45 | * The Address that controls the pin. |
---|
46 | */ |
---|
47 | void *addr; |
---|
48 | |
---|
49 | /** |
---|
50 | * The adc, dac, din, dout... that this |
---|
51 | * structure controls |
---|
52 | */ |
---|
53 | int pin; |
---|
54 | } rtems_multiio_control; |
---|
55 | |
---|
56 | /** |
---|
57 | * @brief Initialize the multiio interface |
---|
58 | * |
---|
59 | * This function initializes the multiio interface. |
---|
60 | * |
---|
61 | * @return This method returns 0 if the interface was initialized |
---|
62 | * without any problems. |
---|
63 | */ |
---|
64 | int rtems_multiio_initialize(void); |
---|
65 | |
---|
66 | /** |
---|
67 | * @brief Get the name of the multiio device |
---|
68 | * |
---|
69 | * This function returns the name of the multiio device. |
---|
70 | * |
---|
71 | * @return This method returns a character string representing |
---|
72 | * the name of the multiio device. |
---|
73 | */ |
---|
74 | const char *rtems_multiio_get_name(void); |
---|
75 | |
---|
76 | /* |
---|
77 | * ADC |
---|
78 | */ |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief adc control structure. |
---|
82 | */ |
---|
83 | typedef rtems_multiio_control rtems_adc_control; |
---|
84 | |
---|
85 | /** |
---|
86 | * @brief Get the maximum number of adcs supported. |
---|
87 | * |
---|
88 | * This function returns the maximum supported adc. |
---|
89 | * Note that the adcs are numbered 0 to maximum. |
---|
90 | * |
---|
91 | * @return This method returns an integer representing the |
---|
92 | * maximum number of the adc supported. |
---|
93 | */ |
---|
94 | int rtems_adc_get_maximum(void); |
---|
95 | |
---|
96 | /** |
---|
97 | * @brief Get the rtems_adc_control for the @a adc. |
---|
98 | * |
---|
99 | * This function returns the control structure of the |
---|
100 | * given adc. |
---|
101 | * |
---|
102 | * @return This method returns the control structure |
---|
103 | * for @a adc. |
---|
104 | */ |
---|
105 | rtems_adc_control *adc_lookup( int adc ); |
---|
106 | |
---|
107 | /** |
---|
108 | * @brief Get adc channel voltage |
---|
109 | * |
---|
110 | * This function returns the voltage in volts for the |
---|
111 | * channel represented by the @a adc input. |
---|
112 | * |
---|
113 | * @param[in] adc that the voltage corresponds to |
---|
114 | * |
---|
115 | * @return This method returns the volts for the |
---|
116 | * @a adc channel. |
---|
117 | */ |
---|
118 | float rtems_adc_get_channel_voltage( rtems_adc_control *adc ); |
---|
119 | |
---|
120 | /* |
---|
121 | * DAC |
---|
122 | */ |
---|
123 | |
---|
124 | /** |
---|
125 | * @brief dac control structure. |
---|
126 | */ |
---|
127 | typedef rtems_multiio_control rtems_dac_control; |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief Get the maximum number of the supported dac |
---|
131 | * |
---|
132 | * This function returns the maximum number of supported |
---|
133 | * dacs. |
---|
134 | * |
---|
135 | * @return This method returns an integer representing the |
---|
136 | * maximum supported dac. |
---|
137 | */ |
---|
138 | int rtems_dac_get_maximum(void); |
---|
139 | |
---|
140 | /** |
---|
141 | * @brief Get the rtems_dac_control for the @a dac. |
---|
142 | * |
---|
143 | * This function returns the control structure of the |
---|
144 | * given dac. |
---|
145 | * |
---|
146 | * @return This method returns the control structure |
---|
147 | * for @a dac. |
---|
148 | */ |
---|
149 | rtems_dac_control *dac_lookup( int dac ); |
---|
150 | |
---|
151 | /** |
---|
152 | * @brief Get the mimimum voltage |
---|
153 | * |
---|
154 | * This function returns the minimum voltage that the |
---|
155 | * dac may be programmed to. |
---|
156 | * |
---|
157 | * @param[in] dac that the voltage corresponds to |
---|
158 | * |
---|
159 | * @return This method returns an floating point voltage |
---|
160 | * representing the minimum value the voltage may be |
---|
161 | * programmed to. |
---|
162 | */ |
---|
163 | float rtems_dac_get_minimum_voltage(rtems_dac_control *dac); |
---|
164 | |
---|
165 | /** |
---|
166 | * @brief Get the maximum voltage |
---|
167 | * |
---|
168 | * This function returns the maximum voltage that the |
---|
169 | * dac may be programmed to. |
---|
170 | * |
---|
171 | * @param[in] dac that the voltage corresponds to |
---|
172 | * |
---|
173 | * @return This method returns an floating point voltage |
---|
174 | * representing the maximum value the voltage may be |
---|
175 | * programmed to. |
---|
176 | */ |
---|
177 | float rtems_dac_get_maximum_voltage(rtems_dac_control *dac); |
---|
178 | |
---|
179 | /** |
---|
180 | * @brief Set the dac voltage |
---|
181 | * |
---|
182 | * This function sets the given @a dac voltage |
---|
183 | * to the specified @a voltage. |
---|
184 | * |
---|
185 | * @param[in] dac that the voltage corresponds to |
---|
186 | * |
---|
187 | * @param[in] voltage to set the dac to |
---|
188 | * |
---|
189 | * @return This method returns a 0 if floating point |
---|
190 | * voltage was set. |
---|
191 | */ |
---|
192 | int rtems_set_dac_voltage(rtems_dac_control *dac, float voltage); |
---|
193 | |
---|
194 | /* |
---|
195 | * Discrete Outputs |
---|
196 | */ |
---|
197 | |
---|
198 | /** |
---|
199 | * @brief discrete out control structure. |
---|
200 | */ |
---|
201 | typedef rtems_multiio_control rtems_dout_control; |
---|
202 | |
---|
203 | /** |
---|
204 | * @brief Get the maximum discrete out |
---|
205 | * |
---|
206 | * This function returns the maximum discrete out. |
---|
207 | * |
---|
208 | * @return This method returns an integer representing the |
---|
209 | * maximum discrete out. |
---|
210 | */ |
---|
211 | int rtems_dout_get_maximum(void); |
---|
212 | |
---|
213 | /** |
---|
214 | * @brief Get the rtems_dout_control for the @a dout. |
---|
215 | * |
---|
216 | * This function returns the control structure of the |
---|
217 | * given discrete out. |
---|
218 | * |
---|
219 | * @return This method returns the control structure |
---|
220 | * for @a dout. |
---|
221 | */ |
---|
222 | rtems_dout_control *dout_lookup( int dout ); |
---|
223 | |
---|
224 | /** |
---|
225 | * @brief Set the discrete out value |
---|
226 | * |
---|
227 | * This function sets the given @a dout |
---|
228 | * to the specified @a value. |
---|
229 | * |
---|
230 | * @param[in] dout to set |
---|
231 | * |
---|
232 | * @param[in] raw value to set |
---|
233 | * |
---|
234 | * @return This method returns a 0 if discrete out was |
---|
235 | * set to the raw value specified. |
---|
236 | */ |
---|
237 | int rtems_set_dout(rtems_dout_control *dout, int value); |
---|
238 | |
---|
239 | /* |
---|
240 | * Discrete Inputs |
---|
241 | */ |
---|
242 | |
---|
243 | /** |
---|
244 | * @brief discrete out control structure. |
---|
245 | */ |
---|
246 | typedef rtems_multiio_control rtems_din_control; |
---|
247 | |
---|
248 | /** |
---|
249 | * @brief Get the maximum discrete in |
---|
250 | * |
---|
251 | * This function returns the maximum discrete in. |
---|
252 | * |
---|
253 | * @return This method returns an integer representing |
---|
254 | * maximum supported discrete in. |
---|
255 | */ |
---|
256 | int rtems_din_get_maximum(void); |
---|
257 | |
---|
258 | /** |
---|
259 | * @brief Get the rtems_din_control for the @a din. |
---|
260 | * |
---|
261 | * This function returns the control structure of the |
---|
262 | * given discrete input. |
---|
263 | * |
---|
264 | * @return This method returns the control structure |
---|
265 | * for @a din. |
---|
266 | */ |
---|
267 | rtems_din_control *din_lookup( int din ); |
---|
268 | |
---|
269 | |
---|
270 | /** |
---|
271 | * @brief Get the discrete in value |
---|
272 | * |
---|
273 | * This function returns the raw value of the specified |
---|
274 | * @a discrete in. |
---|
275 | * |
---|
276 | * @return This method returns an integer representing the |
---|
277 | * raw value of @a din |
---|
278 | */ |
---|
279 | int rtems_din_get( rtems_din_control *din ); |
---|
280 | |
---|
281 | /** |
---|
282 | * @brief Flush buffered inputs |
---|
283 | * |
---|
284 | * This function flushes buffered discrete inputs. |
---|
285 | * |
---|
286 | * @return This method returns 0 when successful. |
---|
287 | */ |
---|
288 | int rtems_din_flush_buffered_interrupts(void); |
---|
289 | |
---|
290 | /** |
---|
291 | * @brief Discrete In wait interrupt with timeout |
---|
292 | * |
---|
293 | * This function will wait for ANY discrete in to change |
---|
294 | * state for up to @a milliseconds. |
---|
295 | * |
---|
296 | * @param[in] milliseconds to wait for a change |
---|
297 | * |
---|
298 | * @param[out] timestamp of when the change occurred |
---|
299 | * |
---|
300 | * @param[out] discrete in control structure for the changed discrete. |
---|
301 | * |
---|
302 | * @return This method returns 0 when successful. |
---|
303 | * |
---|
304 | */ |
---|
305 | int rtems_din_wait_interrupt_with_timestamp( |
---|
306 | int milliseconds, |
---|
307 | struct timespec *timestamp, |
---|
308 | rtems_din_control *din |
---|
309 | ); |
---|
310 | |
---|
311 | #ifdef __cplusplus |
---|
312 | } |
---|
313 | #endif |
---|
314 | |
---|
315 | #endif |
---|