ert_main.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * File: ert_main.c
  3. *
  4. * Code generated for Simulink model 'SMO_arctan_PLL'.
  5. *
  6. * Model version : 1.812
  7. * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
  8. * C/C++ source code generated on : Tue Apr 11 20:18:35 2023
  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. #include <stddef.h>
  18. #include <stdio.h> /* This ert_main.c example uses printf/fflush */
  19. #include "SMO_arctan_PLL.h" /* Model's header file */
  20. #include "rtwtypes.h"
  21. static RT_MODEL rtM_;
  22. static RT_MODEL *const rtMPtr = &rtM_; /* Real-time model */
  23. static DW rtDW; /* Observable states */
  24. /* '<Root>/Ialfa,beta' */
  25. static real_T rtU_Ialfabeta[2];
  26. /* '<Root>/Ualfa,beta' */
  27. static real_T rtU_Ualfabeta[2];
  28. /* '<Root>/theta' */
  29. static real_T rtY_theta;
  30. /* '<Root>/we' */
  31. static real_T rtY_we;
  32. /*
  33. * Associating rt_OneStep with a real-time clock or interrupt service routine
  34. * is what makes the generated code "real-time". The function rt_OneStep is
  35. * always associated with the base rate of the model. Subrates are managed
  36. * by the base rate from inside the generated code. Enabling/disabling
  37. * interrupts and floating point context switches are target specific. This
  38. * example code indicates where these should take place relative to executing
  39. * the generated code step function. Overrun behavior should be tailored to
  40. * your application needs. This example simply sets an error status in the
  41. * real-time model and returns from rt_OneStep.
  42. */
  43. void rt_OneStep(RT_MODEL *const rtM);
  44. void rt_OneStep(RT_MODEL *const rtM)
  45. {
  46. static boolean_T OverrunFlag = false;
  47. /* Disable interrupts here */
  48. /* Check for overrun */
  49. if (OverrunFlag) {
  50. rtmSetErrorStatus(rtM, "Overrun");
  51. return;
  52. }
  53. OverrunFlag = true;
  54. /* Save FPU context here (if necessary) */
  55. /* Re-enable timer or interrupt here */
  56. /* Set model inputs here */
  57. /* Step the model */
  58. SMO_arctan_PLL_step(rtM, rtU_Ialfabeta, rtU_Ualfabeta, &rtY_theta, &rtY_we);
  59. /* Get model outputs here */
  60. /* Indicate task complete */
  61. OverrunFlag = false;
  62. /* Disable interrupts here */
  63. /* Restore FPU context here (if necessary) */
  64. /* Enable interrupts here */
  65. }
  66. /*
  67. * The example "main" function illustrates what is required by your
  68. * application code to initialize, execute, and terminate the generated code.
  69. * Attaching rt_OneStep to a real-time clock is target specific. This example
  70. * illustrates how you do this relative to initializing the model.
  71. */
  72. int_T main(int_T argc, const char *argv[])
  73. {
  74. RT_MODEL *const rtM = rtMPtr;
  75. /* Unused arguments */
  76. (void)(argc);
  77. (void)(argv);
  78. /* Pack model data into RTM */
  79. rtM->dwork = &rtDW;
  80. /* Initialize model */
  81. SMO_arctan_PLL_initialize(rtM);
  82. /* Attach rt_OneStep to a timer or interrupt service routine with
  83. * period 6.0E-5 seconds (the model's base sample time) here. The
  84. * call syntax for rt_OneStep is
  85. *
  86. * rt_OneStep(rtM);
  87. */
  88. printf("Warning: The simulation will run forever. "
  89. "Generated ERT main won't simulate model step behavior. "
  90. "To change this behavior select the 'MAT-file logging' option.\n");
  91. fflush((NULL));
  92. while (rtmGetErrorStatus(rtM) == (NULL)) {
  93. /* Perform other application tasks here */
  94. }
  95. /* Disable rt_OneStep() here */
  96. return 0;
  97. }
  98. /*
  99. * File trailer for generated code.
  100. *
  101. * [EOF]
  102. */