rtGetNaN.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * Abstract:
  19. * Function to initialize non-finite, NaN
  20. */
  21. #include "rtGetNaN.h"
  22. #define NumBitsPerChar 8U
  23. /*
  24. * Initialize rtNaN needed by the generated code.
  25. * NaN is initialized as non-signaling. Assumes IEEE.
  26. */
  27. real_T rtGetNaN(void)
  28. {
  29. size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
  30. real_T nan = 0.0;
  31. if (bitsPerReal == 32U) {
  32. nan = rtGetNaNF();
  33. } else {
  34. union {
  35. LittleEndianIEEEDouble bitVal;
  36. real_T fltVal;
  37. } tmpVal;
  38. tmpVal.bitVal.words.wordH = 0xFFF80000U;
  39. tmpVal.bitVal.words.wordL = 0x00000000U;
  40. nan = tmpVal.fltVal;
  41. }
  42. return nan;
  43. }
  44. /*
  45. * Initialize rtNaNF needed by the generated code.
  46. * NaN is initialized as non-signaling. Assumes IEEE.
  47. */
  48. real32_T rtGetNaNF(void)
  49. {
  50. IEEESingle nanF = { { 0 } };
  51. nanF.wordL.wordLuint = 0xFFC00000U;
  52. return nanF.wordL.wordLreal;
  53. }
  54. /*
  55. * File trailer for generated code.
  56. *
  57. * [EOF]
  58. */