/* * File: ert_main.c * * Code generated for Simulink model 'external_test'. * * Model version : 1.5 * Simulink Coder version : 8.0 (R2011a) 09-Mar-2011 * TLC version : 8.0 (Feb 3 2011) * C/C++ source code generated on : Sat Mar 24 19:12:40 2012 * * Target selection: ert.tlc * Embedded hardware selection: 32-bit Generic * Code generation objectives: Unspecified * Validation result: Not run */ #include /* This ert_main.c example uses printf/fflush */ #include "external_test.h" /* Model's header file */ #include "rtwtypes.h" /* MathWorks types */ #include "ext_work.h" /* External mode header file */ /* * Associating rt_OneStep with a real-time clock or interrupt service routine * is what makes the generated code "real-time". The function rt_OneStep is * always associated with the base rate of the model. Subrates are managed * by the base rate from inside the generated code. Enabling/disabling * interrupts and floating point context switches are target specific. This * example code indicates where these should take place relative to executing * the generated code step function. Overrun behavior should be tailored to * your application needs. This example simply sets an error status in the * real-time model and returns from rt_OneStep. */ void rt_OneStep(void); void rt_OneStep(void) { static boolean_T OverrunFlag = FALSE; /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag) { rtmSetErrorStatus(external_test_M, "Overrun"); return; } OverrunFlag = TRUE; /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ /* Step the model for base rate */ external_test_step(); /* Get model outputs here */ /* Indicate task complete */ OverrunFlag = FALSE; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ rtExtModeCheckEndTrigger(); } /* * The example "main" function illustrates what is required by your * application code to initialize, execute, and terminate the generated code. * Attaching rt_OneStep to a real-time clock is target specific. This example * illustates how you do this relative to initializing the model. */ int_T main(int_T argc, const char_T *argv[]); int_T main(int_T argc, const char_T *argv[]) { /* External mode */ rtERTExtModeParseArgs(argc, argv); /* Initialize model */ external_test_initialize(); /* The External Mode option selected; therefore, * simulating the model step behavior (in non real-time). */ while ((rtmGetErrorStatus(external_test_M) == (NULL)) && !rtmGetStopRequested (external_test_M)) { rt_OneStep(); } /* External mode */ rtExtModeShutdown(2); /* Disable rt_OneStep() here */ /* Terminate model */ external_test_terminate(); return 0; } /* * File trailer for generated code. * * [EOF] */