Rev 118 | Rev 121 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 118 | Rev 119 | ||
---|---|---|---|
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_CMD_USER 10 |
9 | #define SPI_CMD_USER 10 |
10 | #define SPI_CMD_STICK 11 |
10 | #define SPI_CMD_STICK 11 |
11 | #define SPI_CMD_MISC 12 |
11 | #define SPI_CMD_MISC 12 |
12 | #define SPI_CMD_PARAMETER1 13 |
12 | #define SPI_CMD_PARAMETER1 13 |
13 | #define SPI_CMD_VERSION 14 |
13 | #define SPI_CMD_VERSION 14 |
- | 14 | #define SPI_CMD_SERVO 15 |
|
14 | 15 | ||
15 | extern s32 FC_Kalman_K; |
16 | extern s32 FC_Kalman_K; |
16 | extern s32 Kalman_MaxDrift; |
17 | extern s32 Kalman_MaxDrift; |
17 | extern s32 Kalman_MaxFusion; |
18 | extern s32 Kalman_MaxFusion; |
18 | 19 | ||
19 | typedef struct |
20 | typedef struct |
20 | { |
21 | { |
21 | u8 Command; |
22 | u8 Command; |
22 | s16 AngleNick; // NickAngle in 0.1 deg |
23 | s16 AngleNick; // NickAngle in 0.1 deg |
23 | s16 AngleRoll; // RollAngle in 0.1 deg |
24 | s16 AngleRoll; // RollAngle in 0.1 deg |
24 | s16 AccNick; |
25 | s16 AccNick; |
25 | s16 AccRoll; |
26 | s16 AccRoll; |
26 | s16 GyroHeading; // Heading in 0.1 deg |
27 | s16 GyroHeading; // Heading in 0.1 deg |
27 | s16 GyroNick; |
28 | s16 GyroNick; |
28 | s16 GyroRoll; |
29 | s16 GyroRoll; |
29 | s16 GyroYaw; |
30 | s16 GyroYaw; |
30 | union |
31 | union |
31 | { |
32 | { |
32 | s8 sByte[12]; |
33 | s8 sByte[12]; |
33 | u8 Byte[12]; |
34 | u8 Byte[12]; |
34 | s16 Int[6]; |
35 | s16 Int[6]; |
35 | s32 Long[3]; |
36 | s32 Long[3]; |
36 | float Float[3]; |
37 | float Float[3]; |
37 | } Param; |
38 | } Param; |
38 | u8 Chksum; |
39 | u8 Chksum; |
39 | } __attribute__((packed)) FromFlightCtrl_t; |
40 | } __attribute__((packed)) FromFlightCtrl_t; |
40 | 41 | ||
41 | 42 | ||
42 | #define SPI_KALMAN 103 |
43 | #define SPI_KALMAN 103 |
43 | #define SPI_EXTCTRL 104 |
44 | #define SPI_EXTCTRL 104 |
44 | 45 | ||
45 | typedef struct |
46 | typedef struct |
46 | { |
47 | { |
47 | u8 Command; |
48 | u8 Command; |
48 | s16 GPS_Nick; |
49 | s16 GPS_Nick; |
49 | s16 GPS_Roll; |
50 | s16 GPS_Roll; |
50 | s16 GPS_Yaw; |
51 | s16 GPS_Yaw; |
51 | s16 CompassHeading; |
52 | s16 CompassHeading; |
52 | s16 Status; |
53 | s16 Status; |
53 | u16 BeepTime; |
54 | u16 BeepTime; |
54 | union |
55 | union |
55 | { |
56 | { |
56 | s8 sByte[12]; |
57 | s8 sByte[12]; |
57 | u8 Byte[12]; |
58 | u8 Byte[12]; |
58 | s16 Int[6]; |
59 | s16 Int[6]; |
59 | s32 Long[3]; |
60 | s32 Long[3]; |
60 | float Float[3]; |
61 | float Float[3]; |
61 | }Param; |
62 | }Param; |
62 | u8 Chksum; |
63 | u8 Chksum; |
63 | } __attribute__((packed)) ToFlightCtrl_t; |
64 | } __attribute__((packed)) ToFlightCtrl_t; |
64 | 65 | ||
65 | 66 | ||
66 | typedef struct |
67 | typedef struct |
67 | { |
68 | { |
68 | u8 Major; |
69 | u8 Major; |
69 | u8 Minor; |
70 | u8 Minor; |
70 | u8 Patch; |
71 | u8 Patch; |
71 | u8 Compatible; |
72 | u8 Compatible; |
72 | u8 Hardware; |
73 | u8 Hardware; |
73 | } __attribute__((packed)) SPI_Version_t; |
74 | } __attribute__((packed)) SPI_Version_t; |
74 | 75 | ||
75 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
76 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
76 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
77 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
77 | extern SPI_Version_t FC_Version; |
78 | extern SPI_Version_t FC_Version; |
78 | extern fifo_t CompassCalcStateFiFo; |
79 | extern fifo_t CompassCalcStateFiFo; |
79 | extern u32 CheckSPIOkay; |
80 | extern u32 CheckSPIOkay; |
80 | 81 | ||
81 | void SPI0_Init(void); |
82 | void SPI0_Init(void); |
82 | void SPI0_GetFlightCtrlVersion(void); |
83 | void SPI0_GetFlightCtrlVersion(void); |
83 | void SPI0_UpdateBuffer(void); |
84 | void SPI0_UpdateBuffer(void); |
84 | 85 | ||
85 | 86 | ||
86 | 87 | ||
87 | #endif //_SPI_SLAVE_H |
88 | #endif //_SPI_SLAVE_H |
88 | 89 |