Listing 101 continued AIOC

:*************************************************************

CONFIGURE THE CONVERSION PARAMETERS OF AN ANALOG OUTPUT CHANNEL

* Description : This function is used to configure an analog output channel.

* Arguments : n is the analog channel to configure (0. .AIO_MAX_AQ-l) .

* ' gain is the conversion gain

* offset is the conversion offset

* pass is the value for the pass counts

* Returns : 0 if successfull.

* 1 if you specified an invalid analog output channel number. *********************************************************************************************************

INT8U ACCfgConv (INT8U n, FP32 gain, FP32 offset, INT16S lim, INT8U pass) f

INT8U err; AIO *paio;

OSSemPend (AlOSem, paio->AICConvGain paio->AICConvOffset paio->AIOGain paio->AIOOffset paio->AIOLim paio->AIOPassCnts OSSenPost (AlOSem) ; return (0); } else {

paio->AICCalGain paio->AlCCalOffset liin; pass;

/* Point to Analog Output structure

/* Obtain exclusive access to AO channel

/* Store new conv. gain and offset into struct paio->AICConvGain; paio->AIOConvOf f set ;

Ccsiipute overall gain Ccsiipute overall offset

/* Release AO channel

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

* CONFIGURE THE SCALING PARAMETERS OF AN ANALOG OUTPUT CHANNEL

* Description : This function is used to configure the scaling parameters associated with an analog

* output channel.

* Arguments : n is the analog output channel to configure (0. .AIO_MAX_AO-l).

* arg is a pointer to arguments needed by the scaling function

* fnct is a pointer to a scaling function

* Returns : 0 if successfull.

* 1 if you specified an invalid analog output channel number.

DJT8U ACCfgScaling (INT8U n, void (*fnct) (AIO *paio), void *arg) {

AIO *paio;

paio->AIOScaleFnct = (void (*)())fnct; paio->AIOScaleFnctArg - arg; OS_EXIT_CRITICAL ( ) ; return (0) ; } else {

/* Faster to use a pointer to the structure */

Was this article helpful?

0 0

Post a comment