03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Function GFLIB_Lut2D_F32<br />

Note<br />

The function per<strong>for</strong>ms the bilinear interpolation with 16-bit<br />

accuracy.<br />

CAUTION<br />

The function does not check whether the input values are within<br />

a range allowed by the interpolating data table pParam-<br />

>pf32Table. If the computed interval index points to data<br />

outside the provided data table then the interpolation will be<br />

computed with invalid data.<br />

4.70.5 Re-entrancy<br />

The function is re-entrant.<br />

4.70.6 Code Example<br />

#include "gflib.h"<br />

tFrac32 f32In1;<br />

tFrac32 f32In2;<br />

tFrac32 f32Out;<br />

GFLIB_LUT2D_T_F32 tr32tMyLut2D = GFLIB_LUT2D_DEFAULT_F32;<br />

tFrac32 pf32Table2D[81] = {FRAC32 (0.0), FRAC32 (0.01), FRAC32 (0.02), FRAC32<br />

(0.03), FRAC32 (0.04), FRAC32 (0.05), FRAC32 (0.06), FRAC32 (0.07), FRAC32 (0.08),<br />

FRAC32 (0.1), FRAC32 (0.11), FRAC32 (0.12), FRAC32<br />

(0.13), FRAC32 (0.14), FRAC32 (0.15), FRAC32 (0.16), FRAC32 (0.17), FRAC32 (0.18),<br />

FRAC32 (0.2), FRAC32 (0.21), FRAC32 (0.22), FRAC32<br />

(0.23), FRAC32 (0.24), FRAC32 (0.25), FRAC32 (0.26), FRAC32 (0.27), FRAC32 (0.28),<br />

FRAC32 (0.3), FRAC32 (0.31), FRAC32 (0.32), FRAC32<br />

(0.33), FRAC32 (0.34), FRAC32 (0.35), FRAC32 (0.36), FRAC32 (0.37), FRAC32 (0.38),<br />

FRAC32 (0.4), FRAC32 (0.41), FRAC32 (0.42), FRAC32<br />

(0.43), FRAC32 (0.44), FRAC32 (0.45), FRAC32 (0.46), FRAC32 (0.47), FRAC32 (0.48),<br />

FRAC32 (0.5), FRAC32 (0.51), FRAC32 (0.52), FRAC32<br />

(0.53), FRAC32 (0.54), FRAC32 (0.55), FRAC32 (0.56), FRAC32 (0.57), FRAC32 (0.58),<br />

FRAC32 (0.6), FRAC32 (0.61), FRAC32 (0.62), FRAC32<br />

(0.63), FRAC32 (0.64), FRAC32 (0.65), FRAC32 (0.66), FRAC32 (0.67), FRAC32 (0.68),<br />

FRAC32 (0.7), FRAC32 (0.71), FRAC32 (0.72), FRAC32<br />

(0.73), FRAC32 (0.74), FRAC32 (0.75), FRAC32 (0.76), FRAC32 (0.77), FRAC32 (0.78),<br />

FRAC32 (0.8), FRAC32 (0.81), FRAC32 (0.82), FRAC32<br />

(0.83), FRAC32 (0.84), FRAC32 (0.85), FRAC32 (0.86), FRAC32 (0.87), FRAC32 (0.88)};<br />

void main(void)<br />

{<br />

// setting parameters <strong>for</strong> Lut2D function<br />

tr32tMyLut2D.pf32Table = &(pf32Table2D[40]);<br />

tr32tMyLut2D.s32ShamOffset1 = 2;<br />

tr32tMyLut2D.s32ShamOffset2 = 2;<br />

// input vector<br />

f32In1 = FRAC32 (0.5);<br />

f32In2 = FRAC32 (0.5);<br />

// output should be 0x7A03D70A ~ FRAC32(0.88)<br />

f32Out = GFLIB_Lut2D_F32 (f32In1,f32In2,&tr32tMyLut2D);<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

374 Freescale Semiconductor, Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!