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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.62.4 Description<br />

The GFLIB_Limit function tests whether the input value is within the upper <strong>and</strong> lower<br />

limits. If so, the input value will be returned. If the input value is above the upper limit,<br />

the upper limit will be returned. Similarly, if the input value is below the lower limit, the<br />

lower limit will be returned.<br />

The upper <strong>and</strong> lower limits can be found in the limits structure, supplied to the function<br />

as a pointer pParam.<br />

Note<br />

The function assumes that the upper limit f16UpperLimit is<br />

greater than the lower limit f16LowerLimit. Otherwise, the<br />

function returns an undefined value.<br />

4.62.5 Re-entrancy<br />

The function is re-entrant.<br />

4.62.6 Code Example<br />

#include "gflib.h"<br />

tFrac16 f16In;<br />

tFrac16 f16Out;<br />

GFLIB_LIMIT_T_F16 f16trMyLimit = GFLIB_LIMIT_DEFAULT_F16;<br />

void main(void)<br />

{<br />

// upper/lower limits<br />

f16trMyLimit.f16UpperLimit = FRAC16 (0.5);<br />

f16trMyLimit.f16LowerLimit = FRAC16 (-0.5);<br />

}<br />

// input value = 0.75<br />

f16In = FRAC16 (0.75);<br />

// output should be 0x4000 ~ FRAC16(0.5)<br />

f16Out = GFLIB_Limit_F16 (f16In, &f16trMyLimit);<br />

// output should be 0x4000 ~ FRAC16(0.5)<br />

f16Out = GFLIB_Limit (f16In, &f16trMyLimit, Define F16);<br />

// ##############################################################<br />

// Available only if 16-bit fractional implementation selected<br />

// as default<br />

// ##############################################################<br />

// output should be 0x4000 ~ FRAC16(0.5)<br />

f16Out = GFLIB_Limit (f16In, &f16trMyLimit);<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 />

Chapter 4 API References<br />

Freescale Semiconductor, Inc. 349

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

Saved successfully!

Ooh no, something went wrong!