| 1 | /* |
| 2 | * File: rtGetNaN.c |
| 3 | * |
| 4 | * Code generated for Simulink model 'PMSM_Controller'. |
| 5 | * |
| 6 | * Model version : 1.885 |
| 7 | * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020 |
| 8 | * C/C++ source code generated on : Sat Jan 8 15:44:11 2022 |
| 9 | * |
| 10 | * Target selection: ert.tlc |
| 11 | * Embedded hardware selection: ARM Compatible->ARM Cortex-M |
| 12 | * Code generation objectives: |
| 13 | * 1. Execution efficiency |
| 14 | * 2. RAM efficiency |
| 15 | * Validation result: Not run |
| 16 | */ |
| 17 | |
| 18 | /* |
| 19 | * Abstract: |
| 20 | * Function to initialize non-finite, NaN |
| 21 | */ |
| 22 | #include "rtGetNaN.h" |
| 23 | #define NumBitsPerChar 8U |
| 24 | |
| 25 | /* |
| 26 | * Initialize rtNaN needed by the generated code. |
| 27 | * NaN is initialized as non-signaling. Assumes IEEE. |
| 28 | */ |
| 29 | real_T rtGetNaN(void) |
| 30 | { |
| 31 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); |
| 32 | real_T nan = 0.0; |
| 33 | if (bitsPerReal == 32U) { |
| 34 | nan = rtGetNaNF(); |
| 35 | } else { |
| 36 | union { |
| 37 | LittleEndianIEEEDouble bitVal; |
| 38 | real_T fltVal; |
| 39 | } tmpVal; |
| 40 | |
| 41 | tmpVal.bitVal.words.wordH = 0xFFF80000U; |
| 42 | tmpVal.bitVal.words.wordL = 0x00000000U; |
| 43 | nan = tmpVal.fltVal; |
| 44 | } |
| 45 | |
| 46 | return nan; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * Initialize rtNaNF needed by the generated code. |
| 51 | * NaN is initialized as non-signaling. Assumes IEEE. |
| 52 | */ |
| 53 | real32_T rtGetNaNF(void) |
| 54 | { |
| 55 | IEEESingle nanF = { { 0 } }; |
| 56 | |
| 57 | nanF.wordL.wordLuint = 0xFFC00000U; |
| 58 | return nanF.wordL.wordLreal; |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * File trailer for generated code. |
| 63 | * |
| 64 | * [EOF] |
| 65 | */ |
| 66 |