KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
macro.h File Reference

Provides common macros. More...

Go to the source code of this file.

Macros

#define _EVAL(MACRO)   MACRO
 
#define EVAL(MACRO)   _EVAL(MACRO)
 
#define _STR(EXPR)   #EXPR
 
#define STR(EXPR)   _STR(EXPR)
 Stringyfies an expression. More...
 
#define RESCALE(INPUT, IN_MIN, IN_MAX, OUT_MIN, OUT_MAX)
 Re-scales the input value into the range of the output value. More...
 
#define COERCE(INPUT, MIN, MAX)   ( ( INPUT ) > ( MAX ) ? ( MAX ) : ( ( INPUT ) < ( MIN ) ? ( MIN ) : ( INPUT ) ) )
 
#define _CCMP(A, B, BITS)   (((A) - (B)) & (1 << (BITS - 1)))
 Private Cyclic Comparison macro, please don't use.
 
#define CGT(A, B, BITS)   (_CCMP(B, A, BITS) != 0)
 Cyclic comparison function Greater Than. More...
 
#define CGE(A, B, BITS)   (_CCMP(A, B, BITS) == 0)
 Cyclic comparison function Greater Of Equal To. More...
 
#define CLT(A, B, BITS)   (_CCMP(A, B, BITS) != 0)
 Cyclic comparison function Less Than. More...
 
#define CLE(A, B, BITS)   (_CCMP(B, A, BITS) == 0)
 Cyclic comparison function Less Or Equal To. More...
 
#define BIT(N)   ( 1 << ( N ) )
 Makes a value with the specified bit set.
 
#define MASK(LEN)   ( ( 1 << ( LEN ) ) - 1 )
 Creates a mask with the specified offset and length.
 
#define EXT_BITFIELD(VAL, OFF, LEN)   ( ( ( VAL ) >> ( OFF ) ) & MASK( LEN ) )
 Extracts a bitfield.
 
#define _BR_SHORT(SHORT)   ( ( ( 0xFF00L & SHORT ) >> 8 ) | ( ( 0x00FFL & SHORT ) << 8 ) )
 Little Endian to native short.
 
#define _BR_LONG(LONG)   ( _BR_SHORT ( ( 0xFFFF0000L & LONG ) >> 16 ) | ( ( 0x0000FFFFL & _BR_SHORT(SHORT) ) << 16 ) )
 
#define N2LES(SHORT)   _BR_SHORT(SHORT)
 
#define LE2NS(SHORT)   _BR_SHORT(SHORT)
 
#define N2LEL(LONG)   _BR_LONG(LONG)
 
#define LE2NL(LONG)   _BR_LONG(LONG)
 
#define N2BES(SHORT)   ( SHORT )
 
#define BE2NS(SHORT)   ( SHORT )
 
#define N2BEL(LONG)   ( LONG )
 
#define BE2NL(LONG)   ( LONG )
 
#define arraylength(N)   ( sizeof(N) / sizeof(*(N)) )
 Returns the length of the array.
 

Detailed Description

Provides common macros.

Definition in file macro.h.

Macro Definition Documentation

#define CGE (   A,
  B,
  BITS 
)    (_CCMP(A, B, BITS) == 0)

Cyclic comparison function Greater Of Equal To.

Evaluates if A >= B, but only within bit bounds.

Parameters
AValue A
BValue B
BITSBits to check.

Definition at line 78 of file macro.h.

#define CGT (   A,
  B,
  BITS 
)    (_CCMP(B, A, BITS) != 0)

Cyclic comparison function Greater Than.

Evaluates if A > B, but only within bit bounds.

Parameters
AValue A
BValue B
BITSBits to check.

Definition at line 66 of file macro.h.

#define CLE (   A,
  B,
  BITS 
)    (_CCMP(B, A, BITS) == 0)

Cyclic comparison function Less Or Equal To.

Evaluates if A <= B, but only within bit bounds.

Parameters
AValue A
BValue B
BITSBits to check.

Definition at line 102 of file macro.h.

#define CLT (   A,
  B,
  BITS 
)    (_CCMP(A, B, BITS) != 0)

Cyclic comparison function Less Than.

Evaluates if A < B, but only within bit bounds.

Parameters
AValue A
BValue B
BITSBits to check.

Definition at line 90 of file macro.h.

#define RESCALE (   INPUT,
  IN_MIN,
  IN_MAX,
  OUT_MIN,
  OUT_MAX 
)
Value:
( ( ( ( ( INPUT ) - ( IN_MIN ) ) * \
( ( OUT_MAX ) - ( OUT_MIN ) ) + ( ( IN_MAX ) - ( IN_MIN ) ) / 2 ) / \
( ( IN_MAX ) - ( IN_MIN ) ) ) + ( OUT_MIN ) )

Re-scales the input value into the range of the output value.

Definition at line 42 of file macro.h.

#define STR (   EXPR)    _STR(EXPR)

Stringyfies an expression.

Parameters
EXPRThe expression to turn into a string

Definition at line 37 of file macro.h.