Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2034 → Rev 2035

/branches/dongfang_FC_rewrite/spi.h
1,4 → 1,3
// ######################## SPI - FlightCtrl ###################
#ifndef _SPI_H
#define _SPI_H
 
11,69 → 10,108
#define SPI_CMD_MISC 12
#define SPI_CMD_PARAMETER1 13
#define SPI_CMD_VERSION 14
 
typedef struct {
uint8_t Sync1;
uint8_t Sync2;
uint8_t Command;
int16_t IntegralPitch;
int16_t IntegralRoll;
int16_t AccPitch;
int16_t AccRoll;
int16_t GyroHeading;
int16_t GyroPitch;
int16_t GyroRoll;
int16_t GyroYaw;
union {
int8_t sByte[12];
uint8_t Byte[12];
int16_t Int[6];
int32_t Long[3];
float Float[3];
} Param;
uint8_t Chksum;
}__attribute__((packed)) ToNaviCtrl_t;
 
#define SPI_CMD_OSD_DATA 100
#define SPI_CMD_GPS_POS 101
#define SPI_CMD_GPS_TARGET 102
#define SPI_KALMAN 103
#define SPI_NCCMD_KALMAN 103
#define SPI_NCCMD_VERSION 104
#define SPI_NCCMD_GPSINFO 105
#define SPI_NCCMD_HOTT_DATA 106
#define SPI_MISC 107
 
// Satfix types for GPSData.SatFix
#define SATFIX_NONE 0x00
#define SATFIX_DEADRECKOING 0x01
#define SATFIX_2D 0x02
#define SATFIX_3D 0x03
#define SATFIX_GPS_DEADRECKOING 0x04
#define SATFIX_TIMEONLY 0x05
// Flags for interpretation of the GPSData.Flags
#define FLAG_GPSFIXOK 0x01 // (i.e. within DOP & ACC Masks)
#define FLAG_DIFFSOLN 0x02 // (is DGPS used)
#define FLAG_WKNSET 0x04 // (is Week Number valid)
#define FLAG_TOWSET 0x08 // (is Time of Week valid)
#define FLAG_GPS_NAVIGATION_ACTIVE 0x10 // NC to FC -> NC is ready to navigate
 
typedef struct {
uint8_t Command;
uint8_t sync1;
uint8_t sync2;
uint8_t command;
int16_t integralPitch;
int16_t integralRoll;
int16_t accPitch;
int16_t accRoll;
int16_t gyroHeading;
int16_t gyroPitch;
int16_t gyroRoll;
int16_t gyroYaw;
uint8_t FCStatus;
union {
int8_t asSignedByte[12];
uint8_t asByte[12];
int16_t asInt[6];
int32_t asLong[3];
float asFloat[3];
} param;
uint8_t chksum;
}__attribute__((packed)) ToNaviCtrl_t;
 
typedef struct {
uint8_t command;
int16_t GPSStickPitch;
int16_t GPSStickRoll;
int16_t GPS_Yaw;
int16_t CompassHeading;
int16_t Status;
uint16_t BeepTime;
int16_t GPSStickYaw;
int16_t accErrorPitch;
int16_t accErrorRoll;
int16_t magVectorZ;
int16_t compassHeading;
int16_t status;
uint16_t beepTime;
union {
int8_t Byte[12];
int16_t Int[6];
int32_t Long[3];
float Float[3];
} Param;
uint8_t Chksum;
int8_t asSignedByte[12];
uint8_t asByte[12];
int16_t asSignedInt[6];
uint16_t asInt[6];
int32_t asSignedLong[3];
uint32_t asLong[3];
float asFloat[3];
} param;
uint8_t chksum;
}__attribute__((packed)) FromNaviCtrl_t;
 
typedef struct {
uint8_t Major;
uint8_t Minor;
uint8_t Patch;
uint8_t Compatible;
// unsigned char Hardware;
uint8_t major;
uint8_t minor;
uint8_t patch;
uint8_t compatible;
uint8_t hardware;
}__attribute__((packed)) SPI_VersionInfo_t;
 
// Some of this is defined for compatibility with H&I NaviCtrl rather than necessity of the data...
typedef struct {
int8_t kalmanK;
int8_t kalmanMaxDrift;
int8_t kalmanMaxFusion;
uint8_t serialDataOkay;
int8_t GPS_Z;
}__attribute__((packed)) NCData_t;
 
typedef struct {
unsigned char flags; // Status Flags
unsigned char numOfSats; // number of satelites
unsigned char satFix; // type of satfix
unsigned char speed; // m/sek
unsigned int homeDistance; // distance to Home in dm
int homeBearing; // bearing to home in deg
}__attribute__((packed)) GPSInfo_t;
 
extern SPI_VersionInfo_t naviCtrlVersion;
extern ToNaviCtrl_t toNaviCtrl;
extern FromNaviCtrl_t fromNaviCtrl;
extern NCData_t naviCtrlData;
extern GPSInfo_t GPSInfo;
 
typedef struct {
int8_t KalmanK;
int8_t KalmanMaxDrift;
int8_t KalmanMaxFusion;
uint8_t SerialDataOkay;
}__attribute__((packed)) NCData_t;
 
extern uint8_t NCDataOkay;
extern uint8_t NCSerialDataOkay;
 
80,7 → 118,5
void SPI_MasterInit(void);
void SPI_StartTransmitPacket(void);
void SPI_TransmitByte(void);
// new:
// extern void UpdateSPI_Buffer(void);
 
#endif //_SPI_H