source: multiio/pcmmio/original/getvolt.c @ da59d43

Last change on this file since da59d43 was 2bae2aa, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 8, 2009 at 2:52:43 PM

Initial import.

  • Property mode set to 100644
File size: 949 bytes
Line 
1/* getvolt.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 getvolt.c mio_io.o -o getvolt
14*
15*
16*       This program demonstrates the adc_auto_get_channel_voltage
17*       function. It reads the voltage on the channel specified
18*       prints the value and then exits.
19*
20*/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include "mio_io.h"
25
26main(int argc, char *argv[])
27{
28int channel = 0;
29float result;
30
31
32        /* If an argument is present,we'll use is as the channel
33           number. Otherwise we'll default to channel 0
34   */
35
36        if(argc > 1)
37                channel = atoi(argv[1]);
38
39        /* We'll let the driver validate the channel number */
40
41        result = adc_auto_get_channel_voltage(channel);
42
43        /* Check for an error */
44
45        if(mio_error_code)
46        {
47
48                /* If an error occured. Display the error and exit */
49
50                printf("%s\n",mio_error_string);
51                exit(1);
52        }
53
54        /* Print the results */
55
56        printf(" Channel %d  =  %9.4f\n",channel,result);
57}
58
59
Note: See TracBrowser for help on using the repository browser.