rtGetNaN.c
Go to the documentation of this file.
00001 /*
00002  * rtGetNaN.c
00003  *
00004  * Embedded MATLAB Coder code generation for function 'autogen_ekf_propagation'
00005  *
00006  * C source code generated on: Wed Aug 24 18:34:48 2011
00007  *
00008  */
00009 
00010 /*
00011  * Abstract:
00012  *       Real-Time Workshop function to initialize non-finite, NaN
00013  */
00014 #include "rtGetNaN.h"
00015 #define NumBitsPerChar  8U
00016 
00017 /* Function: rtGetNaN ==================================================
00018  * Abstract:
00019  * Initialize rtNaN needed by the generated code.
00020  * NaN is initialized as non-signaling. Assumes IEEE.
00021  */
00022 real_T rtGetNaN(void)
00023 {
00024   size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
00025   real_T nan = 0.0;
00026   if (bitsPerReal == 32U) {
00027     nan = rtGetNaNF();
00028   } else {
00029   uint16_T one = 1U;
00030   enum {
00031     LittleEndian,
00032     BigEndian
00033   } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
00034   switch (machByteOrder) {
00035    case LittleEndian:
00036     {
00037       union {
00038         LittleEndianIEEEDouble bitVal;
00039         real_T fltVal;
00040       } tmpVal;
00041 
00042       tmpVal.bitVal.words.wordH = 0xFFF80000U;
00043       tmpVal.bitVal.words.wordL = 0x00000000U;
00044       nan = tmpVal.fltVal;
00045       break;
00046     }
00047 
00048    case BigEndian:
00049     {
00050         union {
00051           BigEndianIEEEDouble bitVal;
00052           real_T fltVal;
00053         } tmpVal;
00054 
00055         tmpVal.bitVal.words.wordH = 0x7FFFFFFFU;
00056         tmpVal.bitVal.words.wordL = 0xFFFFFFFFU;
00057         nan = tmpVal.fltVal;
00058         break;
00059       }
00060     }
00061   }
00062 
00063   return nan;
00064 }
00065 
00066 /* Function: rtGetNaNF ==================================================
00067  * Abstract:
00068  * Initialize rtNaNF needed by the generated code.
00069  * NaN is initialized as non-signaling. Assumes IEEE.
00070  */
00071 real32_T rtGetNaNF(void)
00072 {
00073   IEEESingle nanF;
00074   uint16_T one = 1U;
00075   enum {
00076     LittleEndian,
00077     BigEndian
00078   } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
00079   switch (machByteOrder) {
00080    case LittleEndian:
00081     {
00082       nanF.wordL.wordLuint = 0xFFC00000U;
00083       break;
00084     }
00085 
00086    case BigEndian:
00087     {
00088       nanF.wordL.wordLuint = 0x7FFFFFFFU;
00089       break;
00090     }
00091   }
00092 
00093   return nanF.wordL.wordLreal;
00094 }
00095 
00096 /* End of Embedded MATLAB Coder code generation (rtGetNaN.c) */


asctec_hl_firmware
Author(s): Markus Achtelik, Michael Achtelik, Stephan Weiss, Laurent Kneip
autogenerated on Tue Jan 7 2014 11:05:19