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:
946 bytes
|
Line | |
---|
1 | /* getvolt.c WinSystems PCM-MIO driver Demonstration Program |
---|
2 | * |
---|
3 | * $Id$ |
---|
4 | * |
---|
5 | * Compile for GNU/Linux with: |
---|
6 | * |
---|
7 | * |
---|
8 | * gcc getvolt.c mio_io.o -o getvolt |
---|
9 | * |
---|
10 | * |
---|
11 | * This program demonstrates the adc_auto_get_channel_voltage |
---|
12 | * function. It reads the voltage on the channel specified |
---|
13 | * prints the value and then exits. |
---|
14 | */ |
---|
15 | |
---|
16 | #include <stdio.h> |
---|
17 | #include <stdlib.h> |
---|
18 | #include "mio_io.h" |
---|
19 | |
---|
20 | main(int argc, char *argv[]) |
---|
21 | { |
---|
22 | int channel = 0; |
---|
23 | float result; |
---|
24 | |
---|
25 | |
---|
26 | /* If an argument is present,we'll use is as the channel |
---|
27 | number. Otherwise we'll default to channel 0 |
---|
28 | */ |
---|
29 | |
---|
30 | if(argc > 1) |
---|
31 | channel = atoi(argv[1]); |
---|
32 | |
---|
33 | /* We'll let the driver validate the channel number */ |
---|
34 | |
---|
35 | result = adc_auto_get_channel_voltage(channel); |
---|
36 | |
---|
37 | /* Check for an error */ |
---|
38 | |
---|
39 | if(mio_error_code) |
---|
40 | { |
---|
41 | |
---|
42 | /* If an error occured. Display the error and exit */ |
---|
43 | |
---|
44 | printf("%s\n",mio_error_string); |
---|
45 | exit(1); |
---|
46 | } |
---|
47 | |
---|
48 | /* Print the results */ |
---|
49 | |
---|
50 | printf(" Channel %d = %9.4f\n",channel,result); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.