| 1 | /* |
| 2 | * PMSM_Motor_TL3_mid.h |
| 3 | * |
| 4 | * Code generation for model "PMSM_Motor_TL3_sf". |
| 5 | * |
| 6 | * Model version : 1.825 |
| 7 | * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020 |
| 8 | * C source code generated on : Fri Apr 14 12:51:02 2023 |
| 9 | * |
| 10 | * Target selection: rtwsfcn.tlc |
| 11 | * Note: GRT includes extra infrastructure and instrumentation for prototyping |
| 12 | * Embedded hardware selection: ARM Compatible->ARM Cortex-M |
| 13 | * Emulation hardware selection: |
| 14 | * Differs from embedded hardware (MATLAB Host) |
| 15 | * Code generation objectives: |
| 16 | * 1. Execution efficiency |
| 17 | * 2. RAM efficiency |
| 18 | * Validation result: Not run |
| 19 | * |
| 20 | * SOURCES: PMSM_Motor_TL3_sf.c |
| 21 | */ |
| 22 | |
| 23 | #include "simstruc.h" |
| 24 | #include "PMSM_Motor_TL3_sf.h" |
| 25 | #if defined(MATLAB_MEX_FILE) || defined(RT_MALLOC) |
| 26 | |
| 27 | static int_T RegNumInputPorts(SimStruct *S, int_T nInputPorts) |
| 28 | { |
| 29 | _ssSetNumInputPorts(S,nInputPorts); |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | static int_T RegNumOutputPorts(SimStruct *S, int_T nOutputPorts) |
| 34 | { |
| 35 | _ssSetNumOutputPorts(S,nOutputPorts); |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | static int_T FcnSetErrorStatus(const SimStruct *S, DTypeId arg2) |
| 40 | { |
| 41 | static char msg[256]; |
| 42 | if (strlen(ssGetModelName(S)) < 128) { |
| 43 | sprintf(msg, |
| 44 | "S-function %s does not have a tlc file. It cannot use macros that access regDataType field in simstruct.", |
| 45 | ssGetModelName(S)); |
| 46 | } else { |
| 47 | sprintf(msg, |
| 48 | "A S-function does not have a tlc file. It cannot use macros that access regDataType field in simstruct."); |
| 49 | } |
| 50 | |
| 51 | ssSetErrorStatus(S, msg); |
| 52 | UNUSED_PARAMETER(arg2); |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | static void * FcnSetErrorStatusWithReturnPtr(const SimStruct *S, DTypeId arg2) |
| 57 | { |
| 58 | FcnSetErrorStatus(S,0); |
| 59 | UNUSED_PARAMETER(arg2); |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static int_T FcnSetErrorStatusWithArgPtr(const SimStruct *S, const void* arg2) |
| 64 | { |
| 65 | FcnSetErrorStatus(S,0); |
| 66 | UNUSED_PARAMETER(arg2); |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | #endif |
| 71 | |
| 72 | /* Instance data for model: PMSM_Motor_TL3 */ |
| 73 | void *PMSM_Motor_TL3_malloc(SimStruct *rts) |
| 74 | { |
| 75 | /* Local SimStruct for the generated S-Function */ |
| 76 | LocalS *lS = (LocalS *) malloc(sizeof(LocalS)); |
| 77 | ss_VALIDATE_MEMORY(rts,lS); |
| 78 | (void) memset((char *) lS, 0, |
| 79 | sizeof(LocalS)); |
| 80 | ssSetUserData(rts, lS); |
| 81 | |
| 82 | /* block I/O */ |
| 83 | { |
| 84 | void *b = malloc(sizeof(B_PMSM_Motor_TL3_T)); |
| 85 | ss_VALIDATE_MEMORY(rts,b); |
| 86 | ssSetLocalBlockIO(rts, b); |
| 87 | (void) memset(b, 0, |
| 88 | sizeof(B_PMSM_Motor_TL3_T)); |
| 89 | } |
| 90 | |
| 91 | /* model checksums */ |
| 92 | ssSetChecksumVal(rts, 0, 3090714017U); |
| 93 | ssSetChecksumVal(rts, 1, 3929030705U); |
| 94 | ssSetChecksumVal(rts, 2, 1976178041U); |
| 95 | ssSetChecksumVal(rts, 3, 3610196154U); |
| 96 | return (NULL); |
| 97 | } |
| 98 | |