#define DEVICE_NAME "/dev/cc32_1"
 
 
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <unistd.h>
 
#include <sys/mman.h>
 
#include <errno.h>
 
#include <ctype.h>
 
 
 
#include <libcc32.h> /* the header of the shared library */
 
 
 
char *cszPrgName;
 
CC32_HANDLE handle;
 
 
 
void hlpMsg(void)
 
{
 
    printf("pcicc32_test - a program to test some features of the PCICC32 interface of ARW Elektronik Germany.\n");  
    printf("Copyright see the GPL of the free software foundation. K.Hitschler, %s.\n", __DATE__
);  
    printf("usage: pcicc32_test [-d=device_name] [-?]\n");  
    printf("                     -d - choose a device to use. (Default: %s)\n", DEVICE_NAME
);  
}
 
 
 
int main(int argc, char **argv)
 
{
 
    char *fname = DEVICE_NAME;
 
    char *ptr;
 
    char ch;
 
    int i;
 
    int error;
 
    int nTimeout, nLam;
 
    int k, j;
 
   int data=0;
 
   if (argc
>5) data 
= strtoul(argv
[5],NULL
,0);  
    
 
    cszPrgName = argv[0];
 
    
 
    
 
    
 
    if ((error = cc32_open(fname, &handle))) 
 
    {
 
    }
 
    else
 
        printf("%s: open done.\n", cszPrgName
);  
 
 
case 32:
 
     cc32_write_long(handle,n,a,f,data);
 
     break;
 
case 16:
 
     cc32_write_word(handle,n,a,f,data);
 
     break;
 
case -16:
 
     data=cc32_read_word(handle,n,a,f);
 
     break;
 
case -32:
 
     data=cc32_read_long(handle,n,a,f);
 
     break;
 
default: printf("Unknown command\n");  
      }
 
    printf("CC32 %d N=%d A=%d F=%d data=0x%x\n",atoi(argv
[1]),n
,a
,f
,data
);  
 
 
    return 0;
 
    for (k = 0; k < 1; k++)
 
    {
 
            for (j = 0; j < 0x00FFFFFF; j++)
 
            {    
 
                    cc32_write_long(handle, 1 + (j % 23), (j % 15), 16 + (j % 15), j);
 
            }
 
    }
 
    
 
    // poll the event
 
    error = cc32_poll_event(handle, &nTimeout, &nLam);
 
    printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName
, error
, nTimeout
, nLam
);  
 
 
    // enable all LAM mask bits for this test    
 
    cc32_write_long(handle, 28, 1, 16, 0x00FFFFFF); 
 
    // enable interrupts
 
    error = cc32_interrupt_enable(handle);
 
    
 
    // generate a LAM interrupt with help of the test mode bits
 
    cc32_write_long(handle, 24, 0, 16, 5);
 
              
 
    // wait for a event 
 
    error = cc32_wait_event(handle, &nTimeout, &nLam); 
 
    printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName
, error
, nTimeout
, nLam
);  
    
 
    if (nLam)
 
    {
 
      // clear LAM
 
      cc32_write_word(handle, 28, 0, 16, 0);
 
    }
 
    
 
    // wait again for a event (which never comes)
 
    error = cc32_wait_event(handle, &nTimeout, &nLam); 
 
    printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName
, error
, nTimeout
, nLam
);  
    
 
          
 
    cc32_close(handle);;
 
 
 
    printf("%s: close done.\n", cszPrgName
);  
    
 
    return 0;
 
}