File: D:\Documents\ProcessorSpecificCode\2006_11_xx_MATLAB_Central\models\proc_spec_code_28x\c28x_iir16_demo\c28x_iir16_pcg_ert_rtw\ert_main.c

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