Rev 254 | Rev 258 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 254 | Rev 255 | ||
---|---|---|---|
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 volatile u8 FC_ErrorCode[5]; |
- | |
25 | 24 | ||
26 | typedef struct |
25 | typedef struct |
27 | { |
26 | { |
28 | u8 Command; |
27 | u8 Command; |
29 | s16 AngleNick; // NickAngle in 0.1 deg |
28 | s16 AngleNick; // NickAngle in 0.1 deg |
30 | s16 AngleRoll; // RollAngle in 0.1 deg |
29 | s16 AngleRoll; // RollAngle in 0.1 deg |
31 | s16 AccNick; |
30 | s16 AccNick; |
32 | s16 AccRoll; |
31 | s16 AccRoll; |
33 | s16 GyroHeading; // Heading in 0.1 deg |
32 | s16 GyroHeading; // Heading in 0.1 deg |
34 | s16 GyroNick; |
33 | s16 GyroNick; |
35 | s16 GyroRoll; |
34 | s16 GyroRoll; |
36 | s16 GyroYaw; |
35 | s16 GyroYaw; |
37 | union |
36 | union |
38 | { |
37 | { |
39 | u8 Byte[12]; |
38 | u8 Byte[12]; |
40 | s8 sByte[12]; |
39 | s8 sByte[12]; |
41 | u16 Int[6]; |
40 | u16 Int[6]; |
42 | s16 sInt[6]; |
41 | s16 sInt[6]; |
43 | u32 Long[3]; |
42 | u32 Long[3]; |
44 | s32 sLong[3]; |
43 | s32 sLong[3]; |
45 | float Float[3]; |
44 | float Float[3]; |
46 | } Param; |
45 | } Param; |
47 | u8 Chksum; |
46 | u8 Chksum; |
48 | } __attribute__((packed)) FromFlightCtrl_t; |
47 | } __attribute__((packed)) FromFlightCtrl_t; |
49 | 48 | ||
50 | #define SPI_NCCMD_OSD_DATA 100 |
49 | #define SPI_NCCMD_OSD_DATA 100 |
51 | #define SPI_NCCMD_GPS_POS 101 |
50 | #define SPI_NCCMD_GPS_POS 101 |
52 | #define SPI_NCCMD_GPS_TARGET 102 |
51 | #define SPI_NCCMD_GPS_TARGET 102 |
53 | #define SPI_NCCMD_KALMAN 103 |
52 | #define SPI_NCCMD_KALMAN 103 |
54 | #define SPI_NCCMD_VERSION 104 |
53 | #define SPI_NCCMD_VERSION 104 |
55 | #define SPI_NCCMD_GPSINFO 105 |
54 | #define SPI_NCCMD_GPSINFO 105 |
56 | 55 | ||
57 | typedef struct |
56 | typedef struct |
58 | { |
57 | { |
59 | u8 Command; |
58 | u8 Command; |
60 | GPS_Stick_t GPSStick; |
59 | GPS_Stick_t GPSStick; |
61 | s16 CompassHeading; |
60 | s16 CompassHeading; |
62 | s16 Status; |
61 | s16 Status; |
63 | u16 BeepTime; |
62 | u16 BeepTime; |
64 | union |
63 | union |
65 | { |
64 | { |
66 | u8 Byte[12]; |
65 | u8 Byte[12]; |
67 | s8 sByte[12]; |
66 | s8 sByte[12]; |
68 | u16 Int[6]; |
67 | u16 Int[6]; |
69 | s16 sInt[6]; |
68 | s16 sInt[6]; |
70 | u32 Long[3]; |
69 | u32 Long[3]; |
71 | s32 sLong[3]; |
70 | s32 sLong[3]; |
72 | float Float[3]; |
71 | float Float[3]; |
73 | }Param; |
72 | }Param; |
74 | u8 Chksum; |
73 | u8 Chksum; |
75 | } __attribute__((packed)) ToFlightCtrl_t; |
74 | } __attribute__((packed)) ToFlightCtrl_t; |
76 | 75 | ||
77 | 76 | ||
78 | typedef struct |
77 | typedef struct |
79 | { |
78 | { |
80 | u8 Major; |
79 | u8 Major; |
81 | u8 Minor; |
80 | u8 Minor; |
82 | u8 Patch; |
81 | u8 Patch; |
83 | u8 Compatible; |
82 | u8 Compatible; |
84 | u8 Hardware; |
83 | u8 Hardware; |
85 | } __attribute__((packed)) SPI_Version_t; |
84 | } __attribute__((packed)) SPI_Version_t; |
86 | 85 | ||
87 | extern FromFlightCtrl_t FromFlightCtrl; |
86 | extern FromFlightCtrl_t FromFlightCtrl; |
88 | extern ToFlightCtrl_t ToFlightCtrl; |
87 | extern ToFlightCtrl_t ToFlightCtrl; |
89 | extern volatile u32 SPI0_Timeout; |
88 | extern volatile u32 SPI0_Timeout; |
90 | extern SPI_Version_t FC_Version; |
89 | extern SPI_Version_t FC_Version; |
91 | 90 | ||
92 | void SPI0_Init(void); |
91 | void SPI0_Init(void); |
93 | void SPI0_GetFlightCtrlVersion(void); |
92 | void SPI0_GetFlightCtrlVersion(void); |
94 | void SPI0_UpdateBuffer(void); |
93 | void SPI0_UpdateBuffer(void); |
95 | 94 | ||
96 | 95 | ||
97 | 96 | ||
98 | #endif //_SPI_SLAVE_H |
97 | #endif //_SPI_SLAVE_H |
99 | 98 |