1 | /* |
2 | * File: ert_main.c |
3 | * |
4 | * Code generated for Simulink model 'rtwdemo_pmsmfoc'. |
5 | * |
6 | * Model version : 1.2949 |
7 | * Simulink Coder version : 8.7 (R2014b) 11-Aug-2014 |
8 | * C/C++ source code generated on : Sat Oct 11 02:05:41 2014 |
9 | * |
10 | * Target selection: ert.tlc |
11 | * Embedded hardware selection: ARM Compatible->ARM Cortex |
12 | * Code generation objective: Execution efficiency |
13 | * Validation result: Not run |
14 | */ |
15 | |
16 | #include "rtwdemo_pmsmfoc.h" |
17 | #include "rtwtypes.h" |
18 | |
19 | volatile int IsrOverrun = 0; |
20 | static boolean_T OverrunFlag = 0; |
21 | void rt_OneStep(void) |
22 | { |
23 | /* '<Root>/motor_on' */ |
24 | static uint16_T motor_on = 0U; |
25 | |
26 | /* '<Root>/command_type' */ |
27 | static EnumCommandType command_type = Torque; |
28 | |
29 | /* '<Root>/command_value' */ |
30 | static real32_T current_request = 0.0F; |
31 | |
32 | /* '<Root>/sensors' */ |
33 | static SENSORS_STRUCT sensors = { |
34 | { |
35 | 0U, 0U } |
36 | , /* adc_phase_currents */ |
37 | 0U, /* encoder_valid */ |
38 | 0U /* encoder_counter */ |
39 | } ; |
40 | |
41 | /* '<Root>/error' */ |
42 | static EnumErrorType error; |
43 | |
44 | /* '<Root>/pwm_compare' */ |
45 | static uint16_T pwm_compare[3]; |
46 | |
47 | /* Check for overrun. Protect OverrunFlag against preemption */ |
48 | if (OverrunFlag++) { |
49 | IsrOverrun = 1; |
50 | OverrunFlag--; |
51 | return; |
52 | } |
53 | |
54 | __enable_irq(); |
55 | error = Controller(motor_on, command_type, current_request, &sensors, |
56 | pwm_compare); |
57 | |
58 | /* Get model outputs here */ |
59 | __disable_irq(); |
60 | OverrunFlag--; |
61 | } |
62 | |
63 | int main(void) |
64 | { |
65 | volatile boolean_T runModel = 1; |
66 | float modelBaseRate = 4.0E-5; |
67 | float systemClock = 48; |
68 | ((void) 0); |
69 | Controller_Init(); |
70 | ARMCM_SysTick_Config(modelBaseRate); |
71 | runModel = |
72 | ((void*) 0) == (NULL); |
73 | __enable_irq(); |
74 | ; |
75 | while (runModel) { |
76 | runModel = |
77 | ((void*) 0) == (NULL); |
78 | } |
79 | |
80 | /* Disable rt_OneStep() here */ |
81 | #ifdef EXT_MODE |
82 | |
83 | wait_ms(1000); |
84 | |
85 | #endif |
86 | |
87 | (void) systemClock; |
88 | return 0; |
89 | } |
90 | |
91 | /* |
92 | * File trailer for generated code. |
93 | * |
94 | * [EOF] |
95 | */ |
96 |