136 lines
3.2 KiB
C
136 lines
3.2 KiB
C
#ifndef __MAIN__H
|
|
#define __MAIN__H
|
|
#include <stdlib.h>
|
|
#include "bsp.h"
|
|
|
|
#define OSC_CNT 40
|
|
#define SLOPE_CNT 20
|
|
|
|
#define PRESS_VPT 3
|
|
#define FOLLOW_VPT 10
|
|
#define SHIELD_VPT 8000
|
|
#define EME_STOP_VPT 4000
|
|
#define CENTRE_VPT 8000
|
|
#define CENTRE_SHIELD_VPT 2000
|
|
|
|
#define STOP_TIME_MS 500
|
|
#define CENT_TIME_MS 200
|
|
#define RUN_TIME_MS 0
|
|
#define EME_START_MS 0
|
|
#define EME_STOP_MS 2000
|
|
|
|
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
|
|
#define BDC_DOWN() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
|
|
#define BDC_UP() (SET_TWIN_BIT1(),CLR_TWIN_BIT0())
|
|
|
|
//#define BDC_STOP() Motor_Control(MOTOR_CMD_STOP)
|
|
//#define BDC_UP() Motor_Control(MOTOR_CMD_FORWARD)
|
|
//#define BDC_DOWN() Motor_Control(MOTOR_CMD_REVERSE)
|
|
|
|
/*控制等级*/
|
|
typedef enum {
|
|
LEVEL_1 = 1, // 一级
|
|
LEVEL_2 = 2, // 二级
|
|
LEVEL_3 = 3, // 三级
|
|
LEVEL_4 = 4, // 四级
|
|
LEVEL_5 = 5 // 五级
|
|
}ControlLevel_m;
|
|
|
|
/*设备阈值*/
|
|
typedef struct{
|
|
int32_t Stop_VPT;
|
|
|
|
int32_t LeftUpVPT;//左上设备阈值
|
|
int32_t LeftLowVPT;//左下设备阈值
|
|
int32_t RightUpVPT;//右上设备阈值
|
|
int32_t RightLowVPT;//右下设备阈值
|
|
|
|
int32_t LeftUpShieldVPT; //左上屏蔽阈值
|
|
int32_t LeftLowShieldVPT; //左下屏蔽阈值
|
|
int32_t RightUpShieldVPT; //右上屏蔽阈值
|
|
int32_t RightLowShieldVPT; //右下屏蔽阈值
|
|
|
|
int32_t LeftUp_Org_AdZero;//左上设备原始AD零点
|
|
int32_t LeftLow_Org_AdZero;//左下设备原始AD零点
|
|
int32_t RightUp_Org_AdZero;//右上设备原始AD零点
|
|
int32_t RightLow_Org_AdZero;//右下设备原始AD零点
|
|
}ADTrack_t;
|
|
typedef struct{//电机参数
|
|
bool RestFlag;
|
|
int16_t Current_height;//当前高度mm
|
|
}MotorPara_t;
|
|
/*数据读取状态机*/
|
|
typedef enum {
|
|
READ_STATUS_IDLE,
|
|
READ_STATUS_START,
|
|
READ_STATUS_LEFTUP,
|
|
READ_STATUS_WAIT_LEFTUP,
|
|
READ_STATUS_LEFTLOW,
|
|
READ_STATUS_WAIT_LEFTLOW,
|
|
READ_STATUS_RIGHTUP,
|
|
READ_STATUS_WAIT_RIGHTUP,
|
|
READ_STATUS_RIGHTLOW,
|
|
READ_STATUS_WAIT_RIGHTLOW,
|
|
READ_STATUS_SUPPORT_CONT
|
|
}ReadStatus_m;
|
|
|
|
/*主程序状态机*/
|
|
typedef enum {
|
|
APP_STATUS_IDLE,
|
|
APP_STATUS_ON,
|
|
APP_STATUS_OFF,
|
|
APP_STATUS_ZERO_MARKING,
|
|
}AppStatus_m;
|
|
|
|
typedef struct{
|
|
__IO uint16_t rPayLen;
|
|
__IO bool HeaderFrame;
|
|
__IO uint16_t RxLen;
|
|
uint8_t RxBuff[4];
|
|
}Uart3Rx_t;
|
|
|
|
typedef struct {
|
|
AppStatus_m Status;//状态
|
|
ReadStatus_m RStatus;
|
|
AppPara_T Para;
|
|
Uart3Rx_t RxUart3Data;
|
|
|
|
ADTrack_t ADTrack;
|
|
MotorPara_t MotorPara;
|
|
uint32_t TD1mSDelayCnt;
|
|
uint32_t Read1mSDelayCnt;
|
|
uint32_t Uart3RxTimeOut1mSCnt;
|
|
uint32_t StopCollDelay1mSCnt;
|
|
uint32_t RunCollDelay1mSCnt;
|
|
uint32_t CentCollDelay1mSCnt;
|
|
uint32_t EmergencyDelay1mSCnt;
|
|
uint8_t FeedDogDlyCnt;
|
|
|
|
bool CaliZeroFlag;//校零标志位
|
|
bool UpFlag;//上升标志位
|
|
bool DownFlag;//下降标志位
|
|
bool StopFlag;//停止标志位
|
|
bool EmeFlag;//应急标志位
|
|
bool LeftRunFalg;
|
|
bool RightRunFalg;
|
|
bool CentreRunFalg;
|
|
|
|
bool LeftUpCS1237ReadEndFlag;
|
|
bool LeftLowCS1237ReadEndFlag;
|
|
bool RightUpCS1237ReadEndFlag;
|
|
bool RightLowCS1237ReadEndFlag;
|
|
|
|
int32_t LeftUpCS1237_TrendArray[OSC_CNT];
|
|
int32_t LeftLowCS1237_TrendArray[OSC_CNT];
|
|
int32_t RightUpCS1237_TrendArray[OSC_CNT];
|
|
int32_t RightLowCS1237_TrendArray[OSC_CNT];
|
|
|
|
int32_t LeftUpCS1237_SlopeArray[SLOPE_CNT];
|
|
int32_t LeftLowCS1237_SlopeArray[SLOPE_CNT];
|
|
int32_t RightUpCS1237_SlopeArray[SLOPE_CNT];
|
|
int32_t RightLowCS1237_SlopeArray[SLOPE_CNT];
|
|
}AppDetect_t;
|
|
extern AppDetect_t App;
|
|
|
|
#endif
|