File: C:\Users\SLUG\Documents\MATLAB\SLUG_Autopilot\Stable\controlMCUSlugsMKII_dspic\sources\controlMCUSlugsMKII_main.c

    1   /*
    2    * File: controlMCUSlugsMKII_main.c
    3    *
    4    * Real-Time Workshop code generated for Simulink model controlMCUSlugsMKII.
    5    *
    6    * Model version                        : 1.714
    7    * Real-Time Workshop file version      : 7.5  (R2010a)  25-Jan-2010
    8    * Real-Time Workshop file generated on : Tue Nov 23 13:12:51 2010
    9    * TLC version                          : 7.5 (Jan 19 2010)
   10    * C source code generated on           : Tue Nov 23 13:12:52 2010
   11    *--------------------------------------------------------------
   12    *   Embedded Coder for Microchip dsPIC family.                 |
   13    *   Generate .c and .h files from your Matlab/simulink model   |
   14    *   and compile the diagram to .hex and .coff file that can be |
   15    *   downloaded directly into the microcontroller               |
   16    *                                                              |
   17    * Licence Accorded to Blake Mills                              |
   18    *                     University of Colorado-Boulder           |
   19    *                                                              |
   20    *   Written by Lubin KERHUEL -  http://www.kerhuel.eu          |
   21    *  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
   22    *   Version 3.3a                              22-Nov-2010      |
   23    *   For Matlab 7.10            R2010a                          |
   24    *--------------------------------------------------------------
   25    */
   26   
   27   #include "controlMCUSlugsMKII.h"
   28   #include "controlMCUSlugsMKII_private.h"
   29   #ifdef _FSS                            /* for chip with memory protection options */
   30   
   31   _FSS( RSS_NO_RAM & SSS_NO_FLASH & SWRP_WRPROTECT_OFF )
   32   #endif
   33     _FGS( GCP_OFF & GSS_OFF & GWRP_OFF )
   34     _FOSCSEL( FNOSC_PRIPLL & IESO_OFF & 0xFFFF )
   35     _FOSC( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_EC)
   36     _FPOR( FPWRT_PWR64 )
   37     _FWDT( FWDTEN_OFF )
   38     _FICD( JTAGEN_OFF & ICS_PGD1 )
   39     uint16_T CalculusTimeStep;
   40   void rt_OneStep()
   41   {
   42     boolean_T eventFlags[2];
   43     int_T i;
   44   
   45     /* Disable interrupts here */
   46     /* Save FPU context here (if necessary) */
   47     /* Re-enable timer or interrupt here */
   48     controlMCUSlugsMKII_SetEventsForThisBaseStep(eventFlags);
   49     controlMCUSlugsMKII_step(0);
   50   
   51     /* Get model outputs here */
   52     for (i = 1; i < 2; i++) {
   53       if (eventFlags[i]) {
   54         controlMCUSlugsMKII_step(i);
   55   
   56         /* Get model outputs here */
   57       }
   58     }
   59   
   60     /* Disable interrupts here */
   61     /* Restore FPU context here (if necessary) */
   62     /* Enable interrupts here */
   63   }
   64   
   65   int main(void)
   66   {
   67     PLLFBD = 38;                         /* configure clock speed */
   68     CLKDIV = 1;
   69   
   70     /* Initialize model */
   71     controlMCUSlugsMKII_initialize(1);
   72   
   73     /* Associate rt_OneStep() with a timer that executes at the base rate of the model */
   74     for (;;) {
   75       /* Associate rt_OneStep() with a timer that executes at the base rate of the model */
   76       while (!_T1IF) ;
   77       _T1IF = 0;
   78       rt_OneStep();
   79       if (_T1IF)
   80         CalculusTimeStep = PR1;          /* Overload */
   81       else
   82         CalculusTimeStep = TMR1;
   83     }
   84   }
   85   
   86   /* File trailer for Real-Time Workshop generated code.
   87    *
   88    * [EOF]
   89    */
   90