    1/*

    2 * File: ert_main.c

    3 *

    4 * Code generated for Simulink model 'Inverter_001'.

    5 *

    6 * Model version                  : 1.139

    7 * Simulink Coder version         : 8.14 (R2018a) 06-Feb-2018

    8 * C/C++ source code generated on : Wed Apr 14 17:37:41 2021

    9 *

    10 * Target selection: ert.tlc

    11 * Embedded hardware selection: Texas Instruments->C2000

    12 * Code generation objectives: Unspecified

    13 * Validation result: Not run

    14 */

    15

    16#include "Inverter_001.h"

    17#include "rtwtypes.h"

    18

    19volatile int IsrOverrun = 0;

    20boolean_T isRateRunning[4] = { 0, 0, 0, 0 };

    21

    22boolean_T need2runFlags[4] = { 0, 0, 0, 0 };

    23

    24void rt_OneStep(void)

    25{

    26  boolean_T eventFlags[4];

    27  int_T i;

    28

    29  /* Check base rate for overrun */

    30  if (isRateRunning[0]++) {

    31    IsrOverrun = 1;

    32    isRateRunning[0]--;                /* allow future iterations to succeed*/

    33    return;

    34  }

    35

    36  /*

    37   * For a bare-board target (i.e., no operating system), the rates

    38   * that execute this base step are buffered locally to allow for

    39   * overlapping preemption.  The generated code includes function

    40   * writeCodeInfoFcn() which sets the rates

    41   * that need to run this time step.  The return values are 1 and 0

    42   * for true and false, respectively.

    43   */

    44  Inverter_001_SetEventsForThisBaseStep(eventFlags);

    45  enableTimer0Interrupt();

    46  Inverter_001_step0();

    47

    48  /* Get model outputs here */

    49  disableTimer0Interrupt();

    50  isRateRunning[0]--;

    51  for (i = 1; i < 4; i++) {

    52    if (eventFlags[i]) {

    53      if (need2runFlags[i]++) {

    54        IsrOverrun = 1;

    55        need2runFlags[i]--;            /* allow future iterations to succeed*/

    56        break;

    57      }

    58    }

    59  }

    60

    61  for (i = 1; i < 4; i++) {

    62    if (isRateRunning[i]) {

    63      /* Yield to higher priority*/

    64      return;

    65    }

    66

    67    if (need2runFlags[i]) {

    68      isRateRunning[i]++;

    69      enableTimer0Interrupt();

    70

    71      /* Step the model for subrate "i" */

    72      switch (i)

    73      {

    74       case 1 :

    75        Inverter_001_step1();

    76

    77        /* Get model outputs here */

    78        break;

    79

    80       case 2 :

    81        Inverter_001_step2();

    82

    83        /* Get model outputs here */

    84        break;

    85

    86       case 3 :

    87        Inverter_001_step3();

    88

    89        /* Get model outputs here */

    90        break;

    91

    92       default :

    93        break;

    94      }

    95

    96      disableTimer0Interrupt();

    97      need2runFlags[i]--;

    98      isRateRunning[i]--;

    99    }

    100  }

    101}

    102

    103volatile boolean_T stopRequested = false;

    104int main(void)

    105{

    106  volatile boolean_T runModel = true;

    107  float modelBaseRate = 5.0E-5;

    108  float systemClock = 200;

    109  c2000_flash_init();

    110  init_board();

    111

    112#ifdef MW_EXEC_PROFILER_ON

    113

    114  config_profilerTimer();

    115

    116#endif

    117

    118  ;

    119  rtmSetErrorStatus(Inverter_001_M, 0);

    120  Inverter_001_initialize();

    121  configureTimer0(modelBaseRate, systemClock);

    122  runModel =

    123    rtmGetErrorStatus(Inverter_001_M) == (NULL);

    124  enableTimer0Interrupt();

    125  globalInterruptEnable();

    126  while (runModel) {

    127    stopRequested = !(

    128                      rtmGetErrorStatus(Inverter_001_M) == (NULL));

    129    runModel = !(stopRequested);

    130  }

    131

    132  /* Disable rt_OneStep() here */

    133

    134  /* Terminate model */

    135  Inverter_001_terminate();

    136  globalInterruptDisable();

    137  return 0;

    138}

    139

    140/*

    141 * File trailer for generated code.

    142 *

    143 * [EOF]

    144 */

    145