#include "stdafx.h"
#include "nio_lib20.h"
#include "nio_lib20_err.h"

HAND g_hDev;

void Intterrup1CallBack()
{
	short devIdx = 0;
	printf("Interrupt NO.1 callback ...");
	NIO_IntClr(g_hDev,0);
}

void Intterrup2CallBack()
{
	short devIdx = 0;
	printf("Interrupt NO.1 callback ...");
	NIO_IntClr(g_hDev,1);
}
// 中断处理例子：中断
short NIO_Example_Interrupt(HAND hDev)
{
	short rtn;
	short interruptIdx = 0;
	short sns = 0;
	g_hDev = hDev;

	// 1.开启中断
	if(interruptIdx == 0)
	{
		rtn = NIO_IntConfig(hDev, interruptIdx, sns,0,1,(GCNIO_IntCallback)Intterrup1CallBack);
	}
	else
	{
		rtn = NIO_IntConfig(hDev, interruptIdx, sns,0,1,(GCNIO_IntCallback)Intterrup2CallBack);
	}
	if (rtn == 0)
	{
		printf("Interrput config ok ...");
	}
	else
	{
		printf("Interrput config err = %d ...",rtn);
	}

	// 2.清除回零状态
	NIO_IntClr(g_hDev,interruptIdx);

	// 3.查询回零状态
	short onOff;
	I32 cnt;
	while(1)
	{
		NIO_IntGetSts(hDev,0,&cnt,&onOff);
	}


	return 0;
}
