/* 他のSW-Cから定期的に呼び出さるタイミングでボタン状態をチェックし降雨量を変化させる */ void GetRainfall(Rainfall *rain) { uint32 cur_key; static uint32 pre_key = 0xFFFF; boolean flg_up = FALSE; boolean flg_down = FALSE; cur_key = sil_rew_iop((void *) KEY_BASE); /* ボタン押下状態に遷移した場合のみ処理を行う */ if (((pre_key & KEY_0) != 0) && ((cur_key & KEY_0) == 0)) { flg_down = TRUE; } else if (((pre_key & KEY_1) != 0) && ((cur_key & KEY_1) == 0)) { flg_up = TRUE; } /* 降雨量増大 */ if ((flg_up == TRUE) && (cur_rainfall < 4)) { cur_rainfall++; } /* 降雨量現象 */ else if ((flg_down == TRUE) && (cur_rainfall > 0)) { cur_rainfall--; } pre_key = cur_key; *rain = cur_rainfall; }
void checkBrakePedal(void) { uint32 key; key = sil_rew_iop((void *) KEY_BASE); if ((key & KEY_1) == 0) { Rte_Write_BrakeStateOut_BrakeEvent(TRUE); } else { Rte_Write_BrakeStateOut_BrakeEvent(FALSE); } return; }
void checkAcceleratorLevel(void) { uint32 key; key = sil_rew_iop((void *) KEY_BASE); if ((key & KEY_0) == 0) { // ON AcceleratorLevel += ACCELERATOR_LEVEL_CHG; } else { // OFF AcceleratorLevel -= ACCELERATOR_LEVEL_CHG; } if (AcceleratorLevel < 0) { AcceleratorLevel = 0; } else if (AcceleratorLevel > ACCELERATOR_LEVEL_MAX) { AcceleratorLevel = ACCELERATOR_LEVEL_MAX; } Rte_Write_LevelToCALLOut_LevelToCALL((AccelLevel) AcceleratorLevel); Rte_Write_LevelToECOut_LevelToEC((AccelLevel) AcceleratorLevel); return; }