1/*
2 * File: ert_main.c
3 *
4 * Code generated for Simulink model 'spring4'.
5 *
6 * Model version : 1.5
7 * Simulink Coder version : 8.10 (R2016a) 10-Feb-2016
8 * C/C++ source code generated on : Sun Jun 05 15:18:00 2016
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: ARM Compatible->ARM Cortex
12 * Emulation hardware selection:
13 * Differs from embedded hardware (MATLAB Host)
14 * Code generation objectives:
15 * 1. Execution efficiency
16 * 2. RAM efficiency
17 * Validation result: Not run
18 */
19
20#include <stddef.h>
21#include <stdio.h> /* This ert_main.c example uses printf/fflush */
22#include "spring4.h" /* Model's header file */
23#include "rtwtypes.h"
24
25/*
26 * Associating rt_OneStep with a real-time clock or interrupt service routine
27 * is what makes the generated code "real-time". The function rt_OneStep is
28 * always associated with the base rate of the model. Subrates are managed
29 * by the base rate from inside the generated code. Enabling/disabling
30 * interrupts and floating point context switches are target specific. This
31 * example code indicates where these should take place relative to executing
32 * the generated code step function. Overrun behavior should be tailored to
33 * your application needs. This example simply sets an error status in the
34 * real-time model and returns from rt_OneStep.
35 */
36void rt_OneStep(void);
37void rt_OneStep(void)
38{
39 static boolean_T OverrunFlag = false;
40
41 /* Disable interrupts here */
42
43 /* Check for overrun */
44 if (OverrunFlag) {
45 rtmSetErrorStatus(rtM, "Overrun");
46 return;
47 }
48
49 OverrunFlag = true;
50
51 /* Save FPU context here (if necessary) */
52 /* Re-enable timer or interrupt here */
53 /* Set model inputs here */
54
55 /* Step the model for base rate */
56 spring4_step();
57
58 /* Get model outputs here */
59
60 /* Indicate task complete */
61 OverrunFlag = false;
62
63 /* Disable interrupts here */
64 /* Restore FPU context here (if necessary) */
65 /* Enable interrupts here */
66}
67
68/*
69 * The example "main" function illustrates what is required by your
70 * application code to initialize, execute, and terminate the generated code.
71 * Attaching rt_OneStep to a real-time clock is target specific. This example
72 * illustrates how you do this relative to initializing the model.
73 */
74int_T main(int_T argc, const char *argv[])
75{
76 /* Unused arguments */
77 (void)(argc);
78 (void)(argv);
79
80 /* Initialize model */
81 spring4_initialize();
82
83 /* Simulating the model step behavior (in non real-time) to
84 * simulate model behavior at stop time.
85 */
86 while ((rtmGetErrorStatus(rtM) == (NULL)) && !rtmGetStopRequested(rtM)) {
87 rt_OneStep();
88 }
89
90 /* Disable rt_OneStep() here */
91 return 0;
92}
93
94/*
95 * File trailer for generated code.
96 *
97 * [EOF]
98 */
99