
Nuvo-3100 Series User’s Manual
Copyright © 2014 Neousys Technology Inc. All Right Reserved.
Page 98 of 99
DI COS Example
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "WDT_DIO.h"
//Step 0, define a Change-of-State Interrupt callback function
void __stdcall callback_function(COS_INT_CALLBACK_ARG* arg)
{
printf("data=0x%02x, flag=0x%02x, seq=%02d\n",
arg->portData, arg->intrFlag, arg->intrSeq);
}
int main(int argc, char* argv[])
{
//Step 1, initialize DIO library by invoking InitDIO()
if ( ! InitDIO() )
{
printf("InitDIO --> FAILED\n");
return -1;
}
printf("InitDIO --> PASSED\n");
//Step 2, setup Change-of-State Interrupt mask and level/edge mode
COS_INT_SETUP setup;
memset(&setup, 0, sizeof(setup));
setup.portMask = 0x0f; // 00001111b, enable ch.0~3
setup.edgeMode = 0x00; // generate interrupt on level change
setup.edgeType = 0x00; // rising/falling edge, only effective when edgeMode = 1
if ( ! SetupDICOS(&setup, sizeof(setup)) )
{
printf("SetupDICOS --> FAILED\n");
return -2;
}
printf("SetupDICOS --> PASSED\n");