152 lines
2.4 KiB
C
152 lines
2.4 KiB
C
#ifndef _ALL_USER_DATA_H_
|
||
#define _ALL_USER_DATA_H_
|
||
|
||
#define SUCCESS 0
|
||
#define FAIL -1
|
||
#define FAILED -1
|
||
typedef signed char int8_t;
|
||
typedef signed short int int16_t;
|
||
typedef signed int int32_t;
|
||
typedef signed long long int64_t;
|
||
|
||
/* exact-width unsigned integer types */
|
||
typedef unsigned char uint8_t;
|
||
typedef unsigned short int uint16_t;
|
||
typedef unsigned int uint32_t;
|
||
typedef unsigned long long uint64_t;
|
||
|
||
|
||
#define NULL 0
|
||
extern volatile uint32_t SysTick_count;
|
||
|
||
|
||
typedef struct{
|
||
int16_t accX;
|
||
int16_t accY;
|
||
int16_t accZ;
|
||
int16_t gyroX;
|
||
int16_t gyroY;
|
||
int16_t gyroZ;
|
||
int16_t magX;
|
||
int16_t magY;
|
||
int16_t magZ;
|
||
}_st_Mpu;
|
||
|
||
typedef struct {
|
||
float accX;
|
||
float accY;
|
||
float accZ;
|
||
float gyroX;
|
||
float gyroY;
|
||
float gyroZ;
|
||
float magX;
|
||
float magY;
|
||
float magZ;
|
||
}_st_Mpu_Angle;
|
||
|
||
struct _1_ekf_filter
|
||
{
|
||
float LastP;
|
||
float Now_P;
|
||
float out;
|
||
float Kg;
|
||
float Q;
|
||
float R;
|
||
};
|
||
|
||
//void ekf_1(struct EKF *ekf,void *input); //一维卡尔曼
|
||
extern void kalman_1(struct _1_ekf_filter *ekf,float input); //一维卡尔曼
|
||
|
||
|
||
|
||
typedef struct{
|
||
int16_t magX;
|
||
int16_t magY;
|
||
int16_t magZ;
|
||
}_st_Mag;
|
||
|
||
|
||
typedef struct{
|
||
float rate;
|
||
float height;
|
||
}High;
|
||
|
||
|
||
typedef struct{
|
||
float roll;
|
||
float pitch;
|
||
float yaw;
|
||
}_st_AngE;
|
||
|
||
|
||
|
||
typedef struct
|
||
{
|
||
uint16_t roll;
|
||
uint16_t pitch;
|
||
uint16_t thr;
|
||
uint16_t yaw;
|
||
uint16_t AUX1;
|
||
uint16_t AUX2;
|
||
uint16_t AUX3;
|
||
uint16_t AUX4;
|
||
}_st_Remote;
|
||
|
||
|
||
|
||
typedef volatile struct
|
||
{
|
||
float desired; //< set point
|
||
float offset; //
|
||
float prevError; //< previous error
|
||
float integ; //< integral
|
||
float kp; //< proportional gain
|
||
float ki; //< integral gain
|
||
float kd; //< derivative gain
|
||
float IntegLimitHigh; //< integral limit
|
||
float IntegLimitLow;
|
||
float measured;
|
||
float out;
|
||
float OutLimitHigh;
|
||
float OutLimitLow;
|
||
}PidObject;
|
||
|
||
|
||
typedef volatile struct
|
||
{
|
||
uint8_t unlock;
|
||
|
||
|
||
}_st_ALL_flag;
|
||
|
||
|
||
extern _st_Remote Remote;
|
||
extern _st_Mpu MPU6050;
|
||
extern _st_Mpu MPU6050UnFiltered;
|
||
extern _st_Mpu_Angle MPU6050Angle;
|
||
extern _st_Mag AK8975; //保留,需外接磁力<E7A381><E58A9B>?
|
||
extern _st_AngE Angle;
|
||
|
||
|
||
extern _st_ALL_flag ALL_flag;
|
||
|
||
|
||
extern PidObject pidRateX;
|
||
extern PidObject pidRateY;
|
||
extern PidObject pidRateZ;
|
||
|
||
extern PidObject pidPitch;
|
||
extern PidObject pidRoll;
|
||
extern PidObject pidYaw;
|
||
|
||
extern PidObject pidHeightRate;
|
||
extern PidObject pidHeightHigh;
|
||
|
||
extern int i2c0Lock;
|
||
|
||
extern void I2C0_LCK ();
|
||
extern void I2C0_UNLOCK();
|
||
|
||
#endif
|
||
|