Subversion Repositories NaviCtrl

Rev

Rev 206 | Rev 222 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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