National Instruments 320571-01 Car Stereo System User Manual


 
Getting Started with the NI-DSP Interface Utilities Chapter 2
Part 4: NI-DSP Interface Utilities 2-2 NI-DSP SRM for LabVIEW for Windows
long *n,*imin,*imax;
{
long i,j;
float *x, small;
float localmin ,localmax;
if ((*n)<= 0) return(0);
x = z;
localmin = *x;
localmax = localmin;
*imax = 0;
*imin = 0;
for (i=0;i< *n;i++,*x++) {
if (localmax < *x) {
localmax = *x;
*imax = i;
}
if (localmin > *x) {
localmin = *x;
*imin = i;
}
}
*min = localmin;
*max = localmax;
for(i=0; i< *n; i++) y[i] = z[i];
for(i=0; i< *n; i++){
for(j=i+1; j< *n; j++)
if(y[i] > y[j]) {
small = y[j];
y[j] = y[i];
y[i] = small;
}
}
return(noError);
}
Note: The file ATDSP.h is the header file containing all of the error codes used by the DSP Library. You can
find it in the LIB directory. To efficiently and correctly compile WE DSP32C code that uses error codes
defined in ATDSP.h, you may want to copy this header file to the Include directory of your WE
DSP32C tools. Otherwise, you should specify the correct path of ATDSP.h in your program.
Guidelines for the Custom Functions
When adding functions to build your custom DSP Library, follow these guidelines:
Pass all parameters by address–All input, output, and input/output parameters, whether arrays or scalars, must
be passed by address (pointer). For instance, in the example gmaxmin.c, although the length n of an input
array is only an input scalar, it is passed by address.
You must pass parameters in a certain order–Pass all pointers to arrays, then pass all of the pointers to 32-bit
floating-point scalars, and then pass all of the pointers to 32-bit long integer scalars. In gmaxmin.c, the
parameters are passed in the following order–z (input array), y (output array), max (output floating-point
scalar), min (output floating-point scalar), n (input integer scalar), imax (output integer scalar), and imin
(output integer scalar).