Rev 27 | Rev 43 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 27 | Rev 41 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _SPI_H |
1 | #ifndef _SPI_SLAVE_H |
2 | #define _SPI_H |
2 | #define _SPI_SLAVE_H |
- | 3 | ||
- | 4 | #include "fifo.h" |
|
Line 3... | Line -... | ||
3 | - | ||
Line 4... | Line 5... | ||
4 | #define SPI_PROTOCOL_COMP 1 |
5 | |
Line 5... | Line -... | ||
5 | - | ||
6 | #define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7) |
- | |
7 | - | ||
8 | // IMPORTANT: no syncbytes in structure ! |
6 | |
9 | #define SPI_CMD_USER 10 |
- | |
Line -... | Line 7... | ||
- | 7 | #define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7) |
|
- | 8 | ||
- | 9 | #define SPI_PROTOCOL_COMP 2 |
|
- | 10 | ||
- | 11 | #define SPI_CMD_USER 10 |
|
- | 12 | #define SPI_CMD_STICK 11 |
|
10 | #define SPI_CMD_STICK 11 |
13 | #define SPI_CMD_MISC 12 |
- | 14 | #define SPI_CMD_PARAMETER1 13 |
|
- | 15 | #define SPI_CMD_VERSION 14 |
|
- | 16 | ||
11 | #define SPI_CMD_CAL_COMPASS 12 |
17 | extern s32 FC_Kalman_K; |
12 | #define SPI_CMD_PARAMETER1 13 |
18 | extern s32 Kalman_MaxDrift; |
13 | 19 | extern s32 Kalman_MaxFusion; |
|
14 | struct str_FromFlightCtrl |
20 | typedef struct |
15 | { |
21 | { |
16 | u8 Command; |
22 | u8 Command; |
17 | s16 IntegralNick; |
23 | s16 IntegralNick; |
18 | s16 IntegralRoll; |
24 | s16 IntegralRoll; |
19 | s16 AccNick; |
25 | s16 AccNick; |
20 | s16 AccRoll; |
26 | s16 AccRoll; |
21 | s16 GyroCompass; |
27 | s16 GyroHeading; |
- | 28 | s16 GyroNick; |
|
22 | s16 GyroNick; |
29 | s16 GyroRoll; |
23 | s16 GyroRoll; |
30 | s16 GyroYaw; |
24 | s16 GyroGier; |
31 | union |
- | 32 | { |
|
25 | union |
33 | s8 sByte[12]; |
26 | { u8 Byte[12]; |
- | |
27 | s8 sByte[12]; |
34 | u8 Byte[12]; |
28 | s16 Int[6]; |
35 | s16 Int[6]; |
29 | float Float[3]; |
36 | s32 Long[3]; |
30 | int Long[3]; |
37 | float Float[3]; |
31 | } Param; |
38 | } Param; |
32 | u8 Chksum; |
39 | u8 Chksum; |
33 | } __attribute__((packed)); |
40 | } __attribute__((packed)) FromFlightCtrl_t; |
- | 41 | ||
Line 34... | Line 42... | ||
34 | 42 | #define SPI_CMD_OSD_DATA 100 |
|
35 | #define SPI_CMD_OSD_DATA 100 |
43 | #define SPI_CMD_GPS_POS 101 |
36 | #define SPI_CMD_GPS_POS 101 |
- | |
37 | #define SPI_CMD_GPS_TARGET 102 |
44 | #define SPI_CMD_GPS_TARGET 102 |
38 | 45 | #define SPI_KALMAN 103 |
|
39 | struct str_ToFlightCtrl |
46 | |
40 | { |
47 | typedef struct |
41 | unsigned char Sync1, Sync2; |
48 | { |
42 | unsigned char Command; |
49 | u8 Command; |
43 | s16 GPS_Nick; |
50 | s16 GPS_Nick; |
44 | s16 GPS_Roll; |
51 | s16 GPS_Roll; |
- | 52 | s16 GPS_Yaw; |
|
- | 53 | s16 CompassHeading; |
|
45 | s16 GPS_Gier; |
54 | s16 Status; |
46 | s16 CompassValue; |
55 | u16 BeepTime; |
47 | s16 Status; |
56 | union |
48 | unsigned char BeepTime; |
57 | { |
49 | union |
58 | s8 sByte[12]; |
50 | { u8 Byte[12]; |
59 | u8 Byte[12]; |
51 | s16 Int[6]; |
60 | s16 Int[6]; |
52 | float Float[3]; |
- | |
53 | int Long[3]; |
- | |
54 | } Param; |
- | |
55 | unsigned char Chksum; |
- | |
56 | } __attribute__((packed)); |
- | |
57 | - | ||
Line 58... | Line 61... | ||
58 | 61 | s32 Long[3]; |
|
59 | #define X_AXIS 1 |
62 | float Float[3]; |
60 | #define Y_AXIS 2 |
63 | }Param; |
61 | #define Z_AXIS 3 |
64 | u8 Chksum; |
62 | 65 | } __attribute__((packed)) ToFlightCtrl_t; |
|
- | 66 | ||
63 | 67 | ||
Line -... | Line 68... | ||
- | 68 | typedef struct |
|
- | 69 | { |
|
- | 70 | u8 Major; |
|
- | 71 | u8 Minor; |
|
- | 72 | u8 Patch; |
|
Line -... | Line 73... | ||
- | 73 | u8 Compatible; |
|
64 | 74 | } __attribute__((packed)) SPI_Version_t; |
|
65 | struct str_MicroMag |
75 | |
Line 66... | Line -... | ||
66 | { |
- | |
Line 67... | Line -... | ||
67 | unsigned char ReadAxis, WaitingforMeasurement; |
- | |
Line 68... | Line 76... | ||
68 | s16 Axis[3]; |
76 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
69 | s16 Heading; |
- | |
70 | } __attribute__((packed)); |
- | |
71 | - |