Subversion Repositories FlightCtrl

Rev

Rev 1821 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1821 Rev 2035
Line 1... Line -...
1
// ######################## SPI - FlightCtrl ###################
-
 
2
#ifndef _SPI_H
1
#ifndef _SPI_H
3
#define _SPI_H
2
#define _SPI_H
Line 4... Line 3...
4
 
3
 
5
//#include <util/delay.h>
4
//#include <util/delay.h>
Line 9... Line 8...
9
#define SPI_CMD_USER        10
8
#define SPI_CMD_USER        10
10
#define SPI_CMD_STICK       11
9
#define SPI_CMD_STICK       11
11
#define SPI_CMD_MISC            12
10
#define SPI_CMD_MISC            12
12
#define SPI_CMD_PARAMETER1      13
11
#define SPI_CMD_PARAMETER1      13
13
#define SPI_CMD_VERSION         14
12
#define SPI_CMD_VERSION         14
14
 
-
 
15
typedef struct {
-
 
16
        uint8_t Sync1;
-
 
17
        uint8_t Sync2;
-
 
18
        uint8_t Command;
-
 
19
        int16_t IntegralPitch;
-
 
20
        int16_t IntegralRoll;
-
 
21
        int16_t AccPitch;
-
 
22
        int16_t AccRoll;
-
 
23
        int16_t GyroHeading;
-
 
24
        int16_t GyroPitch;
-
 
25
        int16_t GyroRoll;
-
 
26
        int16_t GyroYaw;
-
 
27
        union {
-
 
28
                int8_t sByte[12];
-
 
29
                uint8_t Byte[12];
-
 
30
                int16_t Int[6];
-
 
31
                int32_t Long[3];
-
 
32
                float Float[3];
-
 
33
        } Param;
-
 
34
        uint8_t Chksum;
-
 
35
}__attribute__((packed)) ToNaviCtrl_t;
-
 
36
 
-
 
37
#define SPI_CMD_OSD_DATA        100
13
#define SPI_CMD_OSD_DATA        100
38
#define SPI_CMD_GPS_POS         101
14
#define SPI_CMD_GPS_POS         101
39
#define SPI_CMD_GPS_TARGET      102
15
#define SPI_CMD_GPS_TARGET      102
40
#define SPI_KALMAN                      103
16
#define SPI_KALMAN                      103
-
 
17
#define SPI_NCCMD_KALMAN                103
-
 
18
#define SPI_NCCMD_VERSION               104
-
 
19
#define SPI_NCCMD_GPSINFO               105
-
 
20
#define SPI_NCCMD_HOTT_DATA             106
-
 
21
#define SPI_MISC                                107
-
 
22
 
-
 
23
// Satfix types for GPSData.SatFix
-
 
24
#define SATFIX_NONE                             0x00
-
 
25
#define SATFIX_DEADRECKOING             0x01
-
 
26
#define SATFIX_2D                               0x02
-
 
27
#define SATFIX_3D                               0x03
-
 
28
#define SATFIX_GPS_DEADRECKOING 0x04
-
 
29
#define SATFIX_TIMEONLY                 0x05
-
 
30
// Flags for interpretation of the GPSData.Flags
-
 
31
#define FLAG_GPSFIXOK                           0x01 // (i.e. within DOP & ACC Masks)
-
 
32
#define FLAG_DIFFSOLN                           0x02 // (is DGPS used)
-
 
33
#define FLAG_WKNSET                                     0x04 // (is Week Number valid)
-
 
34
#define FLAG_TOWSET                                     0x08 // (is Time of Week valid)
-
 
35
#define FLAG_GPS_NAVIGATION_ACTIVE      0x10 // NC to FC -> NC is ready to navigate
-
 
36
 
-
 
37
typedef struct {
-
 
38
        uint8_t sync1;
-
 
39
        uint8_t sync2;
-
 
40
        uint8_t command;
-
 
41
        int16_t integralPitch;
-
 
42
        int16_t integralRoll;
-
 
43
        int16_t accPitch;
-
 
44
        int16_t accRoll;
-
 
45
        int16_t gyroHeading;
-
 
46
        int16_t gyroPitch;
-
 
47
        int16_t gyroRoll;
-
 
48
        int16_t gyroYaw;
-
 
49
        uint8_t FCStatus;
-
 
50
        union {
-
 
51
                int8_t  asSignedByte[12];
-
 
52
                uint8_t asByte[12];
-
 
53
                int16_t asInt[6];
-
 
54
                int32_t asLong[3];
-
 
55
                float   asFloat[3];
-
 
56
        } param;
-
 
57
        uint8_t chksum;
-
 
58
}__attribute__((packed)) ToNaviCtrl_t;
Line 41... Line 59...
41
 
59
 
42
typedef struct {
60
typedef struct {
43
        uint8_t Command;
61
        uint8_t command;
44
        int16_t GPSStickPitch;
62
        int16_t GPSStickPitch;
45
        int16_t GPSStickRoll;
63
        int16_t GPSStickRoll;
-
 
64
        int16_t GPSStickYaw;
-
 
65
        int16_t accErrorPitch;
-
 
66
        int16_t accErrorRoll;
46
        int16_t GPS_Yaw;
67
        int16_t magVectorZ;
47
        int16_t CompassHeading;
68
        int16_t compassHeading;
48
        int16_t Status;
69
        int16_t status;
49
        uint16_t BeepTime;
70
        uint16_t beepTime;
-
 
71
        union {
50
        union {
72
                int8_t  asSignedByte[12];
-
 
73
                uint8_t asByte[12];
51
                int8_t Byte[12];
74
                int16_t asSignedInt[6];
-
 
75
                uint16_t asInt[6];
52
                int16_t Int[6];
76
                int32_t asSignedLong[3];
53
                int32_t Long[3];
77
                uint32_t asLong[3];
54
                float Float[3];
78
                float   asFloat[3];
55
        } Param;
79
        } param;
56
        uint8_t Chksum;
80
        uint8_t chksum;
Line 57... Line 81...
57
}__attribute__((packed)) FromNaviCtrl_t;
81
}__attribute__((packed)) FromNaviCtrl_t;
58
 
82
 
59
typedef struct {
83
typedef struct {
60
        uint8_t Major;
84
        uint8_t major;
61
        uint8_t Minor;
85
        uint8_t minor;
62
        uint8_t Patch;
86
        uint8_t patch;
63
        uint8_t Compatible;
87
        uint8_t compatible;
Line 64... Line -...
64
//    unsigned char Hardware;
-
 
65
}__attribute__((packed)) SPI_VersionInfo_t;
88
        uint8_t hardware;
66
 
-
 
67
extern ToNaviCtrl_t toNaviCtrl;
89
}__attribute__((packed)) SPI_VersionInfo_t;
68
extern FromNaviCtrl_t fromNaviCtrl;
90
 
69
 
91
// Some of this is defined for compatibility with H&I NaviCtrl rather than necessity of the data...
70
typedef struct {
92
typedef struct {
71
        int8_t KalmanK;
93
        int8_t kalmanK;
-
 
94
        int8_t kalmanMaxDrift;
72
        int8_t KalmanMaxDrift;
95
        int8_t kalmanMaxFusion;
Line -... Line 96...
-
 
96
        uint8_t serialDataOkay;
-
 
97
        int8_t GPS_Z;
-
 
98
}__attribute__((packed)) NCData_t;
-
 
99
 
-
 
100
typedef struct {
-
 
101
        unsigned char   flags;                  // Status Flags
-
 
102
        unsigned char   numOfSats;              // number of satelites
-
 
103
        unsigned char   satFix;                 // type of satfix
-
 
104
        unsigned char   speed;                  // m/sek
-
 
105
        unsigned int    homeDistance;   // distance to Home in dm
-
 
106
        int                             homeBearing;    // bearing to home in deg
-
 
107
}__attribute__((packed)) GPSInfo_t;
-
 
108
 
-
 
109
extern SPI_VersionInfo_t naviCtrlVersion;
-
 
110
extern ToNaviCtrl_t toNaviCtrl;
73
        int8_t KalmanMaxFusion;
111
extern FromNaviCtrl_t fromNaviCtrl;
74
        uint8_t SerialDataOkay;
112
extern NCData_t naviCtrlData;
Line 75... Line 113...
75
}__attribute__((packed)) NCData_t;
113
extern GPSInfo_t GPSInfo;
76
 
114
 
77
extern uint8_t NCDataOkay;
115
extern uint8_t NCDataOkay;
78
extern uint8_t NCSerialDataOkay;
-
 
79
 
-
 
Line 80... Line 116...
80
void SPI_MasterInit(void);
116
extern uint8_t NCSerialDataOkay;