Line | |
---|
1 | /* dacout.c WinSystems PCM-MIO driver Demonstration Program |
---|
2 | * |
---|
3 | * $Header$ |
---|
4 | * |
---|
5 | * $Id$ |
---|
6 | * |
---|
7 | * $Log$ |
---|
8 | * |
---|
9 | * |
---|
10 | * Compile with : |
---|
11 | * |
---|
12 | * |
---|
13 | * gcc dacout.c mio_io.o -o dacout |
---|
14 | * |
---|
15 | * |
---|
16 | * This extremely simple program uses the set_dac_voltage function to update |
---|
17 | * the dac output to a specific voltage. |
---|
18 | */ |
---|
19 | |
---|
20 | #include <stdio.h> |
---|
21 | #include <stdlib.h> |
---|
22 | #include "mio_io.h" |
---|
23 | |
---|
24 | main(int argc, char *argv[]) |
---|
25 | { |
---|
26 | int channel = 0; |
---|
27 | float voltage; |
---|
28 | |
---|
29 | /* We must have arguments for channel and voltage */ |
---|
30 | |
---|
31 | if(argc != 3) |
---|
32 | { |
---|
33 | printf("usage : dacout channel voltage\n"); |
---|
34 | exit(1); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | /* Channel is the first argument. We'll let the driver |
---|
39 | check for valid channel numbers just to show how the |
---|
40 | mio_error_string works |
---|
41 | */ |
---|
42 | channel = atoi(argv[1]); |
---|
43 | |
---|
44 | /* The same goes for the voltage argument. The driver will tell us |
---|
45 | if the input is out of range |
---|
46 | */ |
---|
47 | |
---|
48 | voltage = atof(argv[2]); |
---|
49 | |
---|
50 | printf("Setting DAC channel %d to %9.5f Volts\n",channel,voltage); |
---|
51 | |
---|
52 | set_dac_voltage(channel, voltage); |
---|
53 | |
---|
54 | |
---|
55 | /* Here's where any problems with the input parameters will be determined. |
---|
56 | by checking mio_error_code for a non-zero value we can detect error |
---|
57 | conditions. |
---|
58 | */ |
---|
59 | |
---|
60 | if(mio_error_code) |
---|
61 | { |
---|
62 | /* We'll print out the error and exit */ |
---|
63 | |
---|
64 | printf("%s\n",mio_error_string); |
---|
65 | exit(1); |
---|
66 | } |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
Note: See
TracBrowser
for help on using the repository browser.