附录上生成的 main.c
#include "SPI01.h"
#include "rtwtypes.h"
#include "SPI01_private.h"
#include "c2000_main.h"
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"
#include <stdlib.h>
#include <stdio.h>
void init_board(void);
void enable_interrupts(void);
void config_schedulerTimer(void);
void disable_interrupts(void);
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)
{
// Check for overrun. Protect OverrunFlag against
// pre-emption
asm(" SETC INTM");
if (OverrunFlag++) {
IsrOverrun = 1;
OverrunFlag--;
asm(" CLRC INTM");
return;
}
asm(" CLRC INTM");
SPI01_step();
/* Get model outputs here */
OverrunFlag--;
}
//
// Entry point into the code
//
void main(void)
{
volatile boolean_T noErr;
init_board();
SPI01_initialize(1);
/* **starting the model** */
config_schedulerTimer();
noErr =
rtmGetErrorStatus(SPI01_M) == (NULL);
enable_interrupts();
while (noErr ) {
noErr =
rtmGetErrorStatus(SPI01_M) == (NULL);
}
/* **stopping the model** */
/* Disable rt_OneStep() here */
/* Terminate model */
SPI01_terminate();
disable_interrupts();
}
/* File trailer for Real-Time Workshop generated code.
*
* [EOF]
*/