Technical description Chapter 10
APCI-/CPCI-1500
107
e) Example in C for Windows NT/95/98 (in synchronous mode)
str_UserStruct * ps_GlobalUserStruct;
void main (void)
{
int
i_ReturnValue;
unsigned
char
b_BoardHandle;
if (Initialisation (&b_BoardHandle) == 0)
{
if (i_APCI1500_SetBoardIntRoutineWin32 (b_BoardHandle, APCI1500_SYNCHRONOUS_MODE,
sizeof (str_UserStruct), (void **) &ps_GlobalUserStruct,
v_InterruptRoutine) == 0)
{
i_ReturnValue = i_APCI1500_InitTimerInputClock (b_BoardHandle, APCI1500_1_8_KHZ);
printf ("\nTimer input clock initialisation return value = %d", i_ReturnValue);
i_ReturnValue = i_APCI1500_InitTimerCounter1
(b_BoardHandle, APCI1500_TIMER, 1UL,
APCI1500_CONTINUOUS,
APCI1500_ENABLE);
printf ("\nTimer initialisation return value = %d", i_ReturnValue);
i_ReturnValue = i_APCI1500_StartTimerCounter1
(b_BoardHandle);
printf ("\nTimer start return value = %d", i_ReturnValue);
do
{
printf ("\nTimer interrupt counter = %d", ps_GlobalUserStruct->b_TimerCounterCpt [0]);
}
while (!kbhit());
getch ();
i_ReturnValue = i_APCI1500_StopTimerCounter1
(b_BoardHandle);
printf ("\nTimer stop return value = %d", i_ReturnValue);
i_ReturnValue = i_APCI1500_ResetBoardIntRoutine (b_BoardHandle);
printf ("\nReset board interrupt return value = %d", i_ReturnValue);
i_ReturnValue = i_APCI1500_CloseBoardHandle
(b_BoardHandle);
printf ("\nClose board handle return value = %d", i_ReturnValue);
}
else
{
printf ("\nInterrupt initialisation error");
i_ReturnValue = i_APCI1500_CloseBoardHandle
(b_BoardHandle);
printf ("\nClose board handle return value = %d", i_ReturnValue);
}
}
else
{
printf ("\nBoard initialisation error");
}