리크 테스트 gui
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

154 lines
4.4 KiB

/*----------------------------------------------------------------------------*/
/* Company : ADLINK */
/* Date : 2009/06/09 */
/* */
/* This sample performs DI change of state functionality. */
/* In PCIe-7350, there are 32 programmable DIO channels. Each 8 channels are */
/* devided into one port that is the DIO configuration unit. */
/* Internal interrupt will be asserted while the state of the input digital */
/* signal is changed form low to high or high to low. */
/* AFI port can also be set as the COS event out mode, and the set AFI port */
/* will generate a pulse while COS occurs. */
/*----------------------------------------------------------------------------*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <conio.h>
#include "dask.h"
I16 card;
HANDLE COS_Event = 0;
BOOLEAN fStopThr = 0;
BOOLEAN fThrEnded = 0;
void wait_changeofstate(void *arg)
{
I16 err;
U32 COSLData;
U32 stat;
do{
stat = WaitForSingleObject(COS_Event, INFINITE);
if(stat!=0){
printf("WaitForSingleObject Error: %d\n", GetLastError());
continue;
}
if(fStopThr)
break;
else{
err = DIO_GetCOSLatchData32(card, 0, &COSLData);
if(err<0){
printf("DIO_GetCOSLatchData32 Error: %d\n", err);
}
printf("Change of State; Latched Data: 0x%x\n", COSLData);
}
}while(1);
fThrEnded = 1;
_endthread();
}
int main(int argc, char **argv)
{
I16 err;
U16 card_num;
U16 vi;
U32 DIRead;
BOOLEAN fStop;
U32 COSEventOutLen = 100; //100 system clock - 100 * 8 ns
printf("This sample performs change of state functionality.\n");
printf("DIO Port A is configured as a DO port while Port B\n");
printf("is configured as a DI Port. Signal will be asserted\n");
printf("and a %d ns pulse will be generated to AFI0 while\n", 8*COSEventOutLen);
printf("the DI state is changed.\n");
printf("Card Number? ");
scanf(" %hd", &card_num);
/*Open and Initialize Device*/
card = Register_Card(PCI_7350, card_num);
if(card<0){
printf("Register_Card Error: %d\n", card);
exit(1);
}
/*Configure 7350 DIO Port*/
err = DIO_PortConfig(card, P7350_DIO_A, OUTPUT_PORT);
if(err<0){
printf("DIO_PortConfig Port_A Error: %d\n", err);
Release_Card(card);
exit(1);
}
err = DIO_PortConfig(card, P7350_DIO_B, INPUT_PORT);
if(err<0){
printf("DIO_PortConfig Port_B Error: %d\n", err);
Release_Card(card);
exit(1);
}
DO_WritePort(card, P7350_DIO_A, 0);
Sleep(1);
/*
* Setup COS for Port B
*/
err = DIO_SetCOSInterrupt32(card, 0, 0xff00, &COS_Event, 0);
if(err<0){
printf("DIO_SetCOSInterrupt32 Error: %d\n", err);
Release_Card(card);
exit(1);
}
/*
* Set COS event out to AFI port
*/
err = DIO_7350_AFIConfig(card, P7350_AFI_0, 1, P7350_AFI_COSTrigOut, COSEventOutLen);
if(err<0){
printf("DIO_7350_AFIConfig Port_A Error: %d\n", err);
Release_Card(card);
exit(1);
}
_beginthread(wait_changeofstate, 0, NULL);
do{
/*
* DO output to Port A/C
*/
printf("\n\nOutput Data? ");
scanf(" %x", &vi);
DO_WritePort(card, P7350_DIO_A, vi&0xff);
DI_ReadPort(card, P7350_DIO_B, &DIRead);
printf("Write to Port A: 0x%x; Read from Port B: 0x%x;\n", vi&0xff, DIRead);
printf("Quit? ");
fStop = getch();
}while((fStop!='q')&&(fStop!='Q'));
fStopThr = 1;
if(!fThrEnded){
SetEvent(COS_Event);
ResetEvent(COS_Event);
}
while(!fThrEnded){
Sleep(1);
}
err = DIO_SetCOSInterrupt32(card, 0, 0, NULL, 0);
if(err<0){
printf("DIO_SetCOSInterrupt32 Error: %d\n", err);
}
err = DIO_7350_AFIConfig(card, P7350_AFI_0, 0, 0, 0);
if(err<0){
printf("DIO_7350_AFIConfig Error: %d\n", err);
}
printf("\n\nPress any key to exit...\n");
getch();
Release_Card(card);
return 0;
}