Subversion Repositories NaviCtrl

Rev

Rev 205 | Rev 215 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 205 Rev 206
1
#ifndef _SPI_SLAVE_H
1
#ifndef _SPI_SLAVE_H
2
#define _SPI_SLAVE_H
2
#define _SPI_SLAVE_H
3
 
3
 
4
#include "fifo.h"
4
#include "fifo.h"
5
 
5
 
6
 
6
 
7
#define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7)
7
#define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7)
8
 
8
 
9
#define SPI_FCCMD_USER                  10
9
#define SPI_FCCMD_USER                  10
10
#define SPI_FCCMD_STICK                 11
10
#define SPI_FCCMD_STICK                 11
11
#define SPI_FCCMD_MISC                  12
11
#define SPI_FCCMD_MISC                  12
12
#define SPI_FCCMD_PARAMETER1    13
12
#define SPI_FCCMD_PARAMETER1    13
13
#define SPI_FCCMD_VERSION               14
13
#define SPI_FCCMD_VERSION               14
14
#define SPI_FCCMD_SERVOS                15
14
#define SPI_FCCMD_SERVOS                15
-
 
15
#define SPI_FCCMD_ACCU                  16
15
 
16
 
16
extern s32 Kalman_K;
17
extern s32 Kalman_K;
17
extern s32 Kalman_MaxDrift;
18
extern s32 Kalman_MaxDrift;
18
extern s32 Kalman_MaxFusion;
19
extern s32 Kalman_MaxFusion;
19
extern s32 ToFcGpsZ;
20
extern s32 ToFcGpsZ;
20
 
21
 
21
typedef struct
22
typedef struct
22
{
23
{
23
        u8   Command;
24
        u8   Command;
24
        s16  AngleNick;  // NickAngle in 0.1 deg
25
        s16  AngleNick;  // NickAngle in 0.1 deg
25
        s16  AngleRoll;  // RollAngle in 0.1 deg
26
        s16  AngleRoll;  // RollAngle in 0.1 deg
26
        s16  AccNick;
27
        s16  AccNick;
27
        s16  AccRoll;
28
        s16  AccRoll;
28
        s16  GyroHeading;        // Heading in 0.1 deg
29
        s16  GyroHeading;        // Heading in 0.1 deg
29
        s16  GyroNick;
30
        s16  GyroNick;
30
        s16  GyroRoll;
31
        s16  GyroRoll;
31
        s16  GyroYaw;
32
        s16  GyroYaw;
32
        union
33
        union
33
        {
34
        {
34
                u8    Byte[12];
35
                u8    Byte[12];
35
                s8        sByte[12];
36
                s8        sByte[12];
36
                u16   Int[6];
37
                u16   Int[6];
37
                s16   sInt[6];
38
                s16   sInt[6];
38
                u32   Long[3];
39
                u32   Long[3];
39
                s32   sLong[3];
40
                s32   sLong[3];
40
                float Float[3];
41
                float Float[3];
41
        } Param;
42
        } Param;
42
        u8 Chksum;
43
        u8 Chksum;
43
 } __attribute__((packed)) FromFlightCtrl_t;
44
 } __attribute__((packed)) FromFlightCtrl_t;
44
 
45
 
45
#define SPI_NCCMD_OSD_DATA              100
46
#define SPI_NCCMD_OSD_DATA              100
46
#define SPI_NCCMD_GPS_POS               101
47
#define SPI_NCCMD_GPS_POS               101
47
#define SPI_NCCMD_GPS_TARGET    102
48
#define SPI_NCCMD_GPS_TARGET    102
48
#define SPI_NCCMD_KALMAN                103
49
#define SPI_NCCMD_KALMAN                103
49
#define SPI_NCCMD_VERSION               104
50
#define SPI_NCCMD_VERSION               104
50
#define SPI_NCCMD_GPSINFO               105
51
#define SPI_NCCMD_GPSINFO               105
51
 
52
 
52
typedef struct
53
typedef struct
53
{
54
{
54
        u8 Command;
55
        u8 Command;
55
        s16 GPS_Nick;
56
        s16 GPS_Nick;
56
        s16 GPS_Roll;
57
        s16 GPS_Roll;
57
        s16 GPS_Yaw;
58
        s16 GPS_Yaw;
58
        s16 CompassHeading;
59
        s16 CompassHeading;
59
        s16 Status;
60
        s16 Status;
60
        u16 BeepTime;
61
        u16 BeepTime;
61
        union
62
        union
62
        {
63
        {
63
                u8    Byte[12];
64
                u8    Byte[12];
64
                s8    sByte[12];
65
                s8    sByte[12];
65
                u16       Int[6];
66
                u16       Int[6];
66
                s16   sInt[6];
67
                s16   sInt[6];
67
                u32   Long[3];
68
                u32   Long[3];
68
                s32   sLong[3];
69
                s32   sLong[3];
69
                float Float[3];
70
                float Float[3];
70
        }Param;
71
        }Param;
71
        u8 Chksum;
72
        u8 Chksum;
72
 } __attribute__((packed)) ToFlightCtrl_t;
73
 } __attribute__((packed)) ToFlightCtrl_t;
73
 
74
 
74
 
75
 
75
typedef struct
76
typedef struct
76
{
77
{
77
   u8 Major;
78
   u8 Major;
78
   u8 Minor;
79
   u8 Minor;
79
   u8 Patch;
80
   u8 Patch;
80
   u8 Compatible;
81
   u8 Compatible;
81
   u8 Hardware;
82
   u8 Hardware;
82
} __attribute__((packed)) SPI_Version_t;
83
} __attribute__((packed)) SPI_Version_t;
83
 
84
 
84
extern volatile FromFlightCtrl_t   FromFlightCtrl;
85
extern volatile FromFlightCtrl_t   FromFlightCtrl;
85
extern volatile ToFlightCtrl_t     ToFlightCtrl;
86
extern volatile ToFlightCtrl_t     ToFlightCtrl;
86
extern volatile u32 SPI0_Timeout;
87
extern volatile u32 SPI0_Timeout;
87
extern SPI_Version_t FC_Version;
88
extern SPI_Version_t FC_Version;
88
extern fifo_t CompassCalcStateFiFo;
89
extern fifo_t CompassCalcStateFiFo;
89
 
90
 
90
void SPI0_Init(void);
91
void SPI0_Init(void);
91
void SPI0_GetFlightCtrlVersion(void);
92
void SPI0_GetFlightCtrlVersion(void);
92
void SPI0_UpdateBuffer(void);
93
void SPI0_UpdateBuffer(void);
93
 
94
 
94
 
95
 
95
 
96
 
96
#endif //_SPI_SLAVE_H
97
#endif //_SPI_SLAVE_H
97
 
98