xPCI-3116 API
xPCI-3116 Timer/Counter/Watchdog functions

Functions

_INT_ i_PCI3116_InitAndStartCounterTimerWatchdog (HANDLE h_DeviceHandle, BYTE b_Function, BYTE b_Index, BYTE b_InterruptEnabled, WORD w_ReloadValue, BYTE b_TimerWatchdogTimeBase, BYTE b_CounterTimerOutputMode, BYTE b_TimerMode, BYTE b_CounterDirection, BYTE b_CounterLevel)
 
_INT_ i_PCI3116_StopCounterTimerWatchdog (HANDLE h_DeviceHandle, BYTE b_Index)
 
_INT_ i_PCI3116_TriggerCounterTimerWatchdog (HANDLE h_DeviceHandle, BYTE b_Index)
 
_INT_ i_PCI3116_ReadCounterStatus (HANDLE h_DeviceHandle, BYTE b_Index, PBYTE pb_CounterStatus, PBYTE pb_Clear, PBYTE pb_SoftwareTriggerStatus, PWORD pw_CounterValue)
 
_INT_ i_PCI3116_ReadCounterValue (HANDLE h_DeviceHandle, BYTE b_Index, PWORD pw_CounterValue)
 
_INT_ i_PCI3116_ClearCounter (HANDLE h_DeviceHandle, BYTE b_Index)
 
_INT_ i_PCI3116_ReadTimerStatus (HANDLE h_DeviceHandle, BYTE b_Index, PBYTE pb_TimerStatus, PBYTE pb_SoftwareTriggerStatus, PWORD pw_TimerValue)
 
_INT_ i_PCI3116_ReadTimerValue (HANDLE h_DeviceHandle, BYTE b_Index, PWORD pw_TimerValue)
 
_INT_ i_PCI3116_ReadWatchdogStatus (HANDLE h_DeviceHandle, BYTE b_Index, PBYTE pb_WatchdogStatus, PBYTE pb_SoftwareTriggerStatus, PWORD pw_WatchdogValue)
 
_INT_ i_PCI3116_ReadWatchdogValue (HANDLE h_DeviceHandle, BYTE b_Index, PWORD pw_WatchdogValue)
 

Detailed Description

Function Documentation

_INT_ i_PCI3116_InitAndStartCounterTimerWatchdog ( HANDLE  h_DeviceHandle,
BYTE  b_Function,
BYTE  b_Index,
BYTE  b_InterruptEnabled,
WORD  w_ReloadValue,
BYTE  b_TimerWatchdogTimeBase,
BYTE  b_CounterTimerOutputMode,
BYTE  b_TimerMode,
BYTE  b_CounterDirection,
BYTE  b_CounterLevel 
)

Enables to start a counter, timer or watchdog.
Three hardware components are available. A hardware component may only implement one function at a time.
The first component (index 0) can ony be used as counter and timer.
The two last components (index 1 and index 2) can be used as counter, timer and watchdog.

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_FunctionFunction choosed for the component. (PCI3116_COUNTER_FUNCTION, PCI3116_TIMER_FUNCTION, PCI3116_WATCHDOG_FUNCTION )
[in]b_IndexIndex of the component (0, 1, or 2). (Note: index 0 cannot work if b_Function is PCI3116_WATCHDOG_FUNCTION)
[in]b_InterruptEnabledEnable to use or not use an interrupt (0,1).
[in]w_ReloadValueFor the counter: its maximum value. For timer and watchdog: the time to count (depend on b_TimerWatchdogTimeBase)
[in]b_TimerWatchdogTimeBaseOnly use if b_Function is PCI3116_TIMER_FUNCTION or PCI3116_WATCHDOG_FUNCTION. Select the time base (PCI3116_TIME_BASE_MICROSECONDS, PCI3116_TIME_BASE_MILLISECONDS, PCI3116_TIME_BASE_SECONDS)
[in]b_CounterTimerOutputModeOny use if b_Function is PCI3116_COUNTER_FUNCTION or PCI3116_TIMER_FUNCTION. Set the way the output will change (PCI3116_OUTPUT_ENABLED, PCI3116_OUTPUT_DISABLED, PCI3116_OUTPUT_INVERTED)
[in]b_TimerModeOnly use if b_Function is PCI3116_TIMER_FUNCTION. Specifiy the mode of the timer. (PCI3116_TIMER_MODE_2, PCI3116_TIMER_MODE_3).
PCI3116_TIMER_MODE_2: It functions like a divide-by-w_ReloadValue counter. It is used to generate a real time clock interrupt. OUT is initially high after the initialization. When the initial count has decremented to 1, OUT goes low for one CLK pulse. OUT then goes high again, the counter reloads the initial count (w_ReloadValue) and the process is repeated. This action can generate an interrupt.
PCI3116_TIMER_MODE_3: This mode is similar to mode 2 except for the duty cycle of OUT. OUT will initially be high after the initialisation. When the initial count (ul_ReloadValue) has expired, OUT goes low for the next sequence. When the initial count (ul_ReloadValue) of that sequence has expired, OUT goes high again for the following sequence. The mode is periodic; the sequence above is repeated indefinitely.
[in]b_CounterDirectionOnly use if b_Function is PCI3116_COUNTER_FUNCTION. (PCI3116_COUNTER_DIRECTION_UP, PCI3116_COUNTER_DIRECTION_DOWN). Selects the counter for up-counting or down-counting
[in]b_CounterLevelOnly use if b_Function is PCI3116_COUNTER_FUNCTION. (PCI3116_COUNTER_LOW_LEVEL, PCI3116_COUNTER_HIGH_LEVEL, PCI3116_COUNTER_BOTH_LEVEL). Counter counts low levels, or high levels or both.
Return values
0: success
-1: b_Function is invalid
-2: index 0 cannot be used as watchdog
-3: b_InterruptEnabled is invalid
-4: b_Index is invalid
-5: b_TimerWatchdogTimeBase is invalid
-11: b_CounterDirection is invalid
-12: b_CounterLevel is invalid
-13: b_CounterTimerOutputMode is invalid
-14: Error while calling IOCTL function (wrong handle ?)
-21: b_CounterTimerOutputMode is invalid
-22: b_TimerMode is invalid
-23: Error while calling IOCTL function (wrong handle ?)
-31: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_StopCounterTimerWatchdog ( HANDLE  h_DeviceHandle,
BYTE  b_Index 
)

Stops the timer/counter/watchdog

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexCounter/timer/watchdog to stop (0,1 or 2)
Return values
0: No Error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_TriggerCounterTimerWatchdog ( HANDLE  h_DeviceHandle,
BYTE  b_Index 
)

Triggers the timer/counter/watchdog

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexCounter/timer/watchdog to trigger (0,1 or 2)
Return values
0: No Error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadCounterStatus ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PBYTE  pb_CounterStatus,
PBYTE  pb_Clear,
PBYTE  pb_SoftwareTriggerStatus,
PWORD  pw_CounterValue 
)

Reads the counter status

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexTimer to use (PCI3116_TIMER_0, PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pb_CounterStatusTimer status (0 = disabled, 1 = enabled)
[out]pb_ClearStatus of the CLEAR bit (0 = counter has not been cleared, 1 = counter has been cleared)
[out]pb_SoftwareTriggerStatusStatus of the software trigger (0 = no software trigger occured, 1 = software trigger occured)
[out]pw_CounterValueCurrent value of the counter
Return values
0: No Error
-1: b_CounterSelect is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadCounterValue ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PWORD  pw_CounterValue 
)

Read the value of the counter

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexCounter to use (PCI3116_TIMER_0, PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pw_CounterValueCurrent value of the counter
Return values
0: No error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ClearCounter ( HANDLE  h_DeviceHandle,
BYTE  b_Index 
)

Clear the counter

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexWatchdog to use (PCI3116_TIMER_0, PCI3116_TIMER_1 or PCI3116_TIMER_2)
Return values
0: No Error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadTimerStatus ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PBYTE  pb_TimerStatus,
PBYTE  pb_SoftwareTriggerStatus,
PWORD  pw_TimerValue 
)

Reads the timer status

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexTimer to use (PCI3116_TIMER_0, PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pb_TimerStatusTimer status (0 = disabled, 1 = enabled)
[out]pb_SoftwareTriggerStatusStatus of the software trigger (0 = no software trigger occured, 1 = software trigger occured)
[out]pw_TimerValueCurrent value of the timer
Return values
0: No Error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadTimerValue ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PWORD  pw_TimerValue 
)

Read the value of the timer

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexTimer to use (PCI3116_TIMER_0, PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pw_TimerValueCurrent value of the timer
Return values
0: No error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadWatchdogStatus ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PBYTE  pb_WatchdogStatus,
PBYTE  pb_SoftwareTriggerStatus,
PWORD  pw_WatchdogValue 
)

Reads the watchdog status

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexWatchdog to use (PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pb_WatchdogStatusWatchdog status (0 = disabled, 1 = enabled)
[out]pb_SoftwareTriggerStatusStatus of the software trigger (0 = no software trigger occured, 1 = software trigger occured)
[out]pw_WatchdogValueCurrent value of the watchdog
Return values
0: No Error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadWatchdogValue ( HANDLE  h_DeviceHandle,
BYTE  b_Index,
PWORD  pw_WatchdogValue 
)

Read the value of the watchdog

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_IndexWatchdog to use (PCI3116_TIMER_1 or PCI3116_TIMER_2)
[out]pw_WatchdogValueCurrent value of the watchdog
Return values
0: No error
-1: b_Index is invalid
-2: Error while calling IOCTL function (wrong handle ?)