123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #ifndef _H_USER_TASK_H_
- #define _H_USER_TASK_H_
- #include "main.h"
- #define MAIN_EVENT_BUFF_SIZE 32
- #define MoveCheck_INTERVAL 250 //运动检测时间间隔,单位:ms
- #define Softwart_INTERVAL_MS 10 //单位:ms
- #define CheckEsbCmd_INTERVAL 3000 //单位:ms
- #define MSE5611_PRESS_MAX 43000
- #define MSE5611_PRESS_MIN 41000
- #define SHOES_REALSE_MAX_TIME 60*1000 //鞋子压力持续时间
- #define QuitGameMode_Hold_MAX_TIME 5*60*1000/MoveCheck_INTERVAL //五分钟
- #define GET_BATTERY_INTERVAL 5000 //电池电压采样时间,单位:ms
- #define FEED_WATCHDOG_INTERVAL 3000 //看门狗计数器重置时间,单位:ms
- #define ESB_MAX_SEND_DATA (160-5) //ESB发送一帧的最大数据,5个数据为帧头
- #define TranforStep_INTERVAL 200 //传输脚步数据的时间间隔,单位:ms
- #define TranforStep_MAX_NUMBER 20 //脚步重传的最大次数SS
- #define Enable true
- #define DisEnable false
- #define OY_SetValue_False(value) value=false
- #define OY_SetValue_True(value) value=true
- #define OY_ClearValue_Zero(value) value=0
- #define ME5611_PRESSURE_TEST 0 //气压计压力检测,需要配合上位机MATLAB测试
- #define GameMode_TEST 0 //游戏模式测试
- #define STEP_TEST 0 //脚步测试
- #define ESB_RECV_SEND_TEST 0
- typedef enum
- {
- Stop_Mode,//停止模式
- Move_Mode,//运动模式
- Game_Mode,//游戏模式
- }ShoesState;
- typedef struct ShoesInforMation
- {
- uint8_t power;//电量
- uint8_t inner_temperature;//内部温度
- uint8_t pressure[4];//压力
- }ShoesInforMation_type;
- typedef enum
- {
- Motion_Release,//鞋子处于放空状态
- Motion_Press, //鞋子处于踩下状态
- }Motion_state_type;
- typedef struct Motion_Detect
- {
- uint16_t ReleaseHoldTime; //鞋子无压力持续时间
- uint16_t QuitGameHoldTime; //游戏模式,无压力时间记录
- Motion_state_type Motion_state;//鞋子的踩空和释放状态
- ShoesState state;
- }Motion_Detect_type;
- typedef struct TranforStep
- {
- uint16_t Packetlength; //数据包的数量
- uint8_t NumberTransfers; //传输次数
- uint8_t CurrentPacket; //当前传输的包
- uint16_t BeSentDataLength;//待发送数据长度
- bool StopFlag; //停止发送
- bool StartFlag; //开始发送标志位
- uint8_t systemtime[8]; //系统时间
- }TranforStep_type;
- typedef enum
- {
- MainInit_Event,
- Move_Event, //运动事件
- No_MoveOverTime_Event, //没有运动,超时
- Quit_GameMode_Event, //退出游戏模式
- Into_GameMode_Event, //进入游戏模式
- CheckEsbRxData_Event, //空闲时候接收ESB数据
- UpdateStep_Event, //更新脚步
- SendStep_Packet_Event, //发送脚步包到ESB
- Stop_SendStep_Packet_Event,//停止发送脚步数据
- Resquest_Step_Event, //查询步数
- EsbError_Event, //Esb传输异常
- }MainEvent;
- typedef struct motor_control
- {
- bool flag;
- uint16_t delay_ms;
- }motor_control_type;
- typedef struct _IMU_H IMU_H_t;
- typedef struct _IMU_S IMU_S_t;
- typedef struct _IMU_DAT IMU_DAT_t;
- struct _IMU_H{
- int16_t acc[3];
- int16_t gyr[3];
- int16_t mag[3];
- uint16_t press;
- int16_t temperature;
- };
- struct _IMU_S{
- int16_t pos[3];
- int16_t att[3];
- uint16_t press;
- uint8_t zupt;
- uint8_t rssi;
- };
- struct _IMU_DAT{
- IMU_H_t h;
- IMU_S_t s;
- };
- void User_Task_init(void);
- void User_Task_loop(void);
- void TranforMainEvent_Fifo(MainEvent _event);
- uint32_t TIME_GetTicks(void);
- #endif
|