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.

4.76.3 Return<br />

The function returns the sign of the input argument.<br />

4.76.4 Description<br />

The GFLIB_Sign function calculates the sign of the input argument. The function return<br />

value is computed as follows. If the input value is negative, then the return value will be<br />

set to "-1" (0x80000000 hex), if the input value is zero, then the function returns "0" (0x0<br />

hex), otherwise if the input value is greater than zero, the return value will be "1"<br />

(0x7fffffff hex).<br />

In mathematical terms, the function works according to the equation below:<br />

where:<br />

Equation GFLIB_Sign_Eq1<br />

• y out is the return value<br />

• x in is the input value provided as the f32In parameter<br />

Note<br />

The input <strong>and</strong> the output values are in the 32-bit fixed point<br />

fractional data <strong>for</strong>mat.<br />

4.76.5 Re-entrancy<br />

The function is re-entrant.<br />

4.76.6 Code Example<br />

#include "gflib.h"<br />

tFrac32 f32In;<br />

tFrac32 f32Out;<br />

void main(void)<br />

{<br />

// input value = 0.5<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. 395

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

Saved successfully!

Ooh no, something went wrong!