aversive_10-03-12/modules/base/math/fixed_point/f32.h File Reference

#include <aversive.h>

Go to the source code of this file.

Data Structures

struct  fixed_32

Defines

#define f32_decimal   u.s.decimal
#define f32_integer   u.s.integer
#define F32_ZERO
#define F32_NAN
#define F32_IS_GT(x, y)   (f32_to_s32(x) > f32_to_s32(y))
#define F32_IS_LT(x, y)   (f32_to_s32(x) < f32_to_s32(y))
#define F32_IS_GE(x, y)   (f32_to_s32(x) >= f32_to_s32(y))
#define F32_IS_LE(x, y)   (f32_to_s32(x) <= f32_to_s32(y))
#define F32_IS_EQ(x, y)   (f32_to_s32(x) == f32_to_s32(y))
#define F32_IS_NE(x, y)   (f32_to_s32(x) != f32_to_s32(y))
#define F32_IS_NEG(x)   ((x).f32_integer < 0)
#define F32_IS_ZERO(x)   ((x).f32_integer == 0 && (x).f32_decimal == 0)

Typedefs

typedef struct fixed_32 f32

Functions

f32 f32_from_double (double f)
double f32_to_double (f32 fix)
f32 f32_from_integer (int16_t i, uint16_t d)
f32 f32_from_msb (int16_t i)
f32 f32_from_lsb (int16_t i)
f32 f32_neg (f32 f)
f32 f32_add (f32 a, f32 b)
f32 f32_sub (f32 a, f32 b)
f32 f32_inv (f32 f)
f32 f32_mul (f32 a, f32 b)
f32 f32_mul_msb (f32 a, f32 b)
f32 f32_div (f32 a, f32 b)
f32 f32_sqrt (f32 f)
void f32_print (f32 fix)


Define Documentation

#define f32_decimal   u.s.decimal

Definition at line 52 of file f32.h.

#define f32_integer   u.s.integer

Definition at line 53 of file f32.h.

#define F32_IS_EQ ( x,
 )     (f32_to_s32(x) == f32_to_s32(y))

Definition at line 73 of file f32.h.

Referenced by f32_print().

#define F32_IS_GE ( x,
 )     (f32_to_s32(x) >= f32_to_s32(y))

Definition at line 71 of file f32.h.

#define F32_IS_GT ( x,
 )     (f32_to_s32(x) > f32_to_s32(y))

Definition at line 69 of file f32.h.

#define F32_IS_LE ( x,
 )     (f32_to_s32(x) <= f32_to_s32(y))

Definition at line 72 of file f32.h.

#define F32_IS_LT ( x,
 )     (f32_to_s32(x) < f32_to_s32(y))

Definition at line 70 of file f32.h.

#define F32_IS_NE ( x,
 )     (f32_to_s32(x) != f32_to_s32(y))

Definition at line 74 of file f32.h.

#define F32_IS_NEG (  )     ((x).f32_integer < 0)

Definition at line 75 of file f32.h.

Referenced by f32_sqrt().

#define F32_IS_ZERO (  )     ((x).f32_integer == 0 && (x).f32_decimal == 0)

Definition at line 76 of file f32.h.

Referenced by f32_div(), f32_inv(), and f32_sqrt().

#define F32_NAN

Value:

(              \
{                              \
    f32 __f;                   \
    __f.u.s32 = 0xFFFFFFFF;    \
    __f;                       \
})

Definition at line 62 of file f32.h.

Referenced by f32_div(), f32_inv(), f32_print(), and f32_sqrt().

#define F32_ZERO

Value:

(    \
{                     \
    f32 __f;          \
    __f.u.s32 = 0;    \
    __f;              \
})

Definition at line 55 of file f32.h.

Referenced by f32_sqrt().


Typedef Documentation

typedef struct fixed_32 f32


Function Documentation

f32 f32_add ( f32  a,
f32  b 
)

add a with b (=a+b)

Definition at line 27 of file f32_add.c.

f32 f32_div ( f32  a,
f32  b 
)

div a with b (=a/b)

Definition at line 25 of file f32_div.c.

References f32_inv(), F32_IS_ZERO, f32_mul(), and F32_NAN.

f32 f32_from_double ( double  f  ) 

convert a double to a f32

Definition at line 31 of file f32_double.c.

References parse_symbols::f, and POW2_16F.

f32 f32_from_integer ( int16_t  i,
uint16_t  d 
)

convert 2 integer (int16_t and uint16_t) to a f32

Definition at line 28 of file f32_int.c.

References parse_symbols::f.

f32 f32_from_lsb ( int16_t  i  ) 

convert lsb integer (int16_t) to a f32 ( -0.5 < ret < 0.5 )

Definition at line 51 of file f32_int.c.

References parse_symbols::f.

f32 f32_from_msb ( int16_t  i  ) 

convert msb integer (int16_t) to a f32

Definition at line 39 of file f32_int.c.

References parse_symbols::f.

f32 f32_inv ( f32  f  ) 

return opposite of the number (=1/f)

Definition at line 28 of file f32_inv.c.

References F32_IS_ZERO, and F32_NAN.

Referenced by f32_div().

f32 f32_mul ( f32  a,
f32  b 
)

mul a with b (=a*b)

Definition at line 27 of file f32_mul.c.

Referenced by f32_div(), and f32_sqrt().

f32 f32_mul_msb ( f32  a,
f32  b 
)

mul a with b (=a*b), but return only the msb

f32 f32_neg ( f32  f  ) 

return opposite of the number (=-f)

Definition at line 27 of file f32_neg.c.

void f32_print ( f32  fix  ) 

function that display a f32 to the standard output

Definition at line 27 of file f32_print.c.

References F32_IS_EQ, F32_NAN, and f32_to_double().

f32 f32_sqrt ( f32  f  ) 

sqrt of f

Definition at line 46 of file f32_sqrt.c.

References a, F32_IS_NEG, F32_IS_ZERO, f32_mul(), F32_NAN, and F32_ZERO.

f32 f32_sub ( f32  a,
f32  b 
)

add a with b (=a-b)

Definition at line 27 of file f32_sub.c.

double f32_to_double ( f32  fix  ) 

convert a f32 to a double

Definition at line 40 of file f32_double.c.

References POW2_16F.

Referenced by f32_print().


Generated on Fri Mar 12 06:32:05 2010 for AVR by  doxygen 1.5.6