⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c2000scitest_2812tgt_main.c

📁 由MATLAB生成的SCI的源代码
💻 C
字号:
/*
 * File: c2000scitest_2812tgt_main.c
 *
 * Real-Time Workshop code generated for Simulink model c2000scitest_2812tgt.
 *
 * Model version                        : 1.104
 * Real-Time Workshop file version      : 6.3  (R14SP3)  26-Jul-2005
 * Real-Time Workshop file generated on : Sat Dec 13 20:37:34 2008
 * TLC version                          : 6.3 (Aug  5 2005)
 * C source code generated on           : Sat Dec 13 20:37:35 2008
 */

#include "rtwtypes.h"                   // MathWorks types
#include "c2000scitest_2812tgt.h"       // Model's header file

extern volatile int pendingInterrupt;
volatile int IsrOverrun = 0;
static boolean_T OverrunFlag = 0;

/* 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)
{
  /* Disable interrupts here */

  /* Check for overun */
  if (OverrunFlag++) {
    rtmSetErrorStatus(c2000scitest_2812tgt_M, "Overrun");
    return;
  }

  /* Save FPU context here (if necessary) */
  /* Re-enable timer or interrupt here */
  /* Set model inputs here */

  c2000scitest_2812tgt_step();

  /* Get model outputs here */

  OverrunFlag--;

  /* Disable interrupts here */
  /* Restore FPU context here (if necessary) */
  /* Enable interrupts here */
}

void main(void)
{
  /* This is to avoid being optimized away by c2000 compiler o/w
     rtmGetErrorStatus() could be used directly */
  volatile int_T errorStatus;

  init_board();

  c2000scitest_2812tgt_initialize(1);

  errorStatus = rtmGetErrorStatus(c2000scitest_2812tgt_M) != NULL;

  config_schedulerTimer();

  enable_interrupts();

  while (!errorStatus) {
    while (!pendingInterrupt) {         /* wait */
    };
    pendingInterrupt = 0;
    rt_OneStep();
    if (pendingInterrupt) {
      /* Interrupt overrun detected; User selected action = Continue */
      enable_interrupts();
    }

    errorStatus = rtmGetErrorStatus(c2000scitest_2812tgt_M) != NULL;
  }

  disable_interrupts();

  /* Disable rt_OneStep() here */

  /* Terminate model */
  c2000scitest_2812tgt_terminate();
}

/* File trailer for Real-Time Workshop generated code.
 *
 * [EOF]
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -