/***************************************************************************
                     FILE INFORMATION HEADER
                     -----------------------

    a.  PROJECT NAME:       GRIFO_S7  P2813
    b.  ITEM TYPE:		header
    c.  ITEM NAME:              fixed_point_types.h
    d.  ITEM REFERENCE:
    e.  CURRENT VERSION:        1.1
    f.  DATE:                   3/6/97
    g.  SOURCE FILE LOCATION:   /sparc-2/library/sr3b_end/dati/common/cmn_dt/s.fixed_point_types.h
    h.  'C' RELEASE:            2.11
    i.  ITEM DESCRIPTION:       It contains commonly used fixed point types.
    j.  DOCUMENTATION REFERENCES:
    k.  PROGRAMMER NAME(S):     B.Bontempi
				S.R.Curtis
    l.  COPYRIGHT:              FIAR
    m.  REVISION HISTORY:    07-11-01 - Baseline copied from 3B.86 R3K Metis radar version

 ***************************************************************************/

#ifndef fixed_point_types_defined
//## attribute ::types_reverse::TopLevel.fixed_point_types_defined
const RhpString fixed_point_types_defined;

/***** Fixed Point base types, ie represented as integers with LSB *****/

namespace legacy
{
    // Radians, 0 .. 2pi 
    // NOTE: The conversion will normalise the value. 
    //## type ushort_radians_t
    typedef unsigned short ushort_radians_t;
}

//## attribute ::types_reverse::TopLevel.USHORT_RADIANS_T_LSB
const RhpString USHORT_RADIANS_T_LSB(9.5873799e-05F);

//#[ type Radians_To_UShort_Radians
#define Radians_To_UShort_Radians( rad ) \
  (ushort_radians_t)((((int)((rad)/USHORT_RADIANS_T_LSB) % MAX_UNSIGNED_SHORT) \
     + MAX_UNSIGNED_SHORT) % MAX_UNSIGNED_SHORT )
//#]

//#[ type UShort_Radians_To_Radians
#define UShort_Radians_To_Radians( ushort_rad ) \
  (radians_t)((ushort_rad) * USHORT_RADIANS_T_LSB)
//#]

#endif
