2026-06-15 16:49:21 +08:00
|
|
|
#ifndef __MAIN__H
|
|
|
|
|
#define __MAIN__H
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "bsp.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define USE_FILE_SYSTEM 1
|
|
|
|
|
#define SDCARD_BLOCK_MAX (10000)
|
|
|
|
|
|
|
|
|
|
#define OSC_CNT 40
|
|
|
|
|
#define SLOPE_CNT 20
|
|
|
|
|
|
|
|
|
|
#define SLOPE_VPT 1000
|
2026-07-10 16:28:43 +08:00
|
|
|
#define PRESS_VPT 3
|
2026-06-15 16:49:21 +08:00
|
|
|
#define FOLLOW_VPT 10
|
2026-07-09 18:52:49 +08:00
|
|
|
#define SHIELD_VPT 2
|
2026-06-15 16:49:21 +08:00
|
|
|
#define EME_STOP_VPT 4000
|
2026-07-09 18:52:49 +08:00
|
|
|
|
|
|
|
|
#define CENTRE_FRONT_CNT 0
|
|
|
|
|
#define CENTRE_FRONT_SUM 0
|
|
|
|
|
#define CENTRE_FRONT_VPT 0
|
|
|
|
|
#define CENTRE_VPT 0
|
2026-06-15 16:49:21 +08:00
|
|
|
|
|
|
|
|
#define STOP_TIME_MS 500
|
2026-07-09 18:52:49 +08:00
|
|
|
#define CENT_TIME_MS 200
|
2026-06-15 16:49:21 +08:00
|
|
|
#define RUN_TIME_MS 0
|
|
|
|
|
#define EME_START_MS 0
|
|
|
|
|
#define EME_STOP_MS 2000
|
|
|
|
|
#define SLOPE_START_MS 3000
|
|
|
|
|
|
2026-07-09 18:52:49 +08:00
|
|
|
#define TRAVEL_TIME_MS 50000
|
2026-06-15 16:49:21 +08:00
|
|
|
|
|
|
|
|
#define PEAK 1200 //1200mm
|
|
|
|
|
#define VALLEY 720 //720mm
|
|
|
|
|
|
|
|
|
|
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
|
2026-07-09 18:52:49 +08:00
|
|
|
#define BDC_DOWN() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
|
|
|
|
|
#define BDC_UP() (SET_TWIN_BIT1(),CLR_TWIN_BIT0())
|
2026-06-15 16:49:21 +08:00
|
|
|
|
|
|
|
|
//#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 Slope_VPT;
|
|
|
|
|
int32_t Stop_VPT;
|
|
|
|
|
|
|
|
|
|
int32_t LeftUpVPT;//左上设备阈值
|
|
|
|
|
int32_t LeftLowVPT;//左下设备阈值
|
|
|
|
|
int32_t RightUpVPT;//右上设备阈值
|
|
|
|
|
int32_t RightLowVPT;//右下设备阈值
|
|
|
|
|
|
|
|
|
|
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 InitialFlag;//初始标志位
|
|
|
|
|
bool RestFlag;
|
|
|
|
|
bool CaliFlag;
|
|
|
|
|
bool LoopOne;//循环一次标志位
|
|
|
|
|
int16_t Current_height;//当前高度mm
|
|
|
|
|
int16_t CaliNum;//标校数量
|
|
|
|
|
int32_t LU_HeightStress[488];//左上传感器对应高度应力
|
|
|
|
|
int32_t LL_HeightStress[488];//左下传感器对应高度应力
|
|
|
|
|
int32_t RU_HeightStress[488];//右上传感器对应高度应力
|
|
|
|
|
int32_t RL_HeightStress[488];//右上传感器对应高度应力
|
|
|
|
|
}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_MOTOR_INIT,
|
|
|
|
|
APP_STATUS_WAIT_MOTOR_INIT,
|
|
|
|
|
APP_STATUS_WAIT_MOTOR_CALI_UP,
|
|
|
|
|
APP_STATUS_WAIT_MOTOR_CALI_DOWN,
|
|
|
|
|
APP_STATUS_WAIT_STEADY,
|
|
|
|
|
APP_STATUS_ZERO_MARKING,
|
|
|
|
|
APP_STATUS_HEIGHT_CONTROL,
|
|
|
|
|
}AppStatus_m;
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
|
__IO uint16_t rPayLen;
|
|
|
|
|
__IO bool HeaderFrame;
|
|
|
|
|
__IO uint16_t RxLen;
|
|
|
|
|
uint8_t RxBuff[10];
|
|
|
|
|
}Uart1Rx_t;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
Uart1Rx_t RxUart1Data;
|
|
|
|
|
Uart3Rx_t RxUart3Data;
|
|
|
|
|
|
|
|
|
|
ADTrack_t ADTrack;
|
|
|
|
|
MotorPara_t MotorPara;
|
|
|
|
|
uint32_t TD1mSDelayCnt;
|
|
|
|
|
uint32_t Read1mSDelayCnt;
|
|
|
|
|
uint32_t Uart1Delay1mSCnt;
|
|
|
|
|
uint32_t Uart3RxTimeOut1mSCnt;
|
|
|
|
|
uint32_t StopCollDelay1mSCnt;
|
|
|
|
|
uint32_t RunCollDelay1mSCnt;
|
2026-07-09 18:52:49 +08:00
|
|
|
uint32_t CentCollDelay1mSCnt;
|
2026-06-15 16:49:21 +08:00
|
|
|
uint32_t EmergencyDelay1mSCnt;
|
|
|
|
|
uint32_t SlopeCollDelay1mSCnt;
|
|
|
|
|
uint32_t CailUp1mSCnt;
|
|
|
|
|
uint32_t HeightContRolCnt;
|
|
|
|
|
uint8_t FeedDogDlyCnt;
|
|
|
|
|
|
|
|
|
|
bool CaliZeroFlag;//校零标志位
|
|
|
|
|
bool SideFlag;//侧压标志位
|
|
|
|
|
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];
|
|
|
|
|
|
2026-07-09 18:52:49 +08:00
|
|
|
int32_t aaa;
|
|
|
|
|
int32_t bbb;
|
|
|
|
|
int32_t ccc;
|
|
|
|
|
int32_t ddd;
|
|
|
|
|
|
2026-06-15 16:49:21 +08:00
|
|
|
bool WaitFlag;
|
|
|
|
|
}AppDetect_t;
|
|
|
|
|
extern AppDetect_t App;
|
|
|
|
|
|
|
|
|
|
#endif
|