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