vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / vmod / lib / libvmod12a22dioaio.c
blob285cd6faa18396817e7b2e711bc88b9a214dc6a0
1 /**
2 @file libvmod12a2.c
3 @brief Library file for the vmod12a2 driver
4 @author Juan David Gonzalez Cobas
5 @date October 17 2009
6 */
8 #include <sys/ioctl.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include "libvmod12a22dioaio.h"
13 #include <gm/moduletypes.h>
14 #include <dioaiolib.h>
16 #define VMOD12A2_MAX_MODULES 64
18 /**
19 * @brief Get a handle for a vmod12a2 device and channel
21 * A channel is selected by giving the LUN for the board
22 * and the channel number. The handle returned allows
23 * further reference to the same channel
25 * @param carrier_lun - carrier LUN for vmod card
26 * @param channel - selected channel for reading
28 * @return >0 - on success, device file descriptor number
29 * @return <0 - if failure
32 int vmod12a2_get_handle(unsigned int carrier_lun)
34 if(carrier_lun < 0 || carrier_lun >= VMOD12A2_MAX_MODULES){
35 fprintf(stderr, "libvmod12a22dioaio : Invalid lun %d\n", carrier_lun);
36 return -1;
38 return carrier_lun;
41 /**
42 * @brief perform a digital-to-analog conversion
44 * The output voltage depends on hardware configuration (default
45 * -10V..10V, configurable by jumpers to 0-10V range).
47 * @param fd Device handle identifying board
48 * @param channel Channel on the board to write to
49 * @param datum Digital 12-bit value (0x000-0xfff)
51 * @return 0 on success, <0 on failure
53 int vmod12a2_convert(int fd, int channel, int datum)
55 int ret;
56 char *error;
58 ret = DioChannelWrite(IocVMOD12A2, fd, channel, 2, datum);
59 if (ret < 0){
60 DioGetErrorMessage(ret, &error);
61 fprintf(stderr, "libvmod12a22dioaio : %s\n", error);
63 return ret;
66 /**
67 * @brief close a channel handle
69 * @param fd - Handle to close
71 int vmod12a2_close(int fd)
73 return 0;