📄 c2812pmsmsim1_main.c
字号:
/*
* File: c2812pmsmsim1_main.c
*
* Real-Time Workshop code generated for Simulink model c2812pmsmsim1.
*
* Model version : 1.287
* Real-Time Workshop file version : 7.0 (R2007b) 02-Aug-2007
* Real-Time Workshop file generated on : Mon May 26 17:20:51 2008
* TLC version : 7.0 (Jul 26 2007)
* C source code generated on : Mon May 26 17:20:56 2008
*/
#include "c2812pmsmsim1.h"
#include "c2812pmsmsim1_private.h"
#include "rtwtypes.h"
#include "c2000_main.h"
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"
void init_board(void);
void enable_interrupts(void);
void config_schedulerTimer(void);
void disable_interrupts(void);
volatile int IsrOverrun = 0;
boolean_T isRateRunning[2] = { 0, 0 };
boolean_T need2runFlags[2] = { 0, 0 };
/* Function: rt_OneStep -------------------------------------------
*
* Abstract:
* Perform one step of the model. Multi-tasking implementation.
*/
void rt_OneStep(void)
{
boolean_T eventFlags[2];
/* Check base rate for overrun */
// disabling interrupts
asm(" SETC INTM");
if (isRateRunning[0]++) {
IsrOverrun = 1;
isRateRunning[0]--; // allow future iterations to succeed
// enabling interrupts
asm(" CLRC INTM");
return;
}
/*
* For a bare-board target (i.e., no operating system), the rates
* that execute this base step are buffered locally to allow for
* overlapping preemption. The generated code includes function
* c2812pmsmsim1_SetEventsForThisBaseStep() which sets the rates
* that need to run this time step. The return values are 1 and 0
* for true and false, respectively.
*/
c2812pmsmsim1_SetEventsForThisBaseStep(eventFlags);
// enabling interrupts
asm(" CLRC INTM");
c2812pmsmsim1_step(0);
isRateRunning[0]--;
if (eventFlags[1]) {
if (need2runFlags[1]++) {
IsrOverrun = 1;
need2runFlags[1]--; // allow future iterations to succeed
return;
}
}
if (need2runFlags[1]) {
if (isRateRunning[1]) {
//Yield to higher priority
return;
}
// disabling interrupts
asm(" SETC INTM");
isRateRunning[1]++;
// enabling interrupts
asm(" CLRC INTM");
c2812pmsmsim1_step(1);
need2runFlags[1]--;
isRateRunning[1]--;
}
}
//
// Entry point into the code
//
void main(void)
{
volatile boolean_T noErr;
init_board();
c2812pmsmsim1_initialize(1);
/* **starting the model** */
enable_interrupts();
config_schedulerTimer();
noErr =
rtmGetErrorStatus(c2812pmsmsim1_M) == NULL;
while (noErr ) {
noErr =
rtmGetErrorStatus(c2812pmsmsim1_M) == NULL;
}
/* **stopping the model** */
/* Disable rt_OneStep() here */
/* Terminate model */
c2812pmsmsim1_terminate();
disable_interrupts();
}
/* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -