1 | /* |
2 | * File: ert_main.c |
3 | * |
4 | * Code generated for Simulink model 'untitled'. |
5 | * |
6 | * Model version : 1.0 |
7 | * Simulink Coder version : 8.12 (R2017a) 16-Feb-2017 |
8 | * C/C++ source code generated on : Thu Mar 14 11:23:20 2019 |
9 | * |
10 | * Target selection: ert.tlc |
11 | * Embedded hardware selection: Atmel->AVR |
12 | * Code generation objectives: Unspecified |
13 | * Validation result: Not run |
14 | */ |
15 | |
16 | #include "untitled.h" |
17 | #include "rtwtypes.h" |
18 | #include <ext_work.h> |
19 | #include <ext_svr.h> |
20 | #include <ext_share.h> |
21 | #include <updown.h> |
22 | |
23 | volatile int IsrOverrun = 0; |
24 | static boolean_T OverrunFlag = 0; |
25 | void rt_OneStep(void) |
26 | { |
27 | /* Check for overrun. Protect OverrunFlag against preemption */ |
28 | if (OverrunFlag++) { |
29 | IsrOverrun = 1; |
30 | OverrunFlag--; |
31 | return; |
32 | } |
33 | |
34 | #ifndef _MW_ARDUINO_LOOP_ |
35 | |
36 | sei(); |
37 | |
38 | #endif; |
39 | |
40 | untitled_step(); |
41 | |
42 | /* Get model outputs here */ |
43 | #ifndef _MW_ARDUINO_LOOP_ |
44 | |
45 | cli(); |
46 | |
47 | #endif; |
48 | |
49 | OverrunFlag--; |
50 | rtExtModeCheckEndTrigger(); |
51 | } |
52 | |
53 | int main(void) |
54 | { |
55 | volatile boolean_T runModel = 1; |
56 | float modelBaseRate = 0.1; |
57 | float systemClock = 0; |
58 | init(); |
59 | MW_Arduino_Init(); |
60 | rtmSetErrorStatus(untitled_M, 0); |
61 | |
62 | /* initialize external mode */ |
63 | rtParseArgsForExtMode(0, NULL); |
64 | untitled_initialize(); |
65 | sei(); |
66 | |
67 | /* External mode */ |
68 | rtSetTFinalForExtMode(&rtmGetTFinal(untitled_M)); |
69 | rtExtModeCheckInit(1); |
70 | |
71 | { |
72 | boolean_T rtmStopReq = false; |
73 | rtExtModeWaitForStartPkt(untitled_M->extModeInfo, 1, &rtmStopReq); |
74 | if (rtmStopReq) { |
75 | rtmSetStopRequested(untitled_M, true); |
76 | } |
77 | } |
78 | |
79 | rtERTExtModeStartMsg(); |
80 | cli(); |
81 | configureArduinoAVRTimer(); |
82 | runModel = |
83 | (rtmGetErrorStatus(untitled_M) == (NULL)) && !rtmGetStopRequested(untitled_M); |
84 | |
85 | #ifndef _MW_ARDUINO_LOOP_ |
86 | |
87 | sei(); |
88 | |
89 | #endif; |
90 | |
91 | sei(); |
92 | while (runModel) { |
93 | /* External mode */ |
94 | { |
95 | boolean_T rtmStopReq = false; |
96 | rtExtModeOneStep(untitled_M->extModeInfo, 1, &rtmStopReq); |
97 | if (rtmStopReq) { |
98 | rtmSetStopRequested(untitled_M, true); |
99 | } |
100 | } |
101 | |
102 | runModel = |
103 | (rtmGetErrorStatus(untitled_M) == (NULL)) && !rtmGetStopRequested |
104 | (untitled_M); |
105 | runModel = runModel && MW_Arduino_Loop(); |
106 | } |
107 | |
108 | rtExtModeShutdown(1); |
109 | |
110 | /* Disable rt_OneStep() here */ |
111 | |
112 | /* Terminate model */ |
113 | untitled_terminate(); |
114 | cli(); |
115 | return 0; |
116 | } |
117 | |
118 | /* |
119 | * File trailer for generated code. |
120 | * |
121 | * [EOF] |
122 | */ |
123 |