/*
 * File: mrcanhubk344_can_s32ct.c
 *
 * Code generated for Simulink model 'mrcanhubk344_can_s32ct'.
 *
 * Model version                   : 8.1
 * Simulink Coder version          : 24.2 (R2024b) 21-Jun-2024
 * MBDT for S32K3xx Series Version :  Version 1.4.0 (R2021a-R2023a) 29-May-2023
 * C/C++ source code generated on  : Thu Oct 24 17:39:20 2024
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: ARM Compatible->ARM Cortex
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "mrcanhubk344_can_s32ct.h"
#include "mrcanhubk344_can_s32ct_private.h"
#include "rtwtypes.h"
#include <string.h>

/* Exported data definition */

/* Volatile memory section */
/* Definition for custom storage class: Volatile */
volatile real_T ADC_Received;          /* '<Root>/Data Store Memory20' */
volatile uint16_T Adc1Group0_ResultBuffer;/* '<Root>/Data Store Memory1' */
volatile uint16_T Channel1;            /* '<Root>/Data Store Memory3' */
volatile real_T Data[8];               /* '<Root>/Data Store Memory13' */
volatile real_T Dio_Received;          /* '<Root>/Data Store Memory21' */
volatile real_T Length;                /* '<Root>/Data Store Memory15' */
volatile uint32_T RxCounter0;          /* '<Root>/Data Store Memory19' */
volatile uint32_T RxCounter1;          /* '<Root>/Data Store Memory16' */
volatile uint32_T RxCounter2;          /* '<Root>/Data Store Memory17' */
volatile uint32_T RxCounter3;          /* '<Root>/Data Store Memory18' */
volatile uint8_T SetControllerMode_Status;/* '<Root>/Data Store Memory4' */
volatile uint8_T SetControllerMode_Status1;/* '<Root>/Data Store Memory2' */
volatile uint32_T canHardwareObjectID; /* '<Root>/Data Store Memory11' */
volatile uint32_T controllerId;        /* '<Root>/Data Store Memory9' */
volatile uint32_T ctrlErrOut;          /* '<Root>/Data Store Memory5' */
volatile uint32_T dataErrOut;          /* '<Root>/Data Store Memory7' */
volatile uint32_T idErrOut;            /* '<Root>/Data Store Memory6' */

/* Block signals (default storage) */
B_mrcanhubk344_can_s32ct_T mrcanhubk344_can_s32ct_B;

/* Block states (default storage) */
DW_mrcanhubk344_can_s32ct_T mrcanhubk344_can_s32ct_DW;

/* Real-time model */
static RT_MODEL_mrcanhubk344_can_s32_T mrcanhubk344_can_s32ct_M_;
RT_MODEL_mrcanhubk344_can_s32_T *const mrcanhubk344_can_s32ct_M =
  &mrcanhubk344_can_s32ct_M_;
static void init_freemaster_lpuart(void)
{
  LPUART_Type * const uart_base = Lpuart_apBases[2];
  Lpuart_Uart_Ip_Hw_Init(uart_base);
  LPUART_Uart_SetBaudRate(2, 115200U);

  /* Set 8 bit counts per char */
  Lpuart_Uart_Ip_SetBitCountPerChar(uart_base, LPUART_UART_IP_8_BITS_PER_CHAR,
    FALSE);

  /* Set no parity mode */
  Lpuart_Uart_Ip_SetParityMode(uart_base, LPUART_UART_IP_PARITY_DISABLED);

  /* One stop bit */
  Lpuart_Uart_Ip_SetStopBitCount(uart_base, LPUART_UART_IP_ONE_STOP_BIT);
  sys_disableIsrSource(Lpuart_RxTxIrqId[2]);
  sys_registerIsrHandler(Lpuart_RxTxIrqId[2], (uint32) &FMSTR_SerialIsr);
  sys_enableIsrSource(Lpuart_RxTxIrqId[2], 0U);
}

void CanIf_RxIndication (const Can_HwType* Mailbox, const PduInfoType*
  PduInfoPtr)
{
  uint8_t i, length;
  mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 =
    Mailbox->ControllerId;
  mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o3 = Mailbox->Hoh;
  mrcanhubk344_can_s32ct_B.CANID = Mailbox->CanId;
  length = PduInfoPtr->SduLength;
  if (length > 8) {
    length = 8;
  }

  for (i = 0; i < length; i++) {
    (&mrcanhubk344_can_s32ct_B.CANData[0])[i] = PduInfoPtr->SduDataPtr[i];
  }

  mrcanhubk344_can_s32ct_B.CANLength = PduInfoPtr->SduLength;

  /* Output and update for function-call system: '<Root>/can_out' */
  {
    uint32_T qY;

    /* DataStoreWrite: '<S6>/Data Store Write7' */
    controllerId = mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2;

    /* DataStoreWrite: '<S6>/Data Store Write8' */
    canHardwareObjectID =
      mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o3;

    /* Chart: '<S6>/Chart' incorporates:
     *  BusCreator generated from: '<S6>/Chart'
     */
    if (mrcanhubk344_can_s32ct_DW.is_active_c9_mrcanhubk344_can_s == 0) {
      mrcanhubk344_can_s32ct_DW.is_active_c9_mrcanhubk344_can_s = 1U;
      switch (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o3) {
       case 2U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter0_h + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter0_h + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter0_h) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter0_h = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 0U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 1U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 1) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 3U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter1_d + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter1_d + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter1_d) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter1_d = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 1U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 2U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 2) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 4U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter2_k + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter2_k + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter2_k) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter2_k = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 2U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 3U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 3) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 5U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter3_p + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter3_p + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter3_p) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter3_p = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 3U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 4U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 4) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 6U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter4 + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter4 + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter4) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter4 = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 4U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 5U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 5) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 7U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter5 + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter5 + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter5) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter5 = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 5U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 6U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 6) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;
      }

      mrcanhubk344_can_s32ct_B.errorCounter_out =
        mrcanhubk344_can_s32ct_DW.errorCounter;
      qY = mrcanhubk344_can_s32ct_DW.RxCounter + /*MW:OvSatOk*/ 1U;
      if (mrcanhubk344_can_s32ct_DW.RxCounter + 1U <
          mrcanhubk344_can_s32ct_DW.RxCounter) {
        qY = MAX_uint32_T;
      }

      mrcanhubk344_can_s32ct_DW.RxCounter = qY;
      mrcanhubk344_can_s32ct_B.RxCounter0_out =
        mrcanhubk344_can_s32ct_DW.RxCounter0_h;
      mrcanhubk344_can_s32ct_B.RxCounter1_out =
        mrcanhubk344_can_s32ct_DW.RxCounter1_d;
      mrcanhubk344_can_s32ct_B.RxCounter2_out =
        mrcanhubk344_can_s32ct_DW.RxCounter2_k;
      mrcanhubk344_can_s32ct_B.RxCounter3_out =
        mrcanhubk344_can_s32ct_DW.RxCounter3_p;
    } else {
      switch (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o3) {
       case 2U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter0_h + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter0_h + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter0_h) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter0_h = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 0U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 1U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 1) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 3U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter1_d + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter1_d + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter1_d) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter1_d = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 1U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 2U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 2) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 4U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter2_k + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter2_k + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter2_k) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter2_k = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 2U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 3U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 3) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 5U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter3_p + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter3_p + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter3_p) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter3_p = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 3U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 4U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 4) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 6U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter4 + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter4 + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter4) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter4 = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 4U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 5U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 5) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;

       case 7U:
        qY = mrcanhubk344_can_s32ct_DW.RxCounter5 + /*MW:OvSatOk*/ 1U;
        if (mrcanhubk344_can_s32ct_DW.RxCounter5 + 1U <
            mrcanhubk344_can_s32ct_DW.RxCounter5) {
          qY = MAX_uint32_T;
        }

        mrcanhubk344_can_s32ct_DW.RxCounter5 = qY;
        if (mrcanhubk344_can_s32ct_B.Hardware_Interrupt_Handler6_o2 != 5U) {
          qY = mrcanhubk344_can_s32ct_DW.errorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_DW.errorCounter + 1U <
              mrcanhubk344_can_s32ct_DW.errorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_DW.errorCounter = qY;
        }

        if ((mrcanhubk344_can_s32ct_B.CANID & 255U) != 6U) {
          qY = mrcanhubk344_can_s32ct_B.idErrorCounter + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.idErrorCounter + 1U <
              mrcanhubk344_can_s32ct_B.idErrorCounter) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.idErrorCounter = qY;
        }

        if (mrcanhubk344_can_s32ct_B.CANData[0] != 6) {
          qY = mrcanhubk344_can_s32ct_B.dataError + /*MW:OvSatOk*/ 1U;
          if (mrcanhubk344_can_s32ct_B.dataError + 1U <
              mrcanhubk344_can_s32ct_B.dataError) {
            qY = MAX_uint32_T;
          }

          mrcanhubk344_can_s32ct_B.dataError = qY;
        }
        break;
      }

      mrcanhubk344_can_s32ct_B.errorCounter_out =
        mrcanhubk344_can_s32ct_DW.errorCounter;
      qY = mrcanhubk344_can_s32ct_DW.RxCounter + /*MW:OvSatOk*/ 1U;
      if (mrcanhubk344_can_s32ct_DW.RxCounter + 1U <
          mrcanhubk344_can_s32ct_DW.RxCounter) {
        qY = MAX_uint32_T;
      }

      mrcanhubk344_can_s32ct_DW.RxCounter = qY;
      mrcanhubk344_can_s32ct_B.RxCounter0_out =
        mrcanhubk344_can_s32ct_DW.RxCounter0_h;
      mrcanhubk344_can_s32ct_B.RxCounter1_out =
        mrcanhubk344_can_s32ct_DW.RxCounter1_d;
      mrcanhubk344_can_s32ct_B.RxCounter2_out =
        mrcanhubk344_can_s32ct_DW.RxCounter2_k;
      mrcanhubk344_can_s32ct_B.RxCounter3_out =
        mrcanhubk344_can_s32ct_DW.RxCounter3_p;
    }

    /* End of Chart: '<S6>/Chart' */
  }
}

/* Model step function */
void mrcanhubk344_can_s32ct_step(void)
{
  /* S-Function (s32k3_adc): '<Root>/Adc_StartGroupConversion_1' */
  Adc_StartGroupConversion(Adc1Group_0);

  /* End of Outputs for S-Function (s32k3_isr_handler): '<S1>/Hardware_Interrupt_Handler6' */

  /* DataStoreWrite: '<S5>/Data Store Write2' */
  RxCounter0 = mrcanhubk344_can_s32ct_B.RxCounter0_out;

  /* DataStoreWrite: '<S5>/Data Store Write3' */
  RxCounter1 = mrcanhubk344_can_s32ct_B.RxCounter1_out;

  /* DataStoreWrite: '<S5>/Data Store Write5' */
  RxCounter2 = mrcanhubk344_can_s32ct_B.RxCounter2_out;

  /* DataStoreWrite: '<S5>/Data Store Write6' */
  RxCounter3 = mrcanhubk344_can_s32ct_B.RxCounter3_out;

  /* DataStoreWrite: '<S5>/Data Store Write' */
  ctrlErrOut = mrcanhubk344_can_s32ct_B.errorCounter_out;

  /* DataStoreWrite: '<S5>/Data Store Write1' */
  idErrOut = mrcanhubk344_can_s32ct_B.idErrorCounter;

  /* DataStoreWrite: '<S5>/Data Store Write4' */
  dataErrOut = mrcanhubk344_can_s32ct_B.dataError;
}

/* Model initialize function */
void mrcanhubk344_can_s32ct_initialize(void)
{
  /* Start for DataStoreMemory: '<Root>/Data Store Memory1' */
  Adc1Group0_ResultBuffer =
    mrcanhubk344_can_s32ct_P.DataStoreMemory1_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory13' */
  memcpy((real_T *)&Data[0],
         &mrcanhubk344_can_s32ct_P.DataStoreMemory13_InitialValue[0], sizeof
         (real_T) << 3U);

  /* Start for DataStoreMemory: '<Root>/Data Store Memory15' */
  Length = mrcanhubk344_can_s32ct_P.DataStoreMemory15_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory20' */
  ADC_Received = mrcanhubk344_can_s32ct_P.DataStoreMemory20_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory21' */
  Dio_Received = mrcanhubk344_can_s32ct_P.DataStoreMemory21_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory3' */
  Channel1 = mrcanhubk344_can_s32ct_P.DataStoreMemory3_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory11' */
  canHardwareObjectID = mrcanhubk344_can_s32ct_P.DataStoreMemory11_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory16' */
  RxCounter1 = mrcanhubk344_can_s32ct_P.DataStoreMemory16_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory17' */
  RxCounter2 = mrcanhubk344_can_s32ct_P.DataStoreMemory17_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory18' */
  RxCounter3 = mrcanhubk344_can_s32ct_P.DataStoreMemory18_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory19' */
  RxCounter0 = mrcanhubk344_can_s32ct_P.DataStoreMemory19_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory5' */
  ctrlErrOut = mrcanhubk344_can_s32ct_P.DataStoreMemory5_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory6' */
  idErrOut = mrcanhubk344_can_s32ct_P.DataStoreMemory6_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory7' */
  dataErrOut = mrcanhubk344_can_s32ct_P.DataStoreMemory7_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory9' */
  controllerId = mrcanhubk344_can_s32ct_P.DataStoreMemory9_InitialValue;

  /* Start for S-Function (s32k3_fm_config): '<Root>/FreeMASTER Config' */
  init_freemaster_lpuart();
  FMSTR_Init();

  /* Start for DataStoreMemory: '<Root>/Data Store Memory2' */
  SetControllerMode_Status1 =
    mrcanhubk344_can_s32ct_P.DataStoreMemory2_InitialValue;

  /* Start for DataStoreMemory: '<Root>/Data Store Memory4' */
  SetControllerMode_Status =
    mrcanhubk344_can_s32ct_P.DataStoreMemory4_InitialValue;

  /* Outputs for Atomic SubSystem: '<Root>/Initialize Function' */
  /* S-Function (s32k3_can): '<S2>/Can_SetControllerMode1' */
  mrcanhubk344_can_s32ct_B.Can_SetControllerMode1 =
    Can_43_FLEXCAN_SetControllerMode(CanController_1, CAN_CS_STARTED);

  /* DataStoreWrite: '<S2>/Data Store Write7' */
  SetControllerMode_Status1 = mrcanhubk344_can_s32ct_B.Can_SetControllerMode1;

  /* S-Function (s32k3_can): '<S2>/Can_SetControllerMode2' */
  mrcanhubk344_can_s32ct_B.Can_SetControllerMode2 =
    Can_43_FLEXCAN_SetControllerMode(CanController_0, CAN_CS_STARTED);

  /* DataStoreWrite: '<S2>/Data Store Write12' */
  SetControllerMode_Status = mrcanhubk344_can_s32ct_B.Can_SetControllerMode2;

  /* S-Function (s32k3_can): '<S2>/Can_SetControllerMode3' */
  mrcanhubk344_can_s32ct_B.Can_SetControllerMode3 =
    Can_43_FLEXCAN_SetControllerMode(CanController_2, CAN_CS_STARTED);

  /* S-Function (s32k3_can): '<S2>/Can_SetControllerMode4' */
  mrcanhubk344_can_s32ct_B.Can_SetControllerMode4 =
    Can_43_FLEXCAN_SetControllerMode(CanController_3, CAN_CS_STARTED);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel2' incorporates:
   *  Constant: '<S2>/Constant'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_0_EN,
                   mrcanhubk344_can_s32ct_P.Constant_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel3' incorporates:
   *  Constant: '<S2>/Constant'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_0_STB,
                   mrcanhubk344_can_s32ct_P.Constant_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel1' incorporates:
   *  Constant: '<S2>/Constant1'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_1_EN,
                   mrcanhubk344_can_s32ct_P.Constant1_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel4' incorporates:
   *  Constant: '<S2>/Constant1'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_1_STB,
                   mrcanhubk344_can_s32ct_P.Constant1_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel10' incorporates:
   *  Constant: '<S2>/Constant5'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_2_STB,
                   mrcanhubk344_can_s32ct_P.Constant5_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel9' incorporates:
   *  Constant: '<S2>/Constant5'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_2_EN,
                   mrcanhubk344_can_s32ct_P.Constant5_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel11' incorporates:
   *  Constant: '<S2>/Constant6'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_3_STB,
                   mrcanhubk344_can_s32ct_P.Constant6_Value);

  /* S-Function (s32k3_dio): '<S2>/Dio_WriteChannel12' incorporates:
   *  Constant: '<S2>/Constant6'
   */
  Dio_WriteChannel(DioConf_DioChannel_CanController_3_EN,
                   mrcanhubk344_can_s32ct_P.Constant6_Value);

  /* End of Outputs for SubSystem: '<Root>/Initialize Function' */
}

/* Model terminate function */
void mrcanhubk344_can_s32ct_terminate(void)
{
  /* (no terminate code required) */
}

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