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 MLIB_ShL_F16<br />

4.170.3 Return<br />

16-bit fractional value shifted to left by the shift amount. The bits beyond the 16-bit<br />

boundary are discarded.<br />

4.170.4 Description<br />

This function shifts the first argument to left by number defined by second argument.<br />

Overflow is not detected.<br />

Note<br />

The shift amount cannot exceed in magnitude the bit-width of<br />

the shift value, that means must be within the range 0...15.<br />

Otherwise the result of the function is undefined. Due to<br />

effectivity reason this function is implemented as inline <strong>and</strong><br />

thus is not ANSI-C compliant.<br />

4.170.5 Re-entrancy<br />

The function is re-entrant.<br />

4.170.6 Code Example<br />

#include "mlib.h"<br />

tFrac16 f16In1;<br />

tFrac16 f16Out;<br />

tU16 u16In2;<br />

void main(void)<br />

{<br />

// first input = 0.25<br />

f16In1 = FRAC16 (0.25);<br />

// second input = 1<br />

u16In2 = 1;<br />

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

f16Out = MLIB_ShL_F16(f16In1, u16In2);<br />

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

f16Out = MLIB_ShL (f16In1, u16In2, Define F16);<br />

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

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

// as default<br />

// ##############################################################<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 />

654 Freescale Semiconductor, Inc.

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

Saved successfully!

Ooh no, something went wrong!