User`s guide
55
* 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)
{
real_T tnext;
// Check for overrun. Protect OverrunFlag against
// pre-emption
asm(" SETC INTM");
if (OverrunFlag++) {
IsrOverrun = 1;
OverrunFlag--;
asm(" CLRC INTM");
return;
}
asm(" CLRC INTM");
tnext = rt_SimGetNextSampleHit();
rtsiSetSolverStopTime(rtmGetRTWSolverInfo(S), tnext);
MdlOutputs(0);
MdlUpdate(0);
rt_SimUpdateDiscreteTaskSampleHits(rtmGetNumSampleTimes(S),
rtmGetTimingData(S),
rtmGetSampleHitPtr(S),
rtmGetTPtr(S));
OverrunFlag--;
}
//
// Entry point into the code
//
void main(void)
{
volatile boolean_T noErr;
const char_T *status;
init_board();
/************************
* Initialize the model *
************************/
rt_InitInfAndNaN(sizeof(real_T));
S = MODEL();
if (rtmGetErrorStatus(S) != NULL) {
/* Error during model registration */
exit(EXIT_FAILURE);
}
rtmSetTFinal(S, rtInf);
MdlInitializeSizes();
MdlInitializeSampleTimes();
status = rt_SimInitTimingEngine(rtmGetNumSampleTimes(S),
rtmGetStepSize(S),
rtmGetSampleTimePtr(S),