#include "hal_mode_manage.h" #include "hal_imu.h" #include "usr_config.h" #include "bsp_time.h" #include "system.h" /********************************************************************* * LOCAL VARIABLES */ static hal_mode cur_mode; static hal_mode change_mode; /********************************************************************* * LOCAL FUCTIONS */ static void hal_mode_manage_Process(void) { if(change_mode != cur_mode) { switch(change_mode) { case HAL_MODE_GAME: case HAL_MODE_REALSTEP: if(IMU_GetCurrentMode() != STATE_FULL_POWER_MODE){ IMU_ClearAllSignal(); IMU_SetSignal(SIGNAL_FULL_POWER, IMU_SIGNAL_ON); } else{ if(IMU_Get_Front_Data_Num() >= 1 && IMU_Get_Front_Data_Num() < 3){ cur_mode = change_mode; } } break; case HAL_MODE_STANDBY: if(IMU_GetCurrentMode() != STATE_STANDBY_POWER_MODE){ IMU_ClearAllSignal(); IMU_SetSignal(SIGNAL_STANDBY_POWER, IMU_SIGNAL_ON); }else{ if(IMU_Get_Front_Data_Num() >= 10 && IMU_Get_Front_Data_Num() < 13){ cur_mode = change_mode; } } break; case HAL_MODE_NORMAL: if(IMU_GetCurrentMode() != STATE_LOW_POWER_MODE){ IMU_ClearAllSignal(); IMU_SetSignal(SIGNAL_LOW_POWER, IMU_SIGNAL_ON); }else{ if(IMU_Get_Front_Data_Num() >= 10 && IMU_Get_Front_Data_Num() < 13){ cur_mode = change_mode; } } break; case HAL_MODE_SELF_CHECK: if(IMU_GetCurrentMode() != STATE_SELF_CHECK_MODE){ IMU_ClearAllSignal(); IMU_SetSignal(SIGNAL_SELF_CHECK, IMU_SIGNAL_ON); }else{ if(IMU_Get_Front_Data_Num() >= 1 && IMU_Get_Front_Data_Num() < 3){ cur_mode = change_mode; } } break; } } } /********************** 外部接口声明区 *************************/ void hal_mode_set(hal_mode mode) { change_mode = mode; } hal_mode hal_mode_get(void) { return cur_mode; } void hal_mode_manage_Init(void) { if(INIT_MODE == HAL_MODE_NORMAL){ cur_mode = HAL_MODE_NORMAL; change_mode = HAL_MODE_NORMAL; } else if(INIT_MODE == HAL_MODE_STANDBY){ cur_mode = HAL_MODE_STANDBY; change_mode = HAL_MODE_STANDBY; } Process_Start(0,"hal_mode_manage_Process",hal_mode_manage_Process); }