Listing 81 continued DIOC

**************************************************************************

* CONFIGURE DISCRETE INPUT EDGE DETECTION

* Description : This function is used to configure the edge detection capability of the discrete input

* channel.

* Arguments : n is the discrete input channel to configure (0. .DIO MAX DI~1).

* fnct is a pointer to a function that will be executed if the desired edge has been

* detected.

* arg is a pointer to arguments that are passed to the function called.

********************************************************************************************************* */

#if DI_EDGE_EN

void DICfgEdgeDetectFnct (INT8U n, void (*fnct) (void *), void *arg) {

if (n < DIO_MAX_DI) { OS_ENTER_CRITICAL ( ) ; DITbl[n] .DITrigFnct = fnct; DITbl[n] .DITrigFnctArg = arg; OS_EXIT_CRITICAL ( ) ;

**********************************************************************************************

* CONFIGURE DISCRETE INPUT MDDE

* Description : This function is used to configure the mode of a discrete input channel.

* Arguments : n is the discrete input channel to configure (0. ,DIO_MAX_DI-l).

* mode is the desired mode and can be:

* DI_M3DE_LOW input is forced LOW

* DI_M3DE_HIGH input is forced HIOl

* DI_M3DE_DIRECT input is based on state of ph/sical sensor (default)

* DI_M3DE_INV input is based on the complement of physical sensor

* DI_MDDE_EDGE_LOW_GOING a LCW-going transition is detected

* DI_MDDE_EDGE_HIGH_GOIN3 a HIGH-going transition is detected

* DI_M3DE_EDGE_BOTH both a DOW-going and a HIGH-going transition are detected

* DIJ®DE_Ta3GM_ICW_GOIN3 a LCW-going transition is detected in toggle mode

* DIJyDDE_TCGGLE_HIGH_GOIN3 a HIGH-going transition is detected in toggle mode

* Notes : Edge detection is only available if the configuration constant DI_EDGE_EN is set to 1. *********************************************************************************************************

void DICfgMode (INr8U n, INr8U mode) {

if (n < DIO_MAX_DI) { OS_ENTER_CRITICAL ( ) ; DITbl[n] .DIModeSel = mode; OS_EXIT_CRITICAL ( ) ;

*******************************************************

* CLEAR A DISCRETE INPUT CHANNEL

* Description : This function clears the number of edges detected if the discrete input channel is

* configured to count edges.

* Arguments : n is the discrete input channel (0. .DI0_MAX_DI-1) to clear.

* Returns : none **********************************************************

#if DI_EDGE_EN

if (pdi->DIModeSel == DIJ®DE_EœE_L0W_GOING pdi ->DIModeSel == DI_MODE_EDGE_HIGH_GOIN3 pdi->DIModeSel == DI_MODE_ECGE_BOTH) { pdi->DIVal = 0;

#endif

/* See if edge detection mode selected */

/* Clear the number of edges detected */

Was this article helpful?

0 0

Post a comment