User_Task.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef _H_USER_TASK_H_
  2. #define _H_USER_TASK_H_
  3. #include "main.h"
  4. #define MAIN_EVENT_BUFF_SIZE 32
  5. #define MoveCheck_INTERVAL 250 //运动检测时间间隔,单位:ms
  6. #define Softwart_INTERVAL_MS 10 //单位:ms
  7. #define CheckEsbCmd_INTERVAL 3000 //单位:ms
  8. #define MSE5611_PRESS_MAX 43000
  9. #define MSE5611_PRESS_MIN 41000
  10. #define SHOES_REALSE_MAX_TIME 60*1000 //鞋子压力持续时间
  11. #define QuitGameMode_Hold_MAX_TIME 5*60*1000/MoveCheck_INTERVAL //五分钟
  12. #define GET_BATTERY_INTERVAL 5000 //电池电压采样时间,单位:ms
  13. #define FEED_WATCHDOG_INTERVAL 3000 //看门狗计数器重置时间,单位:ms
  14. #define ESB_MAX_SEND_DATA (160-5) //ESB发送一帧的最大数据,5个数据为帧头
  15. #define TranforStep_INTERVAL 200 //传输脚步数据的时间间隔,单位:ms
  16. #define TranforStep_MAX_NUMBER 20 //脚步重传的最大次数SS
  17. #define Enable true
  18. #define DisEnable false
  19. #define OY_SetValue_False(value) value=false
  20. #define OY_SetValue_True(value) value=true
  21. #define OY_ClearValue_Zero(value) value=0
  22. #define ME5611_PRESSURE_TEST 0 //气压计压力检测,需要配合上位机MATLAB测试
  23. #define GameMode_TEST 0 //游戏模式测试
  24. #define STEP_TEST 0 //脚步测试
  25. #define ESB_RECV_SEND_TEST 0
  26. typedef enum
  27. {
  28. Stop_Mode,//停止模式
  29. Move_Mode,//运动模式
  30. Game_Mode,//游戏模式
  31. }ShoesState;
  32. typedef struct ShoesInforMation
  33. {
  34. uint8_t power;//电量
  35. uint8_t inner_temperature;//内部温度
  36. uint8_t pressure[4];//压力
  37. }ShoesInforMation_type;
  38. typedef enum
  39. {
  40. Motion_Release,//鞋子处于放空状态
  41. Motion_Press, //鞋子处于踩下状态
  42. }Motion_state_type;
  43. typedef struct Motion_Detect
  44. {
  45. uint16_t ReleaseHoldTime; //鞋子无压力持续时间
  46. uint16_t QuitGameHoldTime; //游戏模式,无压力时间记录
  47. Motion_state_type Motion_state;//鞋子的踩空和释放状态
  48. ShoesState state;
  49. }Motion_Detect_type;
  50. typedef struct TranforStep
  51. {
  52. uint16_t Packetlength; //数据包的数量
  53. uint8_t NumberTransfers; //传输次数
  54. uint8_t CurrentPacket; //当前传输的包
  55. uint16_t BeSentDataLength;//待发送数据长度
  56. bool StopFlag; //停止发送
  57. bool StartFlag; //开始发送标志位
  58. uint8_t systemtime[8]; //系统时间
  59. }TranforStep_type;
  60. typedef enum
  61. {
  62. MainInit_Event,
  63. Move_Event, //运动事件
  64. No_MoveOverTime_Event, //没有运动,超时
  65. Quit_GameMode_Event, //退出游戏模式
  66. Into_GameMode_Event, //进入游戏模式
  67. CheckEsbRxData_Event, //空闲时候接收ESB数据
  68. UpdateStep_Event, //更新脚步
  69. SendStep_Packet_Event, //发送脚步包到ESB
  70. Stop_SendStep_Packet_Event,//停止发送脚步数据
  71. Resquest_Step_Event, //查询步数
  72. EsbError_Event, //Esb传输异常
  73. }MainEvent;
  74. typedef struct motor_control
  75. {
  76. bool flag;
  77. uint16_t delay_ms;
  78. }motor_control_type;
  79. typedef struct _IMU_H IMU_H_t;
  80. typedef struct _IMU_S IMU_S_t;
  81. typedef struct _IMU_DAT IMU_DAT_t;
  82. struct _IMU_H{
  83. int16_t acc[3];
  84. int16_t gyr[3];
  85. int16_t mag[3];
  86. uint16_t press;
  87. int16_t temperature;
  88. };
  89. struct _IMU_S{
  90. int16_t pos[3];
  91. int16_t att[3];
  92. uint16_t press;
  93. uint8_t zupt;
  94. uint8_t rssi;
  95. };
  96. struct _IMU_DAT{
  97. IMU_H_t h;
  98. IMU_S_t s;
  99. };
  100. void User_Task_init(void);
  101. void User_Task_loop(void);
  102. void TranforMainEvent_Fifo(MainEvent _event);
  103. uint32_t TIME_GetTicks(void);
  104. #endif