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