task_1s ()
{
  uint16_t din2;
  uint16_t din1;
  uint16_t adc_mV;

  <bb 2> :
  # DEBUG BEGIN_STMT
  CAN_Task_1000ms ();
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = gb.led_flag;
  _2 = _1 == 0;
  _3 = (int) _2;
  led_onoff (_3);
  return;

}


task_200ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  CAN_Task_200ms ();
  # DEBUG BEGIN_STMT
  PWM_for_dirve_mode ();
  return;

}


task_100ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  test_pwm.1_1 = test_pwm;
  if (test_pwm.1_1 <= 99)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  test_pwm.2_2 = test_pwm;
  test_pwm.3_3 = test_pwm.2_2;
  _4 = test_pwm.3_3 + 1;
  test_pwm = _4;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  test_pwm = 0;

  <bb 5> :
  # DEBUG BEGIN_STMT
  C_100ms.4_5 = C_100ms;
  _6 = C_100ms.4_5 + 1;
  C_100ms = _6;
  # DEBUG BEGIN_STMT
  CAN_Task_100ms ();
  return;

}


task_50ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  return;

}


task_20ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  CAN_Task_20ms ();
  return;

}


task_10ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  CAN_Task_10ms ();
  return;

}


task_5ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  CAN_Task_5ms ();
  return;

}


task_2ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  ECU3_KATECH_Logic_2ms ();
  return;

}


task_1ms ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  return;

}


task_500us ()
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  can_tx_check ();
  # DEBUG BEGIN_STMT
  can_main_ECU3 ();
  return;

}


main ()
{
  u64 tick_200ms;
  u64 tick_5ms;
  u64 tick_500us;
  u64 tick_1ms;
  u64 tick_1sec;
  u64 tick_2ms;
  u64 tick_50ms;
  u64 tick_20ms;
  u64 tick_10ms;
  u64 tick_100ms;
  char ch;
  int port;
  int i;
  int retry;
  StatusType status;
  int D.13773;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  Gvar_init ();
  # DEBUG BEGIN_STMT
  Clock_Ip_Init (&Mcu_aClockConfigPB[0]);
  # DEBUG BEGIN_STMT
  Siul2_Port_Ip_Init (78, &g_pin_mux_InitConfigArr0);
  # DEBUG BEGIN_STMT
  IntCtrl_Ip_Init (&IntCtrlConfig_0);
  # DEBUG BEGIN_STMT
  IntCtrl_Ip_ConfigIrqRouting (&intRouteConfig);
  # DEBUG BEGIN_STMT
  Uart_Init ();
  # DEBUG BEGIN_STMT
  _1 = gb.pwm_max_tick;
  pwm_init (_1);
  # DEBUG BEGIN_STMT
  Adc_Init ();
  # DEBUG BEGIN_STMT
  i2c1_init ();
  # DEBUG BEGIN_STMT
  i2c0_init ();
  # DEBUG BEGIN_STMT
  SPI_init ();
  # DEBUG BEGIN_STMT
  Pit_Ip_Init (0, &PIT_0_InitConfig_PB);
  # DEBUG BEGIN_STMT
  Pit_Ip_InitChannel (0, &PIT_0_ChannelConfig_PB[0]);
  # DEBUG BEGIN_STMT
  Pit_Ip_EnableChannelInterrupt (0, 0);
  # DEBUG BEGIN_STMT
  Pit_Ip_StartChannel (0, 0, 20000);
  # DEBUG BEGIN_STMT
  ch = 0;
  goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _2 = (int) ch;
  Can_Init_ECU3 (_2);
  # DEBUG BEGIN_STMT
  ch.0_3 = ch;
  ch = ch.0_3 + 1;

  <bb 4> :
  # DEBUG BEGIN_STMT
  if (ch <= 5)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  board_init ();
  # DEBUG BEGIN_STMT
  tick_500us = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_1ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_2ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_5ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_10ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_20ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_50ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_100ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_200ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tick_1sec = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  tmr_delay (1000);
  # DEBUG BEGIN_STMT
  WATCHDOG_HAL_Init ();
  # DEBUG BEGIN_STMT
  debug_printf ("Board Init Finished\n\r");
  # DEBUG BEGIN_STMT
  ECU3_KATECH_Logic_init ();

  <bb 6> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _4 = gb.tmr_cnt;
  _5 = tick_1sec + 1000;
  if (_4 >= _5)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  tick_1sec = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_1s ();

  <bb 8> :
  # DEBUG BEGIN_STMT
  _6 = gb.tmr_cnt;
  _7 = tick_200ms + 200;
  if (_6 >= _7)
    goto <bb 9>; [INV]
  else
    goto <bb 10>; [INV]

  <bb 9> :
  # DEBUG BEGIN_STMT
  tick_200ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_200ms ();

  <bb 10> :
  # DEBUG BEGIN_STMT
  _8 = gb.tmr_cnt;
  _9 = tick_100ms + 100;
  if (_8 >= _9)
    goto <bb 11>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 11> :
  # DEBUG BEGIN_STMT
  tick_100ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_100ms ();

  <bb 12> :
  # DEBUG BEGIN_STMT
  _10 = gb.tmr_cnt;
  _11 = tick_50ms + 50;
  if (_10 >= _11)
    goto <bb 13>; [INV]
  else
    goto <bb 14>; [INV]

  <bb 13> :
  # DEBUG BEGIN_STMT
  tick_50ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_50ms ();

  <bb 14> :
  # DEBUG BEGIN_STMT
  _12 = gb.tmr_cnt;
  _13 = tick_20ms + 20;
  if (_12 >= _13)
    goto <bb 15>; [INV]
  else
    goto <bb 16>; [INV]

  <bb 15> :
  # DEBUG BEGIN_STMT
  tick_20ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_20ms ();

  <bb 16> :
  # DEBUG BEGIN_STMT
  _14 = gb.tmr_cnt;
  _15 = tick_10ms + 10;
  if (_14 >= _15)
    goto <bb 17>; [INV]
  else
    goto <bb 18>; [INV]

  <bb 17> :
  # DEBUG BEGIN_STMT
  tick_10ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_10ms ();

  <bb 18> :
  # DEBUG BEGIN_STMT
  _16 = gb.tmr_cnt;
  _17 = tick_5ms + 5;
  if (_16 >= _17)
    goto <bb 19>; [INV]
  else
    goto <bb 20>; [INV]

  <bb 19> :
  # DEBUG BEGIN_STMT
  tick_5ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_5ms ();

  <bb 20> :
  # DEBUG BEGIN_STMT
  _18 = gb.tmr_cnt;
  _19 = tick_2ms + 2;
  if (_18 >= _19)
    goto <bb 21>; [INV]
  else
    goto <bb 22>; [INV]

  <bb 21> :
  # DEBUG BEGIN_STMT
  tick_2ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_2ms ();

  <bb 22> :
  # DEBUG BEGIN_STMT
  _20 = gb.tmr_cnt;
  _21 = tick_1ms + 1;
  if (_20 >= _21)
    goto <bb 23>; [INV]
  else
    goto <bb 24>; [INV]

  <bb 23> :
  # DEBUG BEGIN_STMT
  tick_1ms = gb.tmr_cnt;
  # DEBUG BEGIN_STMT
  task_1ms ();

  <bb 24> :
  # DEBUG BEGIN_STMT
  _22 = gb.x500us;
  _23 = tick_500us + 1;
  if (_22 >= _23)
    goto <bb 25>; [INV]
  else
    goto <bb 26>; [INV]

  <bb 25> :
  # DEBUG BEGIN_STMT
  tick_500us = gb.x500us;
  # DEBUG BEGIN_STMT
  task_500us ();

  <bb 26> :
  # DEBUG BEGIN_STMT
  WATCHDOG_HAL_Fed ();
  # DEBUG BEGIN_STMT
  uds_wait ();
  # DEBUG BEGIN_STMT
  goto <bb 6>; [INV]

}


