source: multiio/pcmmio/original/flash.c @ 2bae2aa

basewinsystems
Last change on this file since 2bae2aa was 2bae2aa, checked in by Joel Sherrill <joel.sherrill@…>, on 06/08/09 at 14:52:43

Initial import.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* Flash.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 flash.c kbhit.c mio_io.o -o flash
14*
15*   This very simple program, toggles each of the 48  DIO lines in succession, holding it low
16*   for 250ms and then releasing it.
17*
18*/
19
20
21/* These function prototypes are for the keyboard support function kbhit() */
22
23void init_keyboard(void);
24void close_keyboard(void);
25int kbhit(void);
26int readch(void);
27
28
29#include <stdio.h>
30#include <unistd.h>
31#include "mio_io.h"
32
33main(int argc, char *argv[])
34{
35int x;
36
37        x = dio_read_bit(1);    /* Just a test for availability */
38        if(mio_error_code)
39        {
40
41                /* Print the error and exit, if one occurs */
42
43                printf("\n%s\n",mio_error_string);
44                exit(1);
45        }
46
47
48        printf("Flashing - Press any key to exit\n");
49
50        init_keyboard();
51        while(!kbhit())
52        {
53                for(x=1; x<=48; x++)
54                {
55                        dio_set_bit(x); /* Turn on the LED */
56
57                        /* Ideally, we should check mio_error_code after all calls. Practically, there's little to
58                           go wrong once we've validated the driver presence.
59                    */
60
61
62                        /* Got to sleep for 250ms */
63
64                        usleep(25000);
65
66                        dio_clr_bit(x); /* Turn off the LED */
67                }
68        }
69        readch();
70        close_keyboard();
71        printf("\n");
72}
73
74
Note: See TracBrowser for help on using the repository browser.