source: multiio/pcmmio/original/dacbuff.c @ f89686d

Last change on this file since f89686d 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.9 KB
Line 
1/* dacbuff.c Demonstration program for WinSystems PCM-MIO Driver */
2
3/*
4*
5* $Id$
6*
7*
8* Compile for GNU/Linux with:
9*
10*     gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
11*
12*
13* This program demonstrates the adc_buffered_channel_conversions function
14* which allows for a programmed sequence of conversions to be accomplished
15* with a single call.
16*/
17
18#include "mio_io.h"   
19#include <stdio.h>
20#include <stdlib.h>
21
22// This array will store the results of 2000 conversions
23
24unsigned char commands[16385];
25unsigned short values[16384];
26
27void init_keyboard(void);
28void close_keyboard(void);
29int kbhit(void);
30int readch(void);
31
32
33int main(int argc, char* argv[])
34{
35unsigned x;
36
37
38        // Set all 8 DAC outputs to a known span +/- 10V
39
40        for(x=0; x<8; x++)
41                {
42                        set_dac_span(x, DAC_SPAN_BI10);
43                        if(mio_error_code)
44                        {
45                                printf("\n%s\n",mio_error_string);
46                                exit(1);
47                        }
48                }
49
50
51        // For this program we are going to use only channel 0
52        //   with 16384 updates.
53       
54
55        // The data will step up from -10V to +10V in 4/65536 increments
56
57        for(x = 0; x < 16384; x++)
58        {
59            commands[x] = 0;
60            values[x] = x * 4;
61        }
62
63        /* We need to terminate the command so that it knows when its done */
64
65        commands[16384] = 0xff;
66
67 
68        /* This program runs until a key is pressed. It prints nothing
69           on the screen to keep from slowing it down. To see the results
70           it would be necessary to attach an oscilloscope to DAC channel
71           0.
72        */
73
74                init_keyboard();
75
76                printf("DACBUFF running - press any key to exit\n");
77
78        while(!kbhit())
79        {
80
81            /* This command returns when all 16,384 samples have been
82               sent to the DAC as fast as possible
83            */
84
85            buffered_dac_output(commands,values);
86                        if(mio_error_code)
87                        {
88                                printf("\n%s\n",mio_error_string);
89                                exit(2);
90                        }
91
92 
93        }
94
95        readch();
96                close_keyboard();
97                return 0;
98}
99
Note: See TracBrowser for help on using the repository browser.