Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 86 | f9daq | 1 | |
| 2 | #define DEVICE_NAME "/dev/cc32_1" |
||
| 3 | |||
| 4 | #include <stdio.h> |
||
| 5 | #include <stdlib.h> |
||
| 6 | #include <string.h> |
||
| 7 | #include <unistd.h> |
||
| 8 | #include <sys/mman.h> |
||
| 9 | #include <errno.h> |
||
| 10 | #include <ctype.h> |
||
| 11 | |||
| 12 | #include <libcc32.h> /* the header of the shared library */ |
||
| 13 | |||
| 14 | char *cszPrgName; |
||
| 15 | CC32_HANDLE handle; |
||
| 16 | |||
| 17 | void hlpMsg(void) |
||
| 18 | { |
||
| 19 | printf("pcicc32_test - a program to test some features of the PCICC32 interface of ARW Elektronik Germany.\n"); |
||
| 20 | printf("Copyright see the GPL of the free software foundation. K.Hitschler, %s.\n", __DATE__); |
||
| 21 | printf("usage: pcicc32_test [-d=device_name] [-?]\n"); |
||
| 22 | printf(" -d - choose a device to use. (Default: %s)\n", DEVICE_NAME); |
||
| 23 | printf(" -? - this help.\n"); |
||
| 24 | } |
||
| 25 | |||
| 26 | int main(int argc, char **argv) |
||
| 27 | { |
||
| 28 | char *fname = DEVICE_NAME; |
||
| 29 | char *ptr; |
||
| 30 | char ch; |
||
| 31 | int i; |
||
| 32 | int error; |
||
| 33 | int nTimeout, nLam; |
||
| 34 | int k, j; |
||
| 35 | int n=atoi(argv[2]); |
||
| 36 | int a=atoi(argv[3]); |
||
| 37 | int f=atoi(argv[4]); |
||
| 38 | int data=0; |
||
| 39 | if (argc>5) data = strtoul(argv[5],NULL,0); |
||
| 40 | |||
| 41 | cszPrgName = argv[0]; |
||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | if ((error = cc32_open(fname, &handle))) |
||
| 46 | { |
||
| 47 | fprintf(stderr, "%s: %s: %s\n", cszPrgName, fname, strerror(error)); |
||
| 48 | exit(1); |
||
| 49 | } |
||
| 50 | else |
||
| 51 | printf("%s: open done.\n", cszPrgName); |
||
| 52 | |||
| 53 | switch (atoi(argv[1])){ |
||
| 54 | case 32: |
||
| 55 | cc32_write_long(handle,n,a,f,data); |
||
| 56 | break; |
||
| 57 | case 16: |
||
| 58 | cc32_write_word(handle,n,a,f,data); |
||
| 59 | break; |
||
| 60 | case -16: |
||
| 61 | data=cc32_read_word(handle,n,a,f); |
||
| 62 | break; |
||
| 63 | case -32: |
||
| 64 | data=cc32_read_long(handle,n,a,f); |
||
| 65 | break; |
||
| 66 | default: printf("Unknown command\n"); |
||
| 67 | } |
||
| 68 | printf("CC32 %d N=%d A=%d F=%d data=0x%x\n",atoi(argv[1]),n,a,f,data); |
||
| 69 | |||
| 70 | return 0; |
||
| 71 | for (k = 0; k < 1; k++) |
||
| 72 | { |
||
| 73 | for (j = 0; j < 0x00FFFFFF; j++) |
||
| 74 | { |
||
| 75 | cc32_write_long(handle, 1 + (j % 23), (j % 15), 16 + (j % 15), j); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | // poll the event |
||
| 80 | error = cc32_poll_event(handle, &nTimeout, &nLam); |
||
| 81 | printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName, error, nTimeout, nLam); |
||
| 82 | |||
| 83 | // enable all LAM mask bits for this test |
||
| 84 | cc32_write_long(handle, 28, 1, 16, 0x00FFFFFF); |
||
| 85 | // enable interrupts |
||
| 86 | error = cc32_interrupt_enable(handle); |
||
| 87 | |||
| 88 | // generate a LAM interrupt with help of the test mode bits |
||
| 89 | cc32_write_long(handle, 24, 0, 16, 5); |
||
| 90 | |||
| 91 | // wait for a event |
||
| 92 | error = cc32_wait_event(handle, &nTimeout, &nLam); |
||
| 93 | printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName, error, nTimeout, nLam); |
||
| 94 | |||
| 95 | if (nLam) |
||
| 96 | { |
||
| 97 | // clear LAM |
||
| 98 | cc32_write_word(handle, 28, 0, 16, 0); |
||
| 99 | } |
||
| 100 | |||
| 101 | // wait again for a event (which never comes) |
||
| 102 | error = cc32_wait_event(handle, &nTimeout, &nLam); |
||
| 103 | printf("%s : bConnected = %d, bFail = %d, bIrq = %d\n", cszPrgName, error, nTimeout, nLam); |
||
| 104 | |||
| 105 | |||
| 106 | cc32_close(handle);; |
||
| 107 | |||
| 108 | printf("%s: close done.\n", cszPrgName); |
||
| 109 | |||
| 110 | return 0; |
||
| 111 | } |