/*
 * PMSM_Motor_TL3_sf.h
 *
 * Code generation for model "PMSM_Motor_TL3_sf".
 *
 * Model version              : 1.825
 * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
 * C source code generated on : Fri Apr 14 12:51:02 2023
 *
 * Target selection: rtwsfcn.tlc
 * Note: GRT includes extra infrastructure and instrumentation for prototyping
 * Embedded hardware selection: ARM Compatible->ARM Cortex-M
 * Emulation hardware selection:
 *    Differs from embedded hardware (MATLAB Host)
 * Code generation objectives:
 *    1. Execution efficiency
 *    2. RAM efficiency
 * Validation result: Not run
 */

#ifndef RTW_HEADER_PMSM_Motor_TL3_sf_h_
#define RTW_HEADER_PMSM_Motor_TL3_sf_h_
#include <math.h>
#include <string.h>
#include <stddef.h>
#ifndef PMSM_Motor_TL3_sf_COMMON_INCLUDES_
#define PMSM_Motor_TL3_sf_COMMON_INCLUDES_
#include <stdlib.h>
#define S_FUNCTION_NAME                PMSM_Motor_TL3_sf
#define S_FUNCTION_LEVEL               2
#define RTW_GENERATED_S_FUNCTION
#include "rtwtypes.h"
#include "simstruc.h"
#include "fixedpoint.h"
#if !defined(MATLAB_MEX_FILE)
#include "rt_matrx.h"
#endif

#if !defined(RTW_SFUNCTION_DEFINES)
#define RTW_SFUNCTION_DEFINES

typedef struct {
  void *blockIO;
  void *defaultParam;
  void *nonContDerivSig;
} LocalS;

#define ssSetLocalBlockIO(S, io)       ((LocalS *)ssGetUserData(S))->blockIO = ((void *)(io))
#define ssGetLocalBlockIO(S)           ((LocalS *)ssGetUserData(S))->blockIO
#define ssSetLocalDefaultParam(S, paramVector) ((LocalS *)ssGetUserData(S))->defaultParam = (paramVector)
#define ssGetLocalDefaultParam(S)      ((LocalS *)ssGetUserData(S))->defaultParam
#define ssSetLocalNonContDerivSig(S, pSig) ((LocalS *)ssGetUserData(S))->nonContDerivSig = (pSig)
#define ssGetLocalNonContDerivSig(S)   ((LocalS *)ssGetUserData(S))->nonContDerivSig
#endif
#endif                                 /* PMSM_Motor_TL3_sf_COMMON_INCLUDES_ */

#include "PMSM_Motor_TL3_sf_types.h"

/* Shared type includes */
#include "multiword_types.h"
#include "rtGetNaN.h"
#include "rt_nonfinite.h"
#include "rt_defines.h"
#include "rtGetInf.h"

/* Block signals (default storage) */
typedef struct {
  real_T Fcn;                          /* '<S15>/Fcn' */
  real_T Fcn1;                         /* '<S15>/Fcn1' */
  real_T StateSpace_o1[9];             /* '<S20>/State-Space' */
  real_T StateSpace_o2[6];             /* '<S20>/State-Space' */
  real_T Gain;                         /* '<S11>/Gain' */
  real_T Sum1;                         /* '<S18>/Sum1' */
  real_T Sum;                          /* '<S17>/Sum' */
  real_T Add1;                         /* '<S4>/Add1' */
} B_PMSM_Motor_TL3_T;

/* Constant parameters (default storage) */
typedef struct {
  /* Expression: zeros(1,Switches)
   * Referenced by: '<S19>/Constant'
   */
  real_T Constant_Value[6];

  /* Expression: S.D
   * Referenced by: '<S20>/State-Space'
   */
  real_T StateSpace_DS_param[81];
} ConstP_PMSM_Motor_TL3_T;

/* External inputs (root inport signals with default storage) */
typedef struct {
  real_T *PWM[6];                      /* '<Root>/PWM' */
  real_T *TL;                          /* '<Root>/TL' */
  real_T *DC;                          /* '<Root>/DC' */
} ExternalUPtrs_PMSM_Motor_TL3_T;

/* External outputs (root outports fed by signals with default storage) */
typedef struct {
  real_T *Statorcurrentis_aA;          /* '<Root>/Stator current is_a (A)' */
  real_T *Statorcurrentis_bA;          /* '<Root>/Stator current is_b (A)' */
  real_T *Statorcurrentis_cA;          /* '<Root>/Stator current is_c (A)' */
  real_T *Statorcurrentis_qA;          /* '<Root>/Stator current is_q (A)' */
  real_T *Statorcurrentis_dA;          /* '<Root>/Stator current is_d (A)' */
  real_T *StatorvoltageVs_qV;          /* '<Root>/Stator voltage Vs_q (V)' */
  real_T *StatorvoltageVs_dV;          /* '<Root>/Stator voltage Vs_d (V)' */
  real_T *Halleffectsignalh_a;         /* '<Root>/Hall effect signal h_a' */
  real_T *Halleffectsignalh_b;         /* '<Root>/Hall effect signal h_b' */
  real_T *Halleffectsignalh_c;         /* '<Root>/Hall effect signal h_c' */
  real_T *Rotorspeedwmrads;            /* '<Root>/Rotor speed wm (rad//s)' */
  real_T *Rotoranglethetamrad;         /* '<Root>/Rotor angle thetam (rad)' */
  real_T *ElectromagnetictorqueTeNm;
                                  /* '<Root>/Electromagnetic torque Te (N*m)' */
} ExtY_PMSM_Motor_TL3_T;

/* Constant parameters (default storage) */
extern const ConstP_PMSM_Motor_TL3_T PMSM_Motor_TL3_ConstP;

/*-
 * These blocks were eliminated from the model due to optimizations:
 *
 * Block '<S4>/Data Type Duplicate' : Unused code path elimination
 * Block '<S3>/do not delete this gain' : Eliminated nontunable gain of 1
 * Block '<S1>/Data Type Conversion' : Eliminate redundant data type conversion
 * Block '<S17>/Lq//Ld' : Eliminated nontunable gain of 1
 * Block '<S18>/Ld//Lq' : Eliminated nontunable gain of 1
 * Block '<S19>/Data Type Conversion' : Eliminate redundant data type conversion
 */

/*-
 * The generated code includes comments that allow you to trace directly
 * back to the appropriate location in the model.  The basic format
 * is <system>/block_name, where system is the system number (uniquely
 * assigned by Simulink) and block_name is the name of the block.
 *
 * Note that this particular code originates from a subsystem build,
 * and has its own system numbers different from the parent model.
 * Refer to the system hierarchy for this subsystem below, and use the
 * MATLAB hilite_system command to trace the generated code back
 * to the parent model.  For example,
 *
 * hilite_system('FOC_ADRC/PMSM_Motor_TL3')    - opens subsystem FOC_ADRC/PMSM_Motor_TL3
 * hilite_system('FOC_ADRC/PMSM_Motor_TL3/Kp') - opens and selects block Kp
 *
 * Here is the system hierarchy for this model
 *
 * '<Root>' : 'FOC_ADRC'
 * '<S1>'   : 'FOC_ADRC/PMSM_Motor_TL3'
 * '<S2>'   : 'FOC_ADRC/PMSM_Motor_TL3/Controlled Voltage Source1'
 * '<S3>'   : 'FOC_ADRC/PMSM_Motor_TL3/Current Measurement'
 * '<S4>'   : 'FOC_ADRC/PMSM_Motor_TL3/IIR Filter1'
 * '<S5>'   : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1'
 * '<S6>'   : 'FOC_ADRC/PMSM_Motor_TL3/Universal Bridge1'
 * '<S7>'   : 'FOC_ADRC/PMSM_Motor_TL3/powergui'
 * '<S8>'   : 'FOC_ADRC/PMSM_Motor_TL3/Current Measurement/Model'
 * '<S9>'   : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model'
 * '<S10>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Measurements'
 * '<S11>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Mechanical model'
 * '<S12>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/Hall effect sensor'
 * '<S13>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/abc2qd'
 * '<S14>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/iq,id'
 * '<S15>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/qd2abc'
 * '<S16>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/Hall effect sensor/Angle converter'
 * '<S17>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/iq,id/id'
 * '<S18>'  : 'FOC_ADRC/PMSM_Motor_TL3/Permanent Magnet Synchronous Machine1/Electrical model/iq,id/iq'
 * '<S19>'  : 'FOC_ADRC/PMSM_Motor_TL3/Universal Bridge1/Model'
 * '<S20>'  : 'FOC_ADRC/PMSM_Motor_TL3/powergui/EquivalentModel1'
 * '<S21>'  : 'FOC_ADRC/PMSM_Motor_TL3/powergui/EquivalentModel1/Gates'
 * '<S22>'  : 'FOC_ADRC/PMSM_Motor_TL3/powergui/EquivalentModel1/Sources'
 * '<S23>'  : 'FOC_ADRC/PMSM_Motor_TL3/powergui/EquivalentModel1/Status'
 * '<S24>'  : 'FOC_ADRC/PMSM_Motor_TL3/powergui/EquivalentModel1/Yout'
 */
#endif                                 /* RTW_HEADER_PMSM_Motor_TL3_sf_h_ */
