ert_main.c 3.1 KB

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