rtGetInf.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * File: rtGetInf.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, Inf
  20. */
  21. #include "rtGetInf.h"
  22. #define NumBitsPerChar 8U
  23. /*
  24. * Initialize rtInf needed by the generated code.
  25. * Inf is initialized as non-signaling. Assumes IEEE.
  26. */
  27. real_T rtGetInf(void)
  28. {
  29. size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
  30. real_T inf = 0.0;
  31. if (bitsPerReal == 32U) {
  32. inf = rtGetInfF();
  33. } else {
  34. union {
  35. LittleEndianIEEEDouble bitVal;
  36. real_T fltVal;
  37. } tmpVal;
  38. tmpVal.bitVal.words.wordH = 0x7FF00000U;
  39. tmpVal.bitVal.words.wordL = 0x00000000U;
  40. inf = tmpVal.fltVal;
  41. }
  42. return inf;
  43. }
  44. /*
  45. * Initialize rtInfF needed by the generated code.
  46. * Inf is initialized as non-signaling. Assumes IEEE.
  47. */
  48. real32_T rtGetInfF(void)
  49. {
  50. IEEESingle infF;
  51. infF.wordL.wordLuint = 0x7F800000U;
  52. return infF.wordL.wordLreal;
  53. }
  54. /*
  55. * Initialize rtMinusInf needed by the generated code.
  56. * Inf is initialized as non-signaling. Assumes IEEE.
  57. */
  58. real_T rtGetMinusInf(void)
  59. {
  60. size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
  61. real_T minf = 0.0;
  62. if (bitsPerReal == 32U) {
  63. minf = rtGetMinusInfF();
  64. } else {
  65. union {
  66. LittleEndianIEEEDouble bitVal;
  67. real_T fltVal;
  68. } tmpVal;
  69. tmpVal.bitVal.words.wordH = 0xFFF00000U;
  70. tmpVal.bitVal.words.wordL = 0x00000000U;
  71. minf = tmpVal.fltVal;
  72. }
  73. return minf;
  74. }
  75. /*
  76. * Initialize rtMinusInfF needed by the generated code.
  77. * Inf is initialized as non-signaling. Assumes IEEE.
  78. */
  79. real32_T rtGetMinusInfF(void)
  80. {
  81. IEEESingle minfF;
  82. minfF.wordL.wordLuint = 0xFF800000U;
  83. return minfF.wordL.wordLreal;
  84. }
  85. /*
  86. * File trailer for generated code.
  87. *
  88. * [EOF]
  89. */