]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/hudaqlib/hudaqlib.h
QEMU mf624.c formatted to make QEMU checkpatch.pl mostly happy.
[mf6xx.git] / src / hudaqlib / hudaqlib.h
1 /***************************************************************************\r
2 ****************************************************************************\r
3 *\r
4 *       Humusoft data acquisition library.\r
5 *\r
6 *       Copyright 2002-2008 Humusoft s.r.o.\r
7 *       Copyright 2009-2010 J.Fojtik\r
8 *\r
9 ******************************************************************************\r
10 *****************************************************************************/\r
11 \r
12 #ifndef HUDAQLIB_H__\r
13 #define HUDAQLIB_H__\r
14 \r
15 \r
16 /* All the functions have C naming convention in C++. */\r
17 #ifdef __cplusplus\r
18 extern "C" {\r
19 #endif  /* __cplusplus */\r
20 \r
21 \r
22 /* Define calling conventions. */\r
23 #ifdef _WIN32\r
24   #define HUDAQLIBPUBLIC __declspec(dllimport)\r
25   #ifdef _WIN64\r
26     #define HUDAQAPI\r
27   #else\r
28     #define HUDAQAPI __stdcall\r
29   #endif\r
30 #else\r
31   #define HUDAQLIBPUBLIC\r
32   #define HUDAQAPI\r
33 #endif\r
34 \r
35 \r
36 \r
37 /** Return codes for HUDAQ functions.\r
38  * @ingroup GroupConstants\r
39 */\r
40 typedef enum\r
41 {\r
42   HUDAQSUCCESS = 0,     ///< Success. @ifnot UNDOCUMENTED All other values mean failure. @endif\r
43 /** @cond UNDOCUMENTED */\r
44   HUDAQPARTIAL = 1,     ///< Several A/D or D/A operation succeeded and at least one failed, see ::HudaqAOWriteMultiple.\r
45   HUDAQFAILURE = 2,     ///< Unspecified problem occured (e.g. hardware failure).\r
46   HUDAQBADARG = 3,      ///< Unexpected arguments.\r
47   HUDAQNOTSUPPORTED = 4 ///< Device does not support this functionality.\r
48 /** @endcond UNDOCUMENTED */\r
49 } HUDAQSTATUS;\r
50 \r
51 \r
52 /** Subsystem identifiers.\r
53  * Used to identify individual subsystems of the board.\r
54  * @ingroup GroupChannelConfig */\r
55 typedef enum\r
56 {\r
57   HudaqAI  = 0x1000,              ///< Analog Input\r
58   HudaqAO  = 0x2000,              ///< Analog Output\r
59   HudaqDI  = 0x3000,              ///< Digital Input\r
60   HudaqDO  = 0x4000,              ///< Digital Output\r
61   HudaqEnc = 0x5000,              ///< Encoder\r
62   HudaqCtr = 0x6000,              ///< Counter\r
63   HudaqPWM = 0x7000,              ///< Pulse-Width Modulation Output\r
64 /** @cond UNDOCUMENTED */\r
65   HudaqStep= 0x8000,              ///< Stepper motor\r
66   HudaqIRQ = 0x9000,              ///< IRQ subsystem\r
67   HudaqSubsystemMASK = 0xFFFFF000 ///< Mask that separates subsystem number and its parameter.\r
68 /** @endcond UNDOCUMENTED */\r
69 } HudaqSubsystem;\r
70 \r
71 \r
72 /** Parameter identifiers. They are used as the third parameter to\r
73  *  ::HudaqGetParameter and ::HudaqSetParameter functions to specify which parameter should be\r
74  * configured. Please note that a particular\r
75  * device does not neccesarily support all functions.\r
76  *\r
77  * @ingroup GroupChannelConfig\r
78  */\r
79 typedef enum\r
80 {\r
81      /* Parameter names for Analog Input functions. */\r
82 /** @cond UNDOCUMENTED */\r
83   HudaqAIUNITS = HudaqAI,       ///< Set units of channel. See ::HudaqAIOUnits.\r
84 /** @endcond UNDOCUMENTED */\r
85   HudaqAIRANGE,                 ///< @brief Select analog input voltage range. @brief The range is selected by its index;\r
86                                 ///< the actual voltages corresponding to the range can be obtained by calling ::HudaqQueryRange. @par\r
87 /** @cond UNDOCUMENTED */\r
88   HudaqAINUMCHANNELS,           ///< Get number of analog input channels.\r
89 /** @endcond UNDOCUMENTED */\r
90 \r
91      /* Parameter names for Analog Output functions. */\r
92 /** @cond UNDOCUMENTED */\r
93   HudaqAOUNITS = HudaqAO,       ///< Set units of channel. See ::HudaqAIOUnits.\r
94 /** @endcond UNDOCUMENTED */\r
95   HudaqAORANGE,                 ///< @brief Select analog output voltage range. @brief The range is selected by its index;\r
96                                 ///< the actual voltages corresponding to the range can be obtained by calling ::HudaqQueryRange. @par\r
97 /** @cond UNDOCUMENTED */\r
98   HudaqAONUMCHANNELS,           ///< Get number of analog output channels.\r
99 /** @endcond UNDOCUMENTED */\r
100 \r
101      /* Parameter names for Digital Output functions. */\r
102 /** @cond UNDOCUMENTED */\r
103   HudaqDINUMCHANNELS = HudaqDI, ///< Get number of digital input channels.\r
104   HudaqDINUMBITS,               ///< Get number of bits in one digital output channel. @par\r
105 /** @endcond UNDOCUMENTED */\r
106 \r
107      /* Parameter names for Digital Output functions. */\r
108 /** @cond UNDOCUMENTED */\r
109   HudaqDONUMCHANNELS = HudaqDO, ///< Get number of digital output channels.\r
110   HudaqDONUMBITS,               ///< Get number of bits in one digital output channel. @par\r
111   HudaqDOMODE,                  ///< 0 set channel as input, 1 set channel as output\r
112 /** @endcond UNDOCUMENTED */\r
113 \r
114      /* Parameter names for Encoder Input functions. */\r
115   HudaqEncRESETONREAD = HudaqEnc,///< Automatically reset encoder pulse count after it is read; possible values are 0 (off) or 1 (on).\r
116   HudaqEncFILTER,               ///< Filter encoder inputs with a lowpass filter; possible values are 0 (off) or 1 (on).\r
117   HudaqEncMODE,                 ///< Encoder mode; for possible values see ::HudaqEncMode.\r
118   HudaqEncCOUNTCONTROL,         ///< Encoder count control; for possible values see ::HudaqEncCountControl.\r
119   HudaqEncRESETMODE,            ///< Encoder reset mode; for possible values see ::HudaqEncResetMode. @par\r
120 /** @cond UNDOCUMENTED */\r
121   HudaqEncI,                    ///< Read @a I signal. Only ::HudaqGetParameter is supported; option type int.\r
122   HudaqEncNUMCHANNELS,          ///< Get number of encoder channels.\r
123 /** @endcond UNDOCUMENTED */\r
124 \r
125      /* Parameter names for Counter Input functions. */\r
126   HudaqCtrRESETONREAD = HudaqCtr,///< Automatically reset counter pulse count after it is read; possible values are 0 (off) or 1 (on).\r
127   HudaqCtrCLOCKSOURCE,          ///< Counter clock source; for possible values see ::HudaqCtrClockSource.\r
128   HudaqCtrOUTPUTCONTROL,        ///< Counter output signal; for possible values see ::HudaqCtrOutputControl\r
129   HudaqCtrREPETITION,           ///< 0  - counter stops after terminal count; 1 - counter reloads and continues counting.\r
130   HudaqCtrLOADTOGGLE,           ///< 0 - always load from register A; 1 - alternate load registers A and B.\r
131   HudaqCtrDIRECTION,            ///< 0 - counter counts down; 1 - counter counts up.\r
132   HudaqCtrOUTTOGGLE,            ///< 0 - output is directly connected to TC; 1 - use flipflop that is toggled on every TC.\r
133   HudaqCtrTRIGSOURCE,           ///< Counter trigger source; for possible values see ::HudaqCtrTrigSource\r
134   HudaqCtrTRIGTYPE,             ///< Counter trigger edge; for possible values see ::HudaqCtrTrigType\r
135   HudaqCtrRETRIGGER,            ///< Counter can be retriggered: 0 - only when stopped; 1 - anytime\r
136   HudaqCtrGATESOURCE,           ///< Counter gate source; for possible values see ::HudaqCtrGateSource\r
137   HudaqCtrGATEPOLARITY,         ///< Counter gate polarity: 0 - gate low disables counting; 1 - gate high disables counting.\r
138   HudaqCtrFILTER,               ///< Filter counter inputs with a lowpass filter; possible values are 0 (off) or 1 (on). @par\r
139 /** @cond UNDOCUMENTED */\r
140   HudaqCtrNUMCHANNELS,          ///< Get number of counter channels. @par\r
141 /** @endcond UNDOCUMENTED */\r
142 \r
143      /* Parameter names for PWM Output functions. */\r
144 /** @cond UNDOCUMENTED */\r
145   HudaqPwmTHRESHOLD = HudaqPWM, ///< If you change PWM from slow frequency to fast, the last period for old frequency is in progress.\r
146                                 ///< e.g. if you switch from 1Hz to 1MHz you would wait up to 1s to change generated frequency.\r
147                                 ///< Frequencies below threshold are fixed for this artefact. Used algorithm ensures that a rest of\r
148                                 ///< pulse will not be larger than a period of new frequency.\r
149   HudaqPwmNUMCHANNELS,          ///< Get number of PWM channels.\r
150   HudaqPwmINPUT,                ///< Read @a Input signal. Only ::HudaqGetParameter is supported.\r
151 /** @endcond UNDOCUMENTED */\r
152   HudaqPwmPHASES,               ///< Read bits that coresponds to output phases. Only ::HudaqGetParameter is supported. (MF625 only)\r
153   HudaqPwmUPDOWN,               ///< Read UpDown flag. Only ::HudaqGetParameter is supported. (MF625 only)\r
154   HudaqPwmINVERSIONS,           ///< Read bits, that corresponds to inversions in all phases. (MF625 only)\r
155   HudaqPwmDEADBAND,             ///< Set dead band between phase and inverted phase  (MF625 only)\r
156   HudaqPwmOUTPUTCONTROL,        ///< Output phase signal; for possible values see ::HudaqCtrOutputControl\r
157   HudaqPwmCLOCKSOURCE,          ///< Counter clock source; for possible values see ::HudaqCtrClockSource.\r
158   HudaqPwmFILTER,               ///< Filter counter inputs with a lowpass filter; possible values are 0 (off) or 1 (on).\r
159   HudaqPwmGATESOURCE,           ///< Counter gate source; for possible values see ::HudaqCtrGateSource\r
160   HudaqPwmTRANSPARENT,          ///< 0 - Dual buffer is turned on, 1 - Dual buffer is turned off. (MF625 only)\r
161   HudaqPwmEMERGENCY,            ///< Define condition to block PWM output; for possible values see ::HudaqPwmEmergency (MF625 only)\r
162   HudaqPwmGATEPOLARITY,         ///< Counter gate polarity: 0 - gate low disables counting; 1 - gate high disables counting.\r
163   HudaqPwmOUTPUTUDCONTROL,      ///< Output up/down signal; for possible values see ::HudaqCtrOutputControl  @par\r
164 \r
165      /* Parameter names for Stepper Output functions. */\r
166 /** @cond UNDOCUMENTED */\r
167   HudaqStepFMIN = HudaqStep,    ///< Minimal speed of stepping motor [steps/s]; option type double.\r
168   HudaqStepFMAX,                ///< Maximal speed of stepping motor [steps/s]; option type double.\r
169   HudaqStepACCELERATION,        ///< Acceleration of stepping motor [steps/s^2]; option type double.\r
170   HudaqStepCURRENTPOSITION,     ///< Current position in steps; option type int.\r
171   HudaqStepREMAININGSTEPS,      ///< Amount of unrealised steps. Read only. Option type int.\r
172   HudaqStepTARGETPOSITION,      ///< Target position in steps. Read only. Option type int.\r
173   HudaqStepNUMCHANNELS          ///< Get number of stepper channels. @par\r
174 /** @endcond UNDOCUMENTED */\r
175 \r
176 } HudaqParameter;\r
177 \r
178 \r
179 /** @cond UNDOCUMENTED */\r
180 /* lowercase names for backward compatibility */\r
181 typedef enum\r
182 {\r
183   HudaqAIRange = HudaqAIRANGE,\r
184   HudaqAORange = HudaqAORANGE\r
185 } HudaqAIORange;\r
186 /** @endcond UNDOCUMENTED */\r
187 \r
188 \r
189 /** @cond UNDOCUMENTED */\r
190 /* this is documented elsewhere to avoid generation of class hierarchy */\r
191 /** Structure that contains one range record with low and high limit.\r
192  *\r
193  * @ingroup GroupChannelConfig\r
194  */\r
195 typedef struct\r
196 {\r
197   double Lo;   ///< Low range limit.\r
198   double Hi;   ///< Target position in steps. Read only. Option type int.\r
199 } HudaqRange;\r
200 /** @endcond UNDOCUMENTED */\r
201 \r
202 \r
203 /**\r
204  * The HUDAQ device handle data type.\r
205  * @ingroup GroupConstants\r
206  */\r
207 typedef size_t HUDAQHANDLE;\r
208 \r
209 \r
210 \r
211 /** @cond UNDOCUMENTED */\r
212 \r
213 /**\r
214  * Resource range structure.\r
215  * @ingroup GroupConstants\r
216  */\r
217 typedef struct\r
218 {\r
219   size_t Base;                        ///< Base addres/IO port.\r
220   size_t Length;                      ///< Amount resources.\r
221   unsigned int UioMappingIndex;         ///< With UIO driver, we are doing mmap on /dev/uioX; \r
222                                         //for different mappings we just add Index*PAGESIZE as offset\r
223 } HudaqResourceRange;\r
224 \r
225 \r
226 /**\r
227  * Resource information structure. Please note that every device has totally\r
228  * different meaning of this structure.\r
229  * @ingroup GroupConstants\r
230  */\r
231 typedef struct\r
232 {\r
233   int NumMemResources;                ///< Amount of memory mapped ranges in particular device.\r
234   HudaqResourceRange MemResources[8]; ///< Memory resources available for user access.\r
235   int NumIOResources;                 ///< Amount of IO ranges in particular device.\r
236   HudaqResourceRange IOResources[8];  ///< IO resources available for user access.\r
237   unsigned BusNumber;\r
238   unsigned SlotNumber;\r
239   unsigned VendorID;\r
240   unsigned DeviceID;\r
241   unsigned PropAddr;\r
242 } HudaqResourceInfo;\r
243 \r
244 \r
245 /** Options for ::HudaqOpenDevice parameter options\r
246  * @ingroup GroupConstants\r
247  */\r
248 typedef enum\r
249 {\r
250   HudaqOpenRESET = 0,         ///< Force initialization of hardware.\r
251   HudaqOpenNOINIT = 1,        ///< Skip initialization of device. Normally\r
252                               ///< you want initialization. This is reserved for multiple\r
253                               ///< access to device from different application or device enumeration.\r
254   //HudaqOpenForceInit = 2\r
255 } HudaqOpenOptions;\r
256 \r
257 /** @endcond UNDOCUMENTED */\r
258 \r
259 \r
260 /**\r
261  * Open a data acquisition device.\r
262  *   The device is put into initial state when being opened.\r
263  * @ingroup GroupBoardInitialization\r
264  * @param[in] devicename Device name.\r
265  *   This parameter is the device type as a string, for example "MF624".\r
266  * @param[in] deviceorder Device order.\r
267  *   One-based index to distinguish between devices of identical type.\r
268  * @param[in] options Reserved, must be zero.\r
269  * @return Device handle or zero on failure.\r
270  */\r
271 HUDAQLIBPUBLIC HUDAQHANDLE HUDAQAPI HudaqOpenDevice(const char* devicename, int deviceorder, int options);\r
272 \r
273 \r
274 /**\r
275  * Reset a data acquisition device.\r
276  *   This function puts the device into initial state.\r
277  * @ingroup GroupBoardInitialization\r
278  * @param[in] handle Device handle.\r
279  * @return ::HUDAQSUCCESS on success, other values on failure.\r
280  */\r
281 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqResetDevice(HUDAQHANDLE handle);\r
282 \r
283 \r
284 /**\r
285  * Close a data acquisition device handle.\r
286  *   The device handle becomes invalid after this call and must not be used any more.\r
287  *   The device state is not changed when its handle is closed. If it is required that the\r
288  *   device is set to a specific state before closing the application, it must be done explicitly\r
289  *   before calling this function.\r
290  * @ingroup GroupBoardInitialization\r
291  * @param[in] handle Device handle.\r
292  */\r
293 HUDAQLIBPUBLIC void HUDAQAPI HudaqCloseDevice(HUDAQHANDLE handle);\r
294 \r
295 \r
296 /** @cond UNDOCUMENTED */\r
297 \r
298 /**\r
299  * Get device resources.\r
300  * @ingroup GroupBoardInitialization\r
301  * @param[in] handle Device handle.\r
302  * @return Pointer to the resource information structure for the device, zero on error.\r
303 */\r
304 HUDAQLIBPUBLIC const HudaqResourceInfo* HUDAQAPI HudaqGetDeviceResources(HUDAQHANDLE handle);\r
305 \r
306 /** @endcond UNDOCUMENTED */\r
307 \r
308 \r
309 /** This procedure returns full device name. */\r
310 HUDAQLIBPUBLIC const char* HUDAQAPI HudaqGetBoardName(HUDAQHANDLE handle);\r
311 \r
312 \r
313 #ifdef _WIN32\r
314 /** This procedure returns system handle to a kernel driver. */\r
315 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqWaitForIrq(HUDAQHANDLE handle, int TimeOut);\r
316 #endif\r
317 \r
318 \r
319 /** @cond UNDOCUMENTED */\r
320 \r
321 /** Possible values for HudaqAOUNITS. Used in both Analog inputs and Analog outputs channels.\r
322  * See ::HudaqAIUNITS and ::HudaqAOUNITS.\r
323  * @ingroup GroupChannelConfig\r
324  */\r
325 typedef enum\r
326 {\r
327   HudaqAIOVolts = 0,            ///< Use analog values in volts.\r
328   HudaqAIORaw  = 1              ///< Raw value of A/D converter.\r
329 } HudaqAIOUnits;\r
330 \r
331 /** @endcond UNDOCUMENTED */\r
332 \r
333 \r
334 \r
335 /**\r
336  * Read data from a single analog input channel.\r
337  * @ingroup GroupAnalogInput\r
338  * @param[in] handle  Device handle.\r
339  * @param[in] channel Analog input channel number.\r
340  * @return Value read from the analog input channel.\r
341 */\r
342 HUDAQLIBPUBLIC double HUDAQAPI HudaqAIRead(HUDAQHANDLE handle, unsigned channel);\r
343 \r
344 /**\r
345  * Read data from multiple analog input channels.\r
346  *  The analog input channels are read with the minimum possible interval between individual\r
347  *  channels or simultaneously if the device supports this feature.\r
348  * @ingroup GroupAnalogInput\r
349  * @param[in] handle   Device handle.\r
350  * @param[in] number   Number of channels to read.\r
351  * @param[in] channels Array of channel numbers that will be read.\r
352  *   The array must contain the specified number of channel numbers.\r
353  * @param[out] values  Pointer to the array to be filled with values read from the analog input channels.\r
354  *   The array is allocated by the caller and must contain enough space to hold all the values read.\r
355  * @return ::HUDAQSUCCESS on success, other values on failure.\r
356 */\r
357 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqAIReadMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, double* values);\r
358 \r
359 \r
360 /**\r
361  * Write data to a single analog output channel.\r
362  * @ingroup GroupAnalogOutput\r
363  * @param[in] handle  Device handle.\r
364  * @param[in] channel Analog output channel number.\r
365  * @param[in] value   Value to write to the analog output channel.\r
366  */\r
367 HUDAQLIBPUBLIC void HUDAQAPI HudaqAOWrite(HUDAQHANDLE handle, unsigned channel, double value);\r
368 \r
369 \r
370 /**\r
371  * Write data to multiple analog output channels.\r
372  *  The analog output channels are updated with the minimum possible interval between individual\r
373  *  channels or simultaneously if the device supports this feature.\r
374  * @ingroup GroupAnalogOutput\r
375  * @param[in] handle   Device handle.\r
376  * @param[in] number   Number of channels to be written.\r
377  * @param[in] channels Array of channel numbers that will be written.\r
378  *   The array must contain the specified number of channel numbers.\r
379  * @param[in] values   Array of values to be written to the analog output channels.\r
380  *   The array must contain the specified number of values.\r
381  * @return ::HUDAQSUCCESS on success, other values on failure.\r
382  */\r
383 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqAOWriteMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, const double* values);\r
384 \r
385 \r
386 /**\r
387  * Read a single bit from a digital input channel.\r
388  * @ingroup GroupDigitalInput\r
389  * @param[in] handle  Device handle.\r
390  * @param[in] channel Digital input channel number.\r
391  * @param[in] bit     Bit position in the channel.\r
392  * @return Bit value read from the specified bit.\r
393  */\r
394 HUDAQLIBPUBLIC int HUDAQAPI HudaqDIReadBit(HUDAQHANDLE handle, unsigned channel, unsigned bit);\r
395 \r
396 /**\r
397  * Read data from a single digital input channel.\r
398  *  The number of bits in a digital input channel is device specific.\r
399  * @ingroup GroupDigitalInput\r
400  * @param[in] handle  Device handle.\r
401  * @param[in] channel Digital input channel number.\r
402  * @return Value read from the digital input channel.\r
403  */\r
404 HUDAQLIBPUBLIC int HUDAQAPI HudaqDIRead(HUDAQHANDLE handle, unsigned channel);\r
405 \r
406 /**\r
407  * Read data from multiple digital input channels.\r
408  * @ingroup GroupDigitalInput\r
409  * @param[in] handle   Device handle.\r
410  * @param[in] number   Number of channels to read.\r
411  * @param[in] channels Array of channel numbers that will be read.\r
412  *   The array must contain the specified number of channel numbers.\r
413  * @param[out] values  Pointer to the array to be filled with values read from the digital input channels.\r
414  *   The array is allocated by the caller and must contain enough space to hold all the values read.\r
415  * @return ::HUDAQSUCCESS on success, other values on failure.\r
416  */\r
417 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDIReadMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, unsigned* values);\r
418 \r
419 \r
420 /**\r
421  * Write data to a single bit of a digital output channel.\r
422  * @ingroup GroupDigitalOutput\r
423  * @param[in] handle  Device handle.\r
424  * @param[in] channel Digital output channel number.\r
425  * @param[in] bit     Bit position in channel specified\r
426  * @param[in] value   Bit value to be written to the specified bit.\r
427  */\r
428 HUDAQLIBPUBLIC void HUDAQAPI HudaqDOWriteBit(HUDAQHANDLE handle, unsigned channel, unsigned bit, int value);\r
429 \r
430 /**\r
431  * Write data to a single digital output channel.\r
432  *  The number of bits in a digital output channel is device specific.\r
433  * @ingroup GroupDigitalOutput\r
434  * @param[in] handle  Device handle.\r
435  * @param[in] channel Digital output channel number.\r
436  * @param[in] value   Value to be written into digital output.\r
437  * @return ::HUDAQSUCCESS on success, other values on failure.\r
438  */\r
439 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDOWrite(HUDAQHANDLE handle, unsigned channel, unsigned value);\r
440 \r
441 /**\r
442  * Modify multiple bits in a single digital output channel.\r
443  *   All the bits are modified simultaneously.\r
444  * @ingroup GroupDigitalOutput\r
445  * @param[in] handle  Device handle.\r
446  * @param[in] channel Digital output channel number.\r
447  * @param[in] mask    Mask that specifies bits that will be modified. Bits that are 1 will be assigned the corresponding bits of @c value,\r
448  *                    bits that are 0 will be left untouched.\r
449  * @param[in] value   Value to write. Only the bits specified by @c mask are modified, the other bits are ignored.\r
450 */\r
451 HUDAQLIBPUBLIC void HUDAQAPI HudaqDOWriteMultipleBits(HUDAQHANDLE handle, unsigned channel, unsigned mask, unsigned value);\r
452 \r
453 \r
454 /**\r
455  * Write data to multiple digital output channels.\r
456  * @ingroup GroupDigitalOutput\r
457  * @param[in] handle   Device handle.\r
458  * @param[in] number   Number of channels to be written.\r
459  * @param[in] channels Array of channel numbers that will be written.\r
460  *   The array must contain the specified number of channel numbers.\r
461  * @param[in] values   Array of values to be written to the digital output channels.\r
462  *   The array must contain the specified number of values.\r
463  * @return ::HUDAQSUCCESS on success, other values on failure.\r
464 */\r
465 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDOWriteMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, const unsigned* values);\r
466 \r
467 \r
468 /**\r
469  * Counter clock sources.\r
470  * @ingroup GroupChannelConfig\r
471  */\r
472 typedef enum\r
473 {\r
474   HudaqCtrCLOCK50MHz = 0,        ///< Internal clock 50MHz.                 (MF624 and MF625)\r
475   HudaqCtrCLOCK10MHz = 1,        ///< Internal clock 10MHz.                 (MF624 and MF625)\r
476   HudaqCtrCLOCK1MHz = 2,         ///< Internal clock 1MHz.                  (MF624 and MF625)\r
477   HudaqCtrCLOCK100kHz = 3,       ///< Internal clock 100kHz.                (MF624 and MF625)\r
478   HudaqCtrCLOCKINRISING = 5,     ///< External input, count on rising edge. (MF614, MF624 and MF625)\r
479   HudaqCtrCLOCKINFALLING = 6,    ///< External input, count on falling edge.(MF614, MF624 and MF625)\r
480   HudaqCtrCLOCKINEITHER = 7,     ///< External input, count on either edge. (MF624 and MF625)\r
481   HudaqCtrCLOCKPREVRISING = 9,   ///< Output of previous counter, count on rising edge.  (MF614, MF624 and MF625)\r
482   HudaqCtrCLOCKPREVFALLING = 10, ///< Output of previous counter, count on falling edge. (MF614, MF624 and MF625)\r
483   HudaqCtrCLOCKPREVEITHER = 11,  ///< Output of previous counter, count on either edge.  (MF624 and MF625)\r
484   HudaqCtrCLOCKNEXTRISING = 13,  ///< Output of next counter, count on rising edge.      (MF624 and MF625)\r
485   HudaqCtrCLOCKNEXTFALLING = 14, ///< Output of next counter, count on falling edge.     (MF624 and MF625)\r
486   HudaqCtrCLOCKNEXTEITHER = 15,  ///< Output of next counter, count on either edge.      (MF624 and MF625)\r
487   HudaqCtrCLOCK20MHz,            ///< Internal clock 20MHz.                 (MF614 only)\r
488   HudaqCtrCLOCK2MHz,             ///< Internal clock 2MHz.                  (MF614 only)\r
489   HudaqCtrCLOCK200kHz,           ///< Internal clock 200kHz.                (MF614 only)\r
490   HudaqCtrCLOCK20kHz,            ///< Internal clock 20kHz.                 (MF614 only)\r
491   HudaqCtrCLOCK2kHz              ///< Internal clock 2kHz.                  (MF614 only)\r
492 } HudaqCtrClockSource;\r
493 \r
494 \r
495 /**\r
496  * Counter output control.\r
497  * @ingroup GroupChannelConfig\r
498  */\r
499 typedef enum\r
500 {\r
501   HudaqCtrOUTPUTNORMAL = 0,     ///< Normal counter output.                               (MF614 and MF624)\r
502   HudaqCtrOUTPUTINVERTED = 1,   ///< Inverted counter output.                             (MF624 only)\r
503   HudaqCtrOUTPUT_0 = 2,         ///< Force 0 on output, counter is still counting.        (MF624 only)\r
504   HudaqCtrOUTPUT_1 = 3          ///< Force 1 on output,counter is still counting.         (MF624 only)\r
505 } HudaqCtrOutputControl;\r
506 \r
507 \r
508 /**\r
509  * Counter trigger source.\r
510  * @ingroup GroupChannelConfig\r
511  */\r
512 typedef enum\r
513 {\r
514   HudaqCtrTRIGDISABLE = 0,      ///< Trigger is disabled.\r
515   HudaqCtrTRIGINPUT = 1,        ///< Trigger by counter input (TxIn).\r
516   HudaqCtrTRIGPREV = 2,         ///< Trigger by previous counter output.\r
517   HudaqCtrTRIGNEXT = 3          ///< Trigger by next counter output.\r
518 } HudaqCtrTrigSource;\r
519 \r
520 \r
521 /**\r
522  * Counter trigger type.\r
523  * @ingroup GroupChannelConfig\r
524  */\r
525 typedef enum\r
526 {\r
527   HudaqCtrTRIGNONE = 0,         ///< Trigger is inactive.\r
528   HudaqCtrTRIGRISING = 1,       ///< Trigger by rising edge of trigger signal.\r
529   HudaqCtrTRIGFALLING = 2,      ///< Trigger by falling edge of trigger signal.\r
530   HudaqCtrTRIGEITHER = 3        ///< Trigger by either edge of trigger signal.\r
531 } HudaqCtrTrigType;\r
532 \r
533 \r
534 /**\r
535  * Counter gate source.  Please note ::HudaqCtrGATEPOLARITY for full undrestanding\r
536    gate functionality.\r
537  * @ingroup GroupChannelConfig\r
538  */\r
539 typedef enum\r
540 {\r
541   HudaqCtrGATEHIGH = 0,         ///< Gate is forced to logical high.    (MF614, MF624 and MF625)\r
542   HudaqCtrGATEINPUT = 1,        ///< Gate by counter input (TxIn).      (MF614, MF624 and MF625)\r
543   HudaqCtrGATEPREV = 2,         ///< Gate by previous counter output.   (MF624 and MF625)\r
544   HudaqCtrGATENEXT = 3          ///< Gate by next counter output.       (MF624 and MF625)\r
545 } HudaqCtrGateSource;\r
546 \r
547 \r
548 /**\r
549  * Reset counter pulse count.\r
550  * If the counter hardware is used by another subsystem, it is switched to counting mode and\r
551  * the default input is selected. If the counter is already in counting mode, its input selection\r
552  * is not changed.\r
553  * @ingroup GroupCounterInput\r
554  * @param[in] handle  Device handle.\r
555  * @param[in] channel Number of counter channel.\r
556  */\r
557 HUDAQLIBPUBLIC void HUDAQAPI HudaqCtrReset(HUDAQHANDLE handle, unsigned channel);\r
558 \r
559 \r
560 /**\r
561  * Read counter pulse count.\r
562  * The returned value is the number of pulses counted by the counter since reset.\r
563  * @ingroup GroupCounterInput\r
564  * @param[in] handle  Device handle.\r
565  * @param[in] channel Counter input channel number.\r
566  * @return Value read from the counter input channel.\r
567  */\r
568 HUDAQLIBPUBLIC int HUDAQAPI HudaqCtrRead(HUDAQHANDLE handle, unsigned channel);\r
569 \r
570 \r
571 /** Encoder counting modes.\r
572  * @ingroup GroupChannelConfig\r
573  */\r
574 typedef enum\r
575 {\r
576   HudaqEncMODEIRC = 0,     ///< Count IRC pulses on inputs @a A and @a B (MF614, MF624 and MF625)\r
577   HudaqEncMODERISING,      ///< Count pulses on @a A, rising edge, @a B specifies direction (MF614, MF624 and MF625)\r
578   HudaqEncMODEFALLING,     ///< Count pulses on @a A, falling edge, @a B specifies direction (MF624 and MF625)\r
579   HudaqEncMODEEITHER       ///< Count pulses on @a A, either edge, @a B specifies direction (MF624 and MF625)\r
580 } HudaqEncMode;\r
581 \r
582 \r
583 /** Encoder count control.\r
584  * Encoder count control allows enabling or disabling pulse counting based on software or hardware conditions.\r
585  * @ingroup GroupChannelConfig\r
586  */\r
587 typedef enum\r
588 {\r
589   HudaqEncCOUNTENABLE = 0, ///< Encoder counting is enabled. (MF614, MF624 and MF625)\r
590   HudaqEncCOUNTDISABLE,    ///< Encoder counting is disabled. (MF624 and MF625)\r
591   HudaqEncCOUNTI0,         ///< Encoder counting is enabled when input @a I is at logical low, disabled when input @a I is at logical high. (MF624 and MF625)\r
592   HudaqEncCOUNTI1          ///< Encoder counting is enabled when input @a I is at logical high, disabled when input @a I is at logical low. (MF624 and MF625)\r
593 } HudaqEncCountControl;\r
594 \r
595 \r
596 /** Encoder reset mode.\r
597  * Encoder reset mode allows enabling the functionality of resetting the encoder pulse count by external signal.\r
598  * @ingroup GroupChannelConfig\r
599  */\r
600 typedef enum\r
601 {\r
602   HudaqEncRESNONE = 0,     ///< Encoder is not being reset by external signal. (MF614, MF624 and MF625)\r
603   HudaqEncRESPERMANENT,    ///< Encoder is permanently reset; the encoder does not count in this mode. (MF624 only)\r
604   HudaqEncRESI0,           ///< Reset encoder pulse count when input @a I is at logical low. (MF614, MF624 and MF625)\r
605   HudaqEncRESI1,           ///< Reset encoder pulse count when input @a I is at logical high. (MF624 and MF625)\r
606   HudaqEncRESIRISING,      ///< Reset encoder pulse count on rising edge of input @a I . (MF614, MF624 and MF625)\r
607   HudaqEncRESIFALLING,     ///< Reset encoder pulse count on falling edge of input @a I . (MF614, MF624 and MF625)\r
608   HudaqEncRESIEITHER       ///< Reset encoder pulse count on either edge of input @a I . (MF624 and MF625)\r
609 } HudaqEncResetMode;\r
610 \r
611 \r
612 \r
613 /**\r
614  * Reset encoder pulse count.\r
615  * @ingroup GroupEncoderInput\r
616  * @param[in] handle  Device handle.\r
617  * @param[in] channel Encoder input channel number.\r
618  */\r
619 HUDAQLIBPUBLIC void HUDAQAPI HudaqEncReset(HUDAQHANDLE handle, unsigned channel);\r
620 \r
621 \r
622 /**\r
623  * Read encoder pulse count.\r
624  * The returned value is the number of pulses counted by the encoder since reset.\r
625  * @ingroup GroupEncoderInput\r
626  * @param[in] handle  Device handle.\r
627  * @param[in] channel Encoder input channel number.\r
628  * @return Value read from the encoder input channel.\r
629  */\r
630 HUDAQLIBPUBLIC int HUDAQAPI HudaqEncRead(HUDAQHANDLE handle, unsigned channel);\r
631 \r
632 \r
633 /**\r
634  * Emergency PWM output shutdown could be set to the following mode. (MF625 only)\r
635  */\r
636 typedef enum\r
637 {\r
638   HudaqPwmEMERGENCYOFF = 0,     ///< No emergency is employed.\r
639   HudaqPwmEMERGENCYINPUT,       ///< Emergency input in '1' shuts all outputs to '0'.\r
640   HudaqPwmEMERGENCYNOTINPUT,    ///< Emergency input in '0' shuts all outputs to '0'.\r
641   HudaqPwmEMERGENCYON,          ///< All outputs are shut to '0' permanently.\r
642 } HudaqPwmEmergency;\r
643 \r
644 \r
645 /**\r
646  * Generate pulse-width modulation signal on a counter output.\r
647  * @ingroup GroupPWMOutput\r
648  * @param[in] handle    Device handle.\r
649  * @param[in] channel   Counter output channel number.\r
650  * @param[in] frequency Output frequency in Hz.\r
651  * @param[in] duty      Output signal duty.\r
652  *    The duty is the fraction of signal period during which the signal is at high level.@n\r
653  *    Value 0 means permanent logical low on the counter output.@n\r
654  *    Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n\r
655  *    Value 1 means permanent logical high on the counter output.@n\r
656  * @return ::HUDAQSUCCESS on success, other values on failure.\r
657  */\r
658 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqPWMWrite(HUDAQHANDLE handle, unsigned channel, double frequency, double duty);\r
659 \r
660 \r
661 /**\r
662  * Generate 3 phases + their inversions pulse-width modulation signal on a specialized counter.\r
663  * @ingroup GroupPWMOutput\r
664  * @param[in] handle    Device handle.\r
665  * @param[in] channel   Counter output channel number.\r
666  * @param[in] frequency Output frequency in Hz.\r
667  * @param[in] duty1     Output signal duty for first phase.\r
668  * @param[in] duty2     Output signal duty for second phase.\r
669  * @param[in] duty3     Output signal duty for third phase.\r
670  *    The duty is the fraction of signal period during which the signal is at high level.@n\r
671  *    Value 0 means permanent logical low on the counter output.@n\r
672  *    Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n\r
673  *    Value 1 means permanent logical high on the counter output.@n\r
674  * @return ::HUDAQSUCCESS on success, other values on failure.\r
675  */\r
676 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqPWM3Write(HUDAQHANDLE handle, unsigned channel, double frequency, double duty1, double duty2, double duty3);\r
677 \r
678 \r
679 /** @cond UNDOCUMENTED */\r
680 \r
681 /**\r
682  * Generate multiphase pulse-width modulation signal on a specialized PWM counter.\r
683  * @ingroup GroupPWMOutput\r
684  * @param[in] handle    Device handle.\r
685  * @param[in] channel   Counter output channel number.\r
686  * @param[in] phasenum  Number of phases (sub channels) to be written.\r
687  * @param[in] phases    Array of phase numbers (sub channels) that will be written.\r
688  * @param[in] frequency Output frequency in Hz (same for all phases).\r
689  * @param[in] duties    Array of output signal duties.\r
690  *    The duty is the fraction of signal period during which the signal is at high level.@n\r
691  *    Value 0 means permanent logical low on the counter output.@n\r
692  *    Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n\r
693  *    Value 1 means permanent logical high on the counter output.@n\r
694  * @return ::HUDAQSUCCESS on success, other values on failure.\r
695  */\r
696 HUDAQLIBPUBLIC HUDAQSTATUS HudaqPWMWriteMultiphase(HUDAQHANDLE handle, unsigned channel, unsigned phasenum, const unsigned *phases, double frequency, const double *duties);\r
697 \r
698 /**\r
699  * Move stepping motor to a target position. During a first time call it resets internal\r
700  * position counter and sets 2 internal counters for driving one stepper motor.\r
701  * @ingroup GroupStepperOutput\r
702  * @param[in] handle  Device handle.\r
703  * @param[in] channel number of counter.\r
704  * @param[in] position Target position to move stepping motor. (It is absolute position, not a difference.)\r
705  * @return ::HUDAQSUCCESS on success, other values on failure.\r
706  */\r
707 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqStepWrite(HUDAQHANDLE handle, unsigned channel, int position);\r
708 \r
709 /** @endcond UNDOCUMENTED */\r
710 \r
711 \r
712 \r
713 /**\r
714  * Reads single channel configuration for a given subsystem.\r
715  * Not all devices support all the parameters.\r
716  * @ingroup GroupChannelConfig\r
717  * @param[in] handle  Device handle.\r
718  * @param[in] channel Channel number. The channel type is determined by the parameter identifier @c param.\r
719  * @param[in] param Parameter identifier; see ::HudaqParameter for possible values.\r
720  * @return value Value of the parameter; see individual parameter descriptions for description of the values.\r
721  */\r
722 HUDAQLIBPUBLIC double HUDAQAPI HudaqGetParameter(HUDAQHANDLE handle, unsigned channel, HudaqParameter param);\r
723 \r
724 \r
725 /**\r
726  * Configures single channel of a given subsystem.\r
727  * Not all devices support all the parameters and all the parameter values.\r
728  * @ingroup GroupChannelConfig\r
729  * @param[in] handle  Device handle.\r
730  * @param[in] channel Channel number. The channel type is determined by the parameter identifier @c param.\r
731  * @param[in] param Parameter identifier; see ::HudaqParameter for possible values.\r
732  * @param[in] value Value of the parameter; see individual parameter descriptions for possible values.\r
733  * @return ::HUDAQSUCCESS on success, other values on failure.\r
734  */\r
735 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqSetParameter(HUDAQHANDLE handle, unsigned channel, HudaqParameter param, double value);\r
736 \r
737 \r
738 /**\r
739  * Query voltage ranges by their indices.\r
740  * This function translates the voltage range index to actual voltage range limits for the device.\r
741  * No change is done to device configuration; use ::HudaqSetParameter to set a voltage range by its index; use\r
742  * ::HudaqGetParameter to get the index of the currently set voltage range.\r
743 \r
744  * @ingroup GroupChannelConfig\r
745  * @param[in] handle Device handle.\r
746  * @param[in] S      Subsystem identifier; possible values are ::HudaqAI or ::HudaqAO.\r
747  * @param[in] item   Zero-based voltage range index.\r
748  * @return    Pointer to a structure containing the voltage range limits for the specified index, or @c NULL for an invalid range index.\r
749  * The structure pointed to by the returned pointer is defined like this:\r
750  * @code\r
751  * typedef struct\r
752  * {\r
753  *   double Lo;\r
754  *   double Hi;\r
755  * } HudaqRange;\r
756  * @endcode\r
757  */\r
758 HUDAQLIBPUBLIC const HudaqRange * HUDAQAPI HudaqQueryRange(HUDAQHANDLE handle, HudaqSubsystem S, unsigned item);\r
759 \r
760 \r
761 \r
762 /* All the functions have C naming convention in C++. */\r
763 #ifdef __cplusplus\r
764 }\r
765 #endif  /* __cplusplus */\r
766 \r
767 \r
768 #endif  /* HUDAQLIB_H__ */\r