1/*
2 * File: ert_main.c
3 *
4 * Code generated for Simulink model 'SMO_arctan_PLL'.
5 *
6 * Model version : 1.812
7 * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
8 * C/C++ source code generated on : Tue Apr 11 20:18:35 2023
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: ARM Compatible->ARM Cortex-M
12 * Code generation objectives:
13 * 1. Execution efficiency
14 * 2. RAM efficiency
15 * Validation result: Not run
16 */
17
18#include <stddef.h>
19#include <stdio.h> /* This ert_main.c example uses printf/fflush */
20#include "SMO_arctan_PLL.h" /* Model's header file */
21#include "rtwtypes.h"
22
23static RT_MODEL rtM_;
24static RT_MODEL *const rtMPtr = &rtM_; /* Real-time model */
25static DW rtDW; /* Observable states */
26
27/* '<Root>/Ialfa,beta' */
28static real_T rtU_Ialfabeta[2];
29
30/* '<Root>/Ualfa,beta' */
31static real_T rtU_Ualfabeta[2];
32
33/* '<Root>/theta' */
34static real_T rtY_theta;
35
36/* '<Root>/we' */
37static real_T rtY_we;
38
39/*
40 * Associating rt_OneStep with a real-time clock or interrupt service routine
41 * is what makes the generated code "real-time". The function rt_OneStep is
42 * always associated with the base rate of the model. Subrates are managed
43 * by the base rate from inside the generated code. Enabling/disabling
44 * interrupts and floating point context switches are target specific. This
45 * example code indicates where these should take place relative to executing
46 * the generated code step function. Overrun behavior should be tailored to
47 * your application needs. This example simply sets an error status in the
48 * real-time model and returns from rt_OneStep.
49 */
50void rt_OneStep(RT_MODEL *const rtM);
51void rt_OneStep(RT_MODEL *const rtM)
52{
53 static boolean_T OverrunFlag = false;
54
55 /* Disable interrupts here */
56
57 /* Check for overrun */
58 if (OverrunFlag) {
59 rtmSetErrorStatus(rtM, "Overrun");
60 return;
61 }
62
63 OverrunFlag = true;
64
65 /* Save FPU context here (if necessary) */
66 /* Re-enable timer or interrupt here */
67 /* Set model inputs here */
68
69 /* Step the model */
70 SMO_arctan_PLL_step(rtM, rtU_Ialfabeta, rtU_Ualfabeta, &rtY_theta, &rtY_we);
71
72 /* Get model outputs here */
73
74 /* Indicate task complete */
75 OverrunFlag = false;
76
77 /* Disable interrupts here */
78 /* Restore FPU context here (if necessary) */
79 /* Enable interrupts here */
80}
81
82/*
83 * The example "main" function illustrates what is required by your
84 * application code to initialize, execute, and terminate the generated code.
85 * Attaching rt_OneStep to a real-time clock is target specific. This example
86 * illustrates how you do this relative to initializing the model.
87 */
88int_T main(int_T argc, const char *argv[])
89{
90 RT_MODEL *const rtM = rtMPtr;
91
92 /* Unused arguments */
93 (void)(argc);
94 (void)(argv);
95
96 /* Pack model data into RTM */
97 rtM->dwork = &rtDW;
98
99 /* Initialize model */
100 SMO_arctan_PLL_initialize(rtM);
101
102 /* Attach rt_OneStep to a timer or interrupt service routine with
103 * period 6.0E-5 seconds (the model's base sample time) here. The
104 * call syntax for rt_OneStep is
105 *
106 * rt_OneStep(rtM);
107 */
108 printf("Warning: The simulation will run forever. "
109 "Generated ERT main won't simulate model step behavior. "
110 "To change this behavior select the 'MAT-file logging' option.\n");
111 fflush((NULL));
112 while (rtmGetErrorStatus(rtM) == (NULL)) {
113 /* Perform other application tasks here */
114 }
115
116 /* Disable rt_OneStep() here */
117 return 0;
118}
119
120/*
121 * File trailer for generated code.
122 *
123 * [EOF]
124 */
125