Last change
on this file was
1cbabbe,
checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/09 at 20:34:51
|
2009-06-17 Joel Sherrill <joel.sherrill@…>
- buffered.c, dacbuff.c, dacout.c, flash.c, getall.c, getvolt.c,
kbhit.c, mio_io.c, mio_io_linux.c, mio_io_rtems.c, pcmmio.c, poll.c,
repeat.c, rtems_config.c: Clean up. Worked on RTEMS IRQ support code.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /* dacout.c WinSystems PCM-MIO driver Demonstration Program |
---|
2 | * |
---|
3 | * $Id$ |
---|
4 | * |
---|
5 | * Compile for GNU/Linux with: |
---|
6 | * |
---|
7 | * gcc dacout.c mio_io.o -o dacout |
---|
8 | * |
---|
9 | * |
---|
10 | * This extremely simple program uses the set_dac_voltage function to update |
---|
11 | * the dac output to a specific voltage. |
---|
12 | */ |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <stdlib.h> |
---|
16 | #include "mio_io.h" |
---|
17 | |
---|
18 | main(int argc, char *argv[]) |
---|
19 | { |
---|
20 | int channel = 0; |
---|
21 | float voltage; |
---|
22 | |
---|
23 | /* We must have arguments for channel and voltage */ |
---|
24 | |
---|
25 | if(argc != 3) |
---|
26 | { |
---|
27 | printf("usage : dacout channel voltage\n"); |
---|
28 | exit(1); |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | /* Channel is the first argument. We'll let the driver |
---|
33 | check for valid channel numbers just to show how the |
---|
34 | mio_error_string works |
---|
35 | */ |
---|
36 | channel = atoi(argv[1]); |
---|
37 | |
---|
38 | /* The same goes for the voltage argument. The driver will tell us |
---|
39 | if the input is out of range |
---|
40 | */ |
---|
41 | |
---|
42 | voltage = atof(argv[2]); |
---|
43 | |
---|
44 | printf("Setting DAC channel %d to %9.5f Volts\n",channel,voltage); |
---|
45 | |
---|
46 | set_dac_voltage(channel, voltage); |
---|
47 | |
---|
48 | |
---|
49 | /* Here's where any problems with the input parameters will be determined. |
---|
50 | by checking mio_error_code for a non-zero value we can detect error |
---|
51 | conditions. |
---|
52 | */ |
---|
53 | |
---|
54 | if(mio_error_code) |
---|
55 | { |
---|
56 | /* We'll print out the error and exit */ |
---|
57 | |
---|
58 | printf("%s\n",mio_error_string); |
---|
59 | exit(1); |
---|
60 | } |
---|
61 | |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
Note: See
TracBrowser
for help on using the repository browser.