/*
 * BHBF_ROBOT.h
 *
 *  Created on: Oct 26, 2023
 *      Author: shiya
 */

#ifndef INC_BHBF_ROBOT_H_
#define INC_BHBF_ROBOT_H_

#define DF_GL_MotorNum 2
#define SA_GL_MotorNum 3


#include "BSP/bsp_include.h"
#include "BSP/bsp_IMU.h"

#include "MSP/msp_TI5MOTOR_CANOPEN.h"
#include "MSP/msp_OBD.h"
#include "MSP/msp_PID.h"
//#include "MSP/msp_DH_W_H.h"
#include "MSP/msp_TTMotor_ZQ.h"
#include "MSP/msp_DH_W_R_40022_CAN.h"
#include "MSP/msp_PID.h"
#include "MSP/msp_Force_Sensor.h"

//FLASH (rx)     : ORIGIN = 0x08020000, LENGTH = 896K
//#define VECT_TAB_OFFSET         0x00020000U

//关键全局变量定义：GV、CV、PV
//其他变量定义：X1_X2_X3_X4
//X1：变量类型
//X2：所属层级 GL、MSP、BSP
//X3：所属模块
//X4：名称

//全局变量定义 X1=V
//宏定义 X1=DF
//结构体类型声明 X1=SP
//结构体定义 X1=ST
//指针类型定义 X1=P
//全局函数定义 X1=GF
//内部函数定义 X1为空，不要下划线，X2开头
//函数参数定义、函数局部变量定义  X1为空，下划线开头


struct CV_struct_define{
	int32_t Speed_1;
	int32_t Speed_2;
	int32_t Speed_3;
};

struct GV_struct_define
{
	int32_t State_Index_U;
	int32_t State_Index_U_Elapse;
	int32_t State_Index_N;
	int32_t State_Index_N_Elapse;

	int32_t NC_ARRAY_u8_0;//5
	int32_t NC_ARRAY_u8_01;
	int32_t NC_ARRAY_u8_1;
	int32_t NC_ARRAY_u8_11;
	int32_t NC_ARRAY_u8_2;

//	SP_MSP_DH_Handset_Parameters DH_WH_HandSet;
	SP_MSP_DH_CAN_Parameters   DH_CAN_HangSet;
	SP_BSP_MPU6050   Robot_Angle;

	CANOPENPMotorarameters Motor_P_CANOPEN[3];//-28

	TT_MotorParameters TT_Motor_P[4];//-28
	SP_MSP_Force_Value   Force_Value_Bar;

};

struct PV_struct_define{

	int32_t MK32_RxIndex_Last;
	int32_t State_Index_U_Last;
	int32_t State_Index_N_Last;
};


//Global variables related to program execution interfaces
//Interface variables, decision variables
//All types are int32_t
extern struct GV_struct_define GV;

//Process variables related to program execution buffering
//Temporary variables, buffers,intermediate variable
extern struct PV_struct_define PV;

//Configuration variables related to robots
extern struct CV_struct_define CV;

void GF_Robot_Init(void);
void GF_Robot_MainLoop(void);
void GF_WatchDog_Loop(void);

#endif /* INC_BHBF_ROBOT_H_ */
