1/*
2 * rtGetInf.c
3 *
4 * Classroom License -- for classroom instructional use only. Not for
5 * government, commercial, academic research, or other organizational use.
6 *
7 * Code generation for model "FoilControlRaspberrySentinel".
8 *
9 * Model version : 1.24
10 * Simulink Coder version : 8.11 (R2016b) 25-Aug-2016
11 * C source code generated on : Wed Nov 23 14:06:32 2016
12 *
13 * Target selection: ert.tlc
14 * Note: GRT includes extra infrastructure and instrumentation for prototyping
15 * Embedded hardware selection: ARM Compatible->ARM Cortex
16 * Code generation objectives: Unspecified
17 * Validation result: Not run
18 */
19
20/*
21 * Abstract:
22 * Function to initialize non-finite, Inf
23 */
24#include "rtGetInf.h"
25#define NumBitsPerChar 8U
26
27/*
28 * Initialize rtInf needed by the generated code.
29 * Inf is initialized as non-signaling. Assumes IEEE.
30 */
31real_T rtGetInf(void)
32{
33 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
34 real_T inf = 0.0;
35 if (bitsPerReal == 32U) {
36 inf = rtGetInfF();
37 } else {
38 uint16_T one = 1U;
39 enum {
40 LittleEndian,
41 BigEndian
42 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
43 switch (machByteOrder) {
44 case LittleEndian:
45 {
46 union {
47 LittleEndianIEEEDouble bitVal;
48 real_T fltVal;
49 } tmpVal;
50
51 tmpVal.bitVal.words.wordH = 0x7FF00000U;
52 tmpVal.bitVal.words.wordL = 0x00000000U;
53 inf = tmpVal.fltVal;
54 break;
55 }
56
57 case BigEndian:
58 {
59 union {
60 BigEndianIEEEDouble bitVal;
61 real_T fltVal;
62 } tmpVal;
63
64 tmpVal.bitVal.words.wordH = 0x7FF00000U;
65 tmpVal.bitVal.words.wordL = 0x00000000U;
66 inf = tmpVal.fltVal;
67 break;
68 }
69 }
70 }
71
72 return inf;
73}
74
75/*
76 * Initialize rtInfF needed by the generated code.
77 * Inf is initialized as non-signaling. Assumes IEEE.
78 */
79real32_T rtGetInfF(void)
80{
81 IEEESingle infF;
82 infF.wordL.wordLuint = 0x7F800000U;
83 return infF.wordL.wordLreal;
84}
85
86/*
87 * Initialize rtMinusInf needed by the generated code.
88 * Inf is initialized as non-signaling. Assumes IEEE.
89 */
90real_T rtGetMinusInf(void)
91{
92 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
93 real_T minf = 0.0;
94 if (bitsPerReal == 32U) {
95 minf = rtGetMinusInfF();
96 } else {
97 uint16_T one = 1U;
98 enum {
99 LittleEndian,
100 BigEndian
101 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
102 switch (machByteOrder) {
103 case LittleEndian:
104 {
105 union {
106 LittleEndianIEEEDouble bitVal;
107 real_T fltVal;
108 } tmpVal;
109
110 tmpVal.bitVal.words.wordH = 0xFFF00000U;
111 tmpVal.bitVal.words.wordL = 0x00000000U;
112 minf = tmpVal.fltVal;
113 break;
114 }
115
116 case BigEndian:
117 {
118 union {
119 BigEndianIEEEDouble bitVal;
120 real_T fltVal;
121 } tmpVal;
122
123 tmpVal.bitVal.words.wordH = 0xFFF00000U;
124 tmpVal.bitVal.words.wordL = 0x00000000U;
125 minf = tmpVal.fltVal;
126 break;
127 }
128 }
129 }
130
131 return minf;
132}
133
134/*
135 * Initialize rtMinusInfF needed by the generated code.
136 * Inf is initialized as non-signaling. Assumes IEEE.
137 */
138real32_T rtGetMinusInfF(void)
139{
140 IEEESingle minfF;
141 minfF.wordL.wordLuint = 0xFF800000U;
142 return minfF.wordL.wordLreal;
143}
144