Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
827 ingob 1
// ######################## SPI - FlightCtrl ###################
2
#ifndef _SPI_H
3
#define _SPI_H
4
 
886 killagreg 5
//#include <util/delay.h>
6
#include <inttypes.h>
827 ingob 7
 
8
 
9
#define SPI_PROTOCOL_COMP   1
10
 
11
 
12
#define SPI_CMD_USER        10
13
#define SPI_CMD_STICK       11
1078 killagreg 14
#define SPI_CMD_MISC            12
936 killagreg 15
#define SPI_CMD_PARAMETER1      13
1078 killagreg 16
#define SPI_CMD_VERSION         14
886 killagreg 17
 
18
typedef struct
827 ingob 19
{
886 killagreg 20
        uint8_t Sync1;
21
        uint8_t Sync2;
22
        uint8_t Command;
911 killagreg 23
        int16_t IntegralNick;
886 killagreg 24
        int16_t IntegralRoll;
911 killagreg 25
        int16_t AccNick;
886 killagreg 26
        int16_t AccRoll;
27
        int16_t GyroHeading;
911 killagreg 28
        int16_t GyroNick;
886 killagreg 29
        int16_t GyroRoll;
30
        int16_t GyroYaw;
31
        union
32
        {
33
                int8_t  sByte[12];
34
                uint8_t Byte[12];
35
                int16_t Int[6];
36
                int32_t Long[3];
37
                float   Float[3];
38
        } Param;
39
        uint8_t Chksum;
1078 killagreg 40
} __attribute__((packed)) ToNaviCtrl_t;
827 ingob 41
 
886 killagreg 42
 
43
 
1078 killagreg 44
#define SPI_CMD_OSD_DATA        100
45
#define SPI_CMD_GPS_POS         101
46
#define SPI_CMD_GPS_TARGET      102
47
#define SPI_KALMAN                      103
886 killagreg 48
 
49
typedef struct
827 ingob 50
{
886 killagreg 51
        uint8_t Command;
1180 killagreg 52
        int16_t GPSStickNick;
53
        int16_t GPSStickRoll;
886 killagreg 54
        int16_t GPS_Yaw;
55
        int16_t CompassHeading;
56
        int16_t Status;
936 killagreg 57
        uint16_t BeepTime;
886 killagreg 58
        union
59
        {
60
                int8_t  Byte[12];
61
                int16_t Int[6];
62
                int32_t Long[3];
63
                float   Float[3];
64
        } Param;
65
        uint8_t Chksum;
1078 killagreg 66
} __attribute__((packed)) FromNaviCtrl_t;
827 ingob 67
 
68
 
1078 killagreg 69
typedef struct
70
{
71
        uint8_t Major;
72
        uint8_t Minor;
73
        uint8_t Patch;
74
        uint8_t Compatible;
75
} __attribute__((packed)) SPI_VersionInfo_t;
76
 
77
 
78
extern ToNaviCtrl_t                     ToNaviCtrl;
79
extern FromNaviCtrl_t                   FromNaviCtrl;
80
 
1222 killagreg 81
 
82
typedef struct
83
{
84
        int8_t  KalmanK;
85
        int8_t  KalmanMaxDrift;
86
        int8_t  KalmanMaxFusion;
87
        uint8_t SerialDataOkay;
88
} __attribute__((packed)) NCData_t;
89
 
90
 
91
extern uint8_t NCDataOkay;
92
extern uint8_t NCSerialDataOkay;
93
 
936 killagreg 94
void SPI_MasterInit(void);
95
void SPI_StartTransmitPacket(void);
96
void SPI_TransmitByte(void);
827 ingob 97
 
98
 
99
 
886 killagreg 100
#endif //_SPI_H