/*
 * File: TouchBoardXY_handle_4ms.c
 *
 * Code generated for Simulink model 'P417_SWTR_App'.
 *
 * Model version                  : 1.165
 * Simulink Coder version         : 8.13 (R2017b) 24-Jul-2017
 * C/C++ source code generated on : Sun Jun 25 21:59:14 2023
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "TouchBoardXY_handle_4ms.h"

/* Include model header file for global data */
#include "P417_SWTR_App.h"
#include "P417_SWTR_App_private.h"

/* System initialize for function-call system: '<S2>/TouchBoardXY_handle_4ms' */
void P4_TouchBoardXY_handle_4ms_Init(B_TouchBoardXY_handle_4ms_P41_T *localB)
{
  /* SystemInitialize for Chart: '<S15>/Slect_Touch' */
  localB->Sts_Control = 0U;
}

/* Output and update for function-call system: '<S2>/TouchBoardXY_handle_4ms' */
void P417_SW_TouchBoardXY_handle_4ms(uint8_T rtu_TouchBoard_XY_Sts_input,
  uint8_T rtu_Voice_Sts_Select, uint8_T rtu_Vol_Sts_Select, uint8_T
  rtu_Menu_Sts_Select, uint8_T rtu_XY_Touch_And_Below_1N, uint8_T
  *rty_TouchBoard_XY_Sts_after_han, uint8_T *rty_XY_Touch_And_Below_1N_af_hd,
  B_TouchBoardXY_handle_4ms_P41_T *localB, DW_TouchBoardXY_handle_4ms_P4_T
  *localDW)
{
  uint8_T rtb_Compare_oa;
  uint8_T rtb_Compare_eb;
  uint8_T rtb_Compare_ll;

  /* RelationalOperator: '<S36>/Compare' incorporates:
   *  Constant: '<S36>/Constant'
   */
  rtb_Compare_oa = (uint8_T)(rtu_Voice_Sts_Select > 0);

  /* RelationalOperator: '<S37>/Compare' incorporates:
   *  Constant: '<S37>/Constant'
   */
  rtb_Compare_eb = (uint8_T)(rtu_Vol_Sts_Select > 0);

  /* RelationalOperator: '<S38>/Compare' incorporates:
   *  Constant: '<S38>/Constant'
   */
  rtb_Compare_ll = (uint8_T)(rtu_Menu_Sts_Select > 0);

  /* Chart: '<S15>/Slect_Touch' incorporates:
   *  Constant: '<S35>/Constant'
   *  RelationalOperator: '<S35>/Compare'
   */
  /*  Die2_A_Position_Judgement */
  if ((rtb_Compare_oa == 0) && (rtb_Compare_eb == 0) && (rtb_Compare_ll == 0) &&
      (rtu_TouchBoard_XY_Sts_input > 0)) {
    localB->Sts_Control = 1U;
  } else if ((rtb_Compare_oa == 1) && (rtb_Compare_eb == 0) && (rtb_Compare_ll ==
              0)) {
    localB->Sts_Control = 2U;
  } else if ((rtb_Compare_oa == 0) && (rtb_Compare_eb == 1) && (rtb_Compare_ll ==
              0)) {
    localB->Sts_Control = 3U;
  } else {
    if ((rtb_Compare_oa == 0) && (rtb_Compare_eb == 0) && (rtb_Compare_ll == 1))
    {
      localB->Sts_Control = 4U;
    }
  }

  /* End of Chart: '<S15>/Slect_Touch' */

  /* MultiPortSwitch: '<S15>/Multiport Switch' incorporates:
   *  Constant: '<S15>/Constant'
   *  UnitDelay: '<S15>/Unit Delay'
   */
  switch (localB->Sts_Control) {
   case 1:
    *rty_TouchBoard_XY_Sts_after_han = rtu_TouchBoard_XY_Sts_input;
    break;

   case 2:
    *rty_TouchBoard_XY_Sts_after_han = rtu_Voice_Sts_Select;
    break;

   case 3:
    *rty_TouchBoard_XY_Sts_after_han = rtu_Vol_Sts_Select;
    break;

   case 4:
    *rty_TouchBoard_XY_Sts_after_han = rtu_Menu_Sts_Select;
    break;

   case 5:
    *rty_TouchBoard_XY_Sts_after_han = 0U;
    break;

   default:
    *rty_TouchBoard_XY_Sts_after_han = localDW->UnitDelay_DSTATE;
    break;
  }

  /* End of MultiPortSwitch: '<S15>/Multiport Switch' */

  /* Inport: '<S15>/XY_Touch_And_Below_1N' */
  *rty_XY_Touch_And_Below_1N_af_hd = rtu_XY_Touch_And_Below_1N;

  /* Update for UnitDelay: '<S15>/Unit Delay' */
  localDW->UnitDelay_DSTATE = *rty_TouchBoard_XY_Sts_after_han;
}

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