Rev 202 | Rev 205 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 202 | Rev 204 | ||
---|---|---|---|
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]; |
34 | s8 sByte[12]; |
35 | u8 Byte[12]; |
35 | u8 Byte[12]; |
36 | s16 Int[6]; |
36 | s16 Int[6]; |
37 | s32 Long[3]; |
37 | s32 Long[3]; |
38 | float Float[3]; |
38 | float Float[3]; |
39 | } Param; |
39 | } Param; |
40 | u8 Chksum; |
40 | u8 Chksum; |
41 | } __attribute__((packed)) FromFlightCtrl_t; |
41 | } __attribute__((packed)) FromFlightCtrl_t; |
42 | 42 | ||
43 | #define SPI_NCCMD_OSD_DATA 100 |
43 | #define SPI_NCCMD_OSD_DATA 100 |
44 | #define SPI_NCCMD_GPS_POS 101 |
44 | #define SPI_NCCMD_GPS_POS 101 |
45 | #define SPI_NCCMD_GPS_TARGET 102 |
45 | #define SPI_NCCMD_GPS_TARGET 102 |
46 | #define SPI_NCCMD_KALMAN 103 |
46 | #define SPI_NCCMD_KALMAN 103 |
47 | #define SPI_NCCMD_VERSION 104 |
47 | #define SPI_NCCMD_VERSION 104 |
- | 48 | #define SPI_NCCMD_GPSINFO 105 |
|
48 | 49 | ||
49 | typedef struct |
50 | typedef struct |
50 | { |
51 | { |
51 | u8 Command; |
52 | u8 Command; |
52 | s16 GPS_Nick; |
53 | s16 GPS_Nick; |
53 | s16 GPS_Roll; |
54 | s16 GPS_Roll; |
54 | s16 GPS_Yaw; |
55 | s16 GPS_Yaw; |
55 | s16 CompassHeading; |
56 | s16 CompassHeading; |
56 | s16 Status; |
57 | s16 Status; |
57 | u16 BeepTime; |
58 | u16 BeepTime; |
58 | union |
59 | union |
59 | { |
60 | { |
60 | s8 sByte[12]; |
61 | s8 sByte[12]; |
61 | u8 Byte[12]; |
62 | u8 Byte[12]; |
62 | s16 Int[6]; |
63 | s16 Int[6]; |
63 | s32 Long[3]; |
64 | s32 Long[3]; |
64 | float Float[3]; |
65 | float Float[3]; |
65 | }Param; |
66 | }Param; |
66 | u8 Chksum; |
67 | u8 Chksum; |
67 | } __attribute__((packed)) ToFlightCtrl_t; |
68 | } __attribute__((packed)) ToFlightCtrl_t; |
68 | 69 | ||
69 | 70 | ||
70 | typedef struct |
71 | typedef struct |
71 | { |
72 | { |
72 | u8 Major; |
73 | u8 Major; |
73 | u8 Minor; |
74 | u8 Minor; |
74 | u8 Patch; |
75 | u8 Patch; |
75 | u8 Compatible; |
76 | u8 Compatible; |
76 | u8 Hardware; |
77 | u8 Hardware; |
77 | } __attribute__((packed)) SPI_Version_t; |
78 | } __attribute__((packed)) SPI_Version_t; |
78 | 79 | ||
79 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
80 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
80 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
81 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
81 | extern volatile u32 SPI0_Timeout; |
82 | extern volatile u32 SPI0_Timeout; |
82 | extern SPI_Version_t FC_Version; |
83 | extern SPI_Version_t FC_Version; |
83 | extern fifo_t CompassCalcStateFiFo; |
84 | extern fifo_t CompassCalcStateFiFo; |
84 | 85 | ||
85 | void SPI0_Init(void); |
86 | void SPI0_Init(void); |
86 | void SPI0_GetFlightCtrlVersion(void); |
87 | void SPI0_GetFlightCtrlVersion(void); |
87 | void SPI0_UpdateBuffer(void); |
88 | void SPI0_UpdateBuffer(void); |
88 | 89 | ||
89 | 90 | ||
90 | 91 | ||
91 | #endif //_SPI_SLAVE_H |
92 | #endif //_SPI_SLAVE_H |
92 | 93 |