1/*
2 * Academic License - for use in teaching, academic research, and meeting
3 * course requirements at degree granting institutions only. Not for
4 * government, commercial, or other organizational use.
5 *
6 * File: ert_main.c
7 *
8 * Code generated for Simulink model 'FCC_Sys_New'.
9 *
10 * Model version : 1.85
11 * Simulink Coder version : 9.3 (R2020a) 18-Nov-2019
12 * C/C++ source code generated on : Fri Jul 10 14:45:34 2020
13 *
14 * Target selection: ert.tlc
15 * Embedded hardware selection: Intel->x86-32 (Windows32)
16 * Code generation objectives:
17 * 1. Execution efficiency
18 * 2. RAM efficiency
19 * Validation result: Not run
20 */
21
22#include <stddef.h>
23#include <stdio.h> /* This ert_main.c example uses printf/fflush */
24#include "FCC_Sys_New.h" /* Model's header file */
25#include "rtwtypes.h"
26#include "model_reference_types.h"
27
28/*
29 * Associating rt_OneStep with a real-time clock or interrupt service routine
30 * is what makes the generated code "real-time". The function rt_OneStep is
31 * always associated with the base rate of the model. Subrates are managed
32 * by the base rate from inside the generated code. Enabling/disabling
33 * interrupts and floating point context switches are target specific. This
34 * example code indicates where these should take place relative to executing
35 * the generated code step function. Overrun behavior should be tailored to
36 * your application needs. This example simply sets an error status in the
37 * real-time model and returns from rt_OneStep.
38 */
39void rt_OneStep(void);
40void rt_OneStep(void)
41{
42 static boolean_T OverrunFlags[2] = { 0, 0 };
43
44 static boolean_T eventFlags[2] = { 0, 0 };/* Model has 2 rates */
45
46 static int_T taskCounter[2] = { 0, 0 };
47
48 /* Disable interrupts here */
49
50 /* Check base rate for overrun */
51 if (OverrunFlags[0]) {
52 return;
53 }
54
55 OverrunFlags[0] = true;
56
57 /* Save FPU context here (if necessary) */
58 /* Re-enable timer or interrupt here */
59
60 /*
61 * For a bare-board target (i.e., no operating system), the
62 * following code checks whether any subrate overruns,
63 * and also sets the rates that need to run this time step.
64 */
65 if (taskCounter[1] == 0) {
66 if (eventFlags[1]) {
67 OverrunFlags[0] = false;
68 OverrunFlags[1] = true;
69 return;
70 }
71
72 eventFlags[1] = true;
73 }
74
75 taskCounter[1]++;
76 if (taskCounter[1] == 10) {
77 taskCounter[1]= 0;
78 }
79
80 /* Set model inputs associated with base rate here */
81
82 /* Step the model for base rate */
83 FCC_Sys_New_step0();
84
85 /* Get model outputs here */
86
87 /* Indicate task for base rate complete */
88 OverrunFlags[0] = false;
89
90 /* If task 1 is running, don't run any lower priority task */
91 if (OverrunFlags[1]) {
92 return;
93 }
94
95 /* Step the model for subrate */
96 if (eventFlags[1]) {
97 OverrunFlags[1] = true;
98
99 /* Set model inputs associated with subrates here */
100
101 /* Step the model for subrate 1 */
102 FCC_Sys_New_step1();
103
104 /* Get model outputs here */
105
106 /* Indicate task complete for subrate */
107 OverrunFlags[1] = false;
108 eventFlags[1] = false;
109 }
110
111 /* Disable interrupts here */
112 /* Restore FPU context here (if necessary) */
113 /* Enable interrupts here */
114}
115
116/*
117 * The example "main" function illustrates what is required by your
118 * application code to initialize, execute, and terminate the generated code.
119 * Attaching rt_OneStep to a real-time clock is target specific. This example
120 * illustrates how you do this relative to initializing the model.
121 */
122int_T main(int_T argc, const char *argv[])
123{
124 /* Unused arguments */
125 (void)(argc);
126 (void)(argv);
127
128 /* Initialize model */
129 FCC_Sys_New_initialize();
130
131 /* Attach rt_OneStep to a timer or interrupt service routine with
132 * period 0.001 seconds (the model's base sample time) here. The
133 * call syntax for rt_OneStep is
134 *
135 * rt_OneStep();
136 */
137 printf("Warning: The simulation will run forever. "
138 "Generated ERT main won't simulate model step behavior. "
139 "To change this behavior select the 'MAT-file logging' option.\n");
140 fflush((NULL));
141 while (1) {
142 /* Perform other application tasks here */
143 }
144
145 /* The option 'Remove error status field in real-time model data structure'
146 * is selected, therefore the following code does not need to execute.
147 */
148#if 0
149
150 /* Disable rt_OneStep() here */
151#endif
152
153 return 0;
154}
155
156/*
157 * File trailer for generated code.
158 *
159 * [EOF]
160 */
161