Rev 329 | Rev 331 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 329 | Rev 330 | ||
---|---|---|---|
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_Kompass ; |
|
19 | extern s32 Kalman_MaxDrift; |
20 | extern s32 Kalman_MaxDrift; |
20 | extern s32 Kalman_MaxFusion; |
21 | extern s32 Kalman_MaxFusion; |
21 | extern s32 ToFcGpsZ; |
22 | extern s32 ToFcGpsZ; |
22 | extern s32 ToFC_Rotate_C, ToFC_Rotate_S; |
23 | extern s32 ToFC_Rotate_C, ToFC_Rotate_S; |
23 | extern s32 HeadFreeStartAngle; |
24 | extern s32 HeadFreeStartAngle; |
24 | extern s16 FC_WP_EventChannel; |
25 | extern s16 FC_WP_EventChannel; |
25 | extern u32 ToFC_AltitudeRate; |
26 | extern u32 ToFC_AltitudeRate; |
26 | extern s32 ToFC_AltitudeSetpoint; |
27 | extern s32 ToFC_AltitudeSetpoint; |
27 | extern u8 NC_GPS_ModeCharacter; |
28 | extern u8 NC_GPS_ModeCharacter; |
- | 29 | extern u8 FC_is_Calibrated; |
|
- | 30 | extern u8 FCCalibActive; |
|
- | 31 | ||
28 | typedef struct |
32 | typedef struct |
29 | { |
33 | { |
30 | u8 Command; |
34 | u8 Command; |
31 | s16 AngleNick; // NickAngle in 0.1 deg |
35 | s16 AngleNick; // NickAngle in 0.1 deg |
32 | s16 AngleRoll; // RollAngle in 0.1 deg |
36 | s16 AngleRoll; // RollAngle in 0.1 deg |
33 | s16 AccNick; |
37 | s16 AccNick; |
34 | s16 AccRoll; |
38 | s16 AccRoll; |
35 | s16 GyroHeading; // Heading in 0.1 deg |
39 | s16 GyroHeading; // Heading in 0.1 deg |
36 | s16 GyroNick; |
40 | s16 GyroNick; |
37 | s16 GyroRoll; |
41 | s16 GyroRoll; |
38 | s16 GyroYaw; |
42 | s16 GyroYaw; |
39 | u16 FCStatus; |
43 | u16 FCStatus; |
40 | union |
44 | union |
41 | { |
45 | { |
42 | u8 Byte[12]; |
46 | u8 Byte[12]; |
43 | s8 sByte[12]; |
47 | s8 sByte[12]; |
44 | u16 Int[6]; |
48 | u16 Int[6]; |
45 | s16 sInt[6]; |
49 | s16 sInt[6]; |
46 | u32 Long[3]; |
50 | u32 Long[3]; |
47 | s32 sLong[3]; |
51 | s32 sLong[3]; |
48 | float Float[3]; |
52 | float Float[3]; |
49 | } Param; |
53 | } Param; |
50 | u8 Chksum; |
54 | u8 Chksum; |
51 | } __attribute__((packed)) FromFlightCtrl_t; |
55 | } __attribute__((packed)) FromFlightCtrl_t; |
52 | 56 | ||
53 | #define SPI_NCCMD_OSD_DATA 100 |
57 | #define SPI_NCCMD_OSD_DATA 100 |
54 | #define SPI_NCCMD_GPS_POS 101 |
58 | #define SPI_NCCMD_GPS_POS 101 |
55 | #define SPI_NCCMD_GPS_TARGET 102 |
59 | #define SPI_NCCMD_GPS_TARGET 102 |
56 | #define SPI_NCCMD_KALMAN 103 |
60 | #define SPI_NCCMD_KALMAN 103 |
57 | #define SPI_NCCMD_VERSION 104 |
61 | #define SPI_NCCMD_VERSION 104 |
58 | #define SPI_NCCMD_GPSINFO 105 |
62 | #define SPI_NCCMD_GPSINFO 105 |
59 | #define SPI_NCCMD_HOTT_INFO 106 |
63 | #define SPI_NCCMD_HOTT_INFO 106 |
60 | 64 | ||
61 | #define HOTT_VARIO_PACKET_ID 0x89 |
65 | #define HOTT_VARIO_PACKET_ID 0x89 |
62 | #define HOTT_GPS_PACKET_ID 0x8A |
66 | #define HOTT_GPS_PACKET_ID 0x8A |
63 | #define HOTT_ELECTRIC_AIR_PACKET_ID 0x8E |
67 | #define HOTT_ELECTRIC_AIR_PACKET_ID 0x8E |
- | 68 | #define HOTT_GENERAL_PACKET_ID 0x8D |
|
64 | 69 | ||
65 | typedef struct |
70 | typedef struct |
66 | { |
71 | { |
67 | u8 Command; |
72 | u8 Command; |
68 | GPS_Stick_t GPSStick; |
73 | GPS_Stick_t GPSStick; |
69 | s16 CompassHeading; |
74 | s16 CompassHeading; |
70 | s16 AccErrorN; // s16 MagVecX; |
75 | s16 AccErrorN; // s16 MagVecX; |
71 | s16 AccErrorR; // s16 MagVecY; |
76 | s16 AccErrorR; // s16 MagVecY; |
72 | s16 MagVecZ; |
77 | s16 MagVecZ; |
73 | s16 NCStatus; |
78 | s16 NCStatus; |
74 | u16 BeepTime; |
79 | u16 BeepTime; |
75 | union |
80 | union |
76 | { |
81 | { |
77 | u8 Byte[12]; |
82 | u8 Byte[12]; |
78 | s8 sByte[12]; |
83 | s8 sByte[12]; |
79 | u16 Int[6]; |
84 | u16 Int[6]; |
80 | s16 sInt[6]; |
85 | s16 sInt[6]; |
81 | u32 Long[3]; |
86 | u32 Long[3]; |
82 | s32 sLong[3]; |
87 | s32 sLong[3]; |
83 | float Float[3]; |
88 | float Float[3]; |
84 | }Param; |
89 | }Param; |
85 | u8 Chksum; |
90 | u8 Chksum; |
86 | } __attribute__((packed)) ToFlightCtrl_t; |
91 | } __attribute__((packed)) ToFlightCtrl_t; |
87 | 92 | ||
88 | 93 | ||
89 | typedef struct |
94 | typedef struct |
90 | { |
95 | { |
91 | u8 Major; |
96 | u8 Major; |
92 | u8 Minor; |
97 | u8 Minor; |
93 | u8 Patch; |
98 | u8 Patch; |
94 | u8 Compatible; |
99 | u8 Compatible; |
95 | u8 Hardware; |
100 | u8 Hardware; |
96 | } __attribute__((packed)) SPI_Version_t; |
101 | } __attribute__((packed)) SPI_Version_t; |
97 | 102 | ||
98 | extern FromFlightCtrl_t FromFlightCtrl; |
103 | extern FromFlightCtrl_t FromFlightCtrl; |
99 | extern ToFlightCtrl_t ToFlightCtrl; |
104 | extern ToFlightCtrl_t ToFlightCtrl; |
100 | extern volatile u32 SPI0_Timeout; |
105 | extern volatile u32 SPI0_Timeout; |
101 | extern SPI_Version_t FC_Version; |
106 | extern SPI_Version_t FC_Version; |
102 | extern u8 DisableFC_Sticks; |
107 | extern u8 DisableFC_Sticks; |
103 | 108 | ||
104 | void SPI0_Init(void); |
109 | void SPI0_Init(void); |
105 | void SPI0_GetFlightCtrlVersion(void); |
110 | void SPI0_GetFlightCtrlVersion(void); |
106 | void SPI0_UpdateBuffer(void); |
111 | void SPI0_UpdateBuffer(void); |
107 | 112 | ||
108 | 113 | ||
109 | 114 | ||
110 | #endif //_SPI_SLAVE_H |
115 | #endif //_SPI_SLAVE_H |
111 | 116 |