hal_mode_manage.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "hal_mode_manage.h"
  2. #include "hal_imu.h"
  3. #include "usr_config.h"
  4. #include "bsp_time.h"
  5. #include "system.h"
  6. /*********************************************************************
  7. * LOCAL VARIABLES
  8. */
  9. static hal_mode cur_mode;
  10. static hal_mode change_mode;
  11. /*********************************************************************
  12. * LOCAL FUCTIONS
  13. */
  14. static void hal_mode_manage_Process(void)
  15. {
  16. if(change_mode != cur_mode)
  17. {
  18. switch(change_mode)
  19. {
  20. case HAL_MODE_GAME:
  21. case HAL_MODE_REALSTEP:
  22. if(IMU_GetCurrentMode() != STATE_FULL_POWER_MODE){
  23. IMU_ClearAllSignal();
  24. IMU_SetSignal(SIGNAL_FULL_POWER, IMU_SIGNAL_ON);
  25. }
  26. else{
  27. if(IMU_Get_Front_Data_Num() >= 1 && IMU_Get_Front_Data_Num() < 3){
  28. cur_mode = change_mode;
  29. }
  30. }
  31. break;
  32. case HAL_MODE_STANDBY:
  33. if(IMU_GetCurrentMode() != STATE_STANDBY_POWER_MODE){
  34. IMU_ClearAllSignal();
  35. IMU_SetSignal(SIGNAL_STANDBY_POWER, IMU_SIGNAL_ON);
  36. }else{
  37. if(IMU_Get_Front_Data_Num() >= 10 && IMU_Get_Front_Data_Num() < 13){
  38. cur_mode = change_mode;
  39. }
  40. }
  41. break;
  42. case HAL_MODE_NORMAL:
  43. if(IMU_GetCurrentMode() != STATE_LOW_POWER_MODE){
  44. IMU_ClearAllSignal();
  45. IMU_SetSignal(SIGNAL_LOW_POWER, IMU_SIGNAL_ON);
  46. }else{
  47. if(IMU_Get_Front_Data_Num() >= 10 && IMU_Get_Front_Data_Num() < 13){
  48. cur_mode = change_mode;
  49. }
  50. }
  51. break;
  52. case HAL_MODE_SELF_CHECK:
  53. if(IMU_GetCurrentMode() != STATE_SELF_CHECK_MODE){
  54. IMU_ClearAllSignal();
  55. IMU_SetSignal(SIGNAL_SELF_CHECK, IMU_SIGNAL_ON);
  56. }else{
  57. if(IMU_Get_Front_Data_Num() >= 1 && IMU_Get_Front_Data_Num() < 3){
  58. cur_mode = change_mode;
  59. }
  60. }
  61. break;
  62. }
  63. }
  64. }
  65. /********************** Íⲿ½Ó¿ÚÉùÃ÷Çø *************************/
  66. void hal_mode_set(hal_mode mode)
  67. {
  68. change_mode = mode;
  69. }
  70. hal_mode hal_mode_get(void)
  71. {
  72. return cur_mode;
  73. }
  74. void hal_mode_manage_Init(void)
  75. {
  76. if(INIT_MODE == HAL_MODE_NORMAL){
  77. cur_mode = HAL_MODE_NORMAL;
  78. change_mode = HAL_MODE_NORMAL;
  79. }
  80. else if(INIT_MODE == HAL_MODE_STANDBY){
  81. cur_mode = HAL_MODE_STANDBY;
  82. change_mode = HAL_MODE_STANDBY;
  83. }
  84. Process_Start(0,"hal_mode_manage_Process",hal_mode_manage_Process);
  85. }