/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * File: KalibrierungDrucksensor.c
 *
 * Code generated for Simulink model 'KalibrierungDrucksensor'.
 *
 * Model version                  : 1.0
 * Simulink Coder version         : 23.2 (R2023b) 01-Aug-2023
 * C/C++ source code generated on : Thu Nov 21 20:07:46 2024
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Atmel->AVR
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "KalibrierungDrucksensor.h"
#include "rtwtypes.h"
#include "KalibrierungDrucksensor_private.h"

/* Block signals (default storage) */
B_KalibrierungDrucksensor_T KalibrierungDrucksensor_B;

/* Block states (default storage) */
DW_KalibrierungDrucksensor_T KalibrierungDrucksensor_DW;

/* Real-time model */
static RT_MODEL_KalibrierungDrucksen_T KalibrierungDrucksensor_M_;
RT_MODEL_KalibrierungDrucksen_T *const KalibrierungDrucksensor_M =
  &KalibrierungDrucksensor_M_;

/* Model step function */
void KalibrierungDrucksensor_step(void)
{
  /* MATLABSystem: '<Root>/Analog Input' */
  if (KalibrierungDrucksensor_DW.obj.SampleTime !=
      KalibrierungDrucksensor_P.AnalogInput_SampleTime) {
    KalibrierungDrucksensor_DW.obj.SampleTime =
      KalibrierungDrucksensor_P.AnalogInput_SampleTime;
  }

  KalibrierungDrucksensor_DW.obj.AnalogInDriverObj.MW_ANALOGIN_HANDLE =
    MW_AnalogIn_GetHandle(54UL);

  /* MATLABSystem: '<Root>/Analog Input' */
  MW_AnalogInSingle_ReadResult
    (KalibrierungDrucksensor_DW.obj.AnalogInDriverObj.MW_ANALOGIN_HANDLE,
     &KalibrierungDrucksensor_B.AnalogInput, MW_ANALOGIN_UINT16);

  /* Gain: '<Root>/Gain' */
  KalibrierungDrucksensor_B.Gain = (uint32_T)KalibrierungDrucksensor_P.Gain_Gain
    * KalibrierungDrucksensor_B.AnalogInput;

  {                                    /* Sample time: [0.2s, 0.0s] */
  }

  /* Update absolute time for base rate */
  /* The "clockTick0" counts the number of times the code of this task has
   * been executed. The absolute time is the multiplication of "clockTick0"
   * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
   * overflow during the application lifespan selected.
   */
  KalibrierungDrucksensor_M->Timing.taskTime0 =
    ((time_T)(++KalibrierungDrucksensor_M->Timing.clockTick0)) *
    KalibrierungDrucksensor_M->Timing.stepSize0;
}

/* Model initialize function */
void KalibrierungDrucksensor_initialize(void)
{
  /* Registration code */
  rtmSetTFinal(KalibrierungDrucksensor_M, -1);
  KalibrierungDrucksensor_M->Timing.stepSize0 = 0.2;

  /* External mode info */
  KalibrierungDrucksensor_M->Sizes.checksums[0] = (85137889U);
  KalibrierungDrucksensor_M->Sizes.checksums[1] = (624812530U);
  KalibrierungDrucksensor_M->Sizes.checksums[2] = (2894822500U);
  KalibrierungDrucksensor_M->Sizes.checksums[3] = (2678819211U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[2];
    KalibrierungDrucksensor_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    systemRan[1] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(KalibrierungDrucksensor_M->extModeInfo,
      &KalibrierungDrucksensor_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(KalibrierungDrucksensor_M->extModeInfo,
                        KalibrierungDrucksensor_M->Sizes.checksums);
    rteiSetTPtr(KalibrierungDrucksensor_M->extModeInfo, rtmGetTPtr
                (KalibrierungDrucksensor_M));
  }

  /* Start for MATLABSystem: '<Root>/Analog Input' */
  KalibrierungDrucksensor_DW.obj.matlabCodegenIsDeleted = false;
  KalibrierungDrucksensor_DW.obj.SampleTime =
    KalibrierungDrucksensor_P.AnalogInput_SampleTime;
  KalibrierungDrucksensor_DW.obj.isInitialized = 1L;
  KalibrierungDrucksensor_DW.obj.AnalogInDriverObj.MW_ANALOGIN_HANDLE =
    MW_AnalogInSingle_Open(54UL);
  KalibrierungDrucksensor_DW.obj.isSetupComplete = true;
}

/* Model terminate function */
void KalibrierungDrucksensor_terminate(void)
{
  /* Terminate for MATLABSystem: '<Root>/Analog Input' */
  if (!KalibrierungDrucksensor_DW.obj.matlabCodegenIsDeleted) {
    KalibrierungDrucksensor_DW.obj.matlabCodegenIsDeleted = true;
    if ((KalibrierungDrucksensor_DW.obj.isInitialized == 1L) &&
        KalibrierungDrucksensor_DW.obj.isSetupComplete) {
      KalibrierungDrucksensor_DW.obj.AnalogInDriverObj.MW_ANALOGIN_HANDLE =
        MW_AnalogIn_GetHandle(54UL);
      MW_AnalogIn_Close
        (KalibrierungDrucksensor_DW.obj.AnalogInDriverObj.MW_ANALOGIN_HANDLE);
    }
  }

  /* End of Terminate for MATLABSystem: '<Root>/Analog Input' */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
