/* POLL.C
Copyright 1996 by WinSystems Inc.
Permission is hereby granted to the purchaser of the WinSystems
UIO cards and CPU products incorporating the UIO device, to distribute
any binary file or files compiled using this source code directly or
in any work derived by the user from this file. In no case may the
source code, original or derived from this file, be distributed to any
third party except by explicit permission of WinSystems. This file is
distributed on an "As-is" basis and no warranty as to performance,
fitness of purposes, or any other warranty is expressed or implied.
In no case shall WinSystems be liable for any direct or indirect loss
or damage, real or consequential resulting from the usage of this
source code. It is the user's sole responsibility to determine
fitness for any considered purpose.
*/
#include <stdio.h>
#include <conio.h>
#include "uio48.h"
#define BASE_PORT 0x200
/* This program uses the edge detection interrupt capability of the
WS16C48 to count transitions on the first 24 lines. It does this
however, no by using true interrupts but by polling for transitions
using the get_int() function.
*/
/* Our transition totals are stored in this array */
unsigned int_counts[25];
/* Definitions for local functions */
void check_ints(void);
void main()
{
int x;
/* Initialize the I/O ports. Set all I/O pins to input */
init_io(BASE_PORT);
/* Initialize our transition counts, and enable falling edge
transition interrupts.
*/
for(x=1; x<25; x++)
{
int_counts[x] = 0;
/* Clear the counts */
enab_int(x,FALLING);
/* Enable the falling edge interrupts */
}
/* Clean up the screen for our display. Nothing fancy */
clrscr();
for(x=1; x<25; x++)
{
gotoxy(1,x);
printf("Bit number %02d ",x);
}
/* We will continue to display until any key is pressed */
while(!kbhit())
{
/* Retrieve any pending transitions and update the counts */
check_ints();
/* Display the current count values */
for(x=1; x < 25; x++)
{
gotoxy(16,x);
printf("%05u",int_counts[x]);
}
}
getch();
}
void check_ints()
{
int current;