Rev 338 | Rev 351 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 338 | Rev 342 | ||
---|---|---|---|
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_Kompass ; |
19 | extern s32 Kalman_Kompass ; |
20 | extern s32 Kalman_MaxDrift; |
20 | extern s32 Kalman_MaxDrift; |
21 | extern s32 Kalman_MaxFusion; |
21 | extern s32 Kalman_MaxFusion; |
22 | extern s32 ToFcGpsZ; |
22 | extern s32 ToFcGpsZ; |
23 | extern s32 ToFC_Rotate_C, ToFC_Rotate_S; |
23 | extern s32 ToFC_Rotate_C, ToFC_Rotate_S; |
24 | extern s32 HeadFreeStartAngle; |
24 | extern s32 HeadFreeStartAngle; |
25 | extern s16 FC_WP_EventChannel; |
25 | extern s16 FC_WP_EventChannel; |
26 | extern u32 ToFC_AltitudeRate; |
26 | extern u32 ToFC_AltitudeRate; |
27 | extern s32 ToFC_AltitudeSetpoint; |
27 | extern s32 ToFC_AltitudeSetpoint; |
28 | extern u8 NC_GPS_ModeCharacter; |
28 | extern u8 NC_GPS_ModeCharacter; |
29 | extern u8 FC_is_Calibrated; |
29 | extern u8 FC_is_Calibrated; |
30 | extern u8 FCCalibActive; |
30 | extern u8 FCCalibActive; |
31 | extern u8 MotorCurrent[12]; |
31 | extern u8 MotorCurrent[12]; |
32 | extern u8 MotorTemperature[12]; |
32 | extern u8 MotorTemperature[12]; |
33 | extern u8 BL_MinOfMaxPWM; // indication if all BL-controllers run on full power |
33 | extern u8 BL_MinOfMaxPWM; // indication if all BL-controllers run on full power |
34 | extern u32 FC_I2C_ErrorConter; |
34 | extern u32 FC_I2C_ErrorConter; |
35 | extern u8 FromFC_VarioCharacter; |
35 | extern u8 FromFC_VarioCharacter; |
36 | extern u8 Logging_FCStatusFlags1,Logging_FCStatusFlags2; |
36 | extern u8 Logging_FCStatusFlags1,Logging_FCStatusFlags2; |
37 | 37 | ||
38 | typedef struct |
38 | typedef struct |
39 | { |
39 | { |
40 | u8 Command; |
40 | u8 Command; |
41 | s16 AngleNick; // NickAngle in 0.1 deg |
41 | s16 AngleNick; // NickAngle in 0.1 deg |
42 | s16 AngleRoll; // RollAngle in 0.1 deg |
42 | s16 AngleRoll; // RollAngle in 0.1 deg |
43 | s16 AccNick; |
43 | s16 AccNick; |
44 | s16 AccRoll; |
44 | s16 AccRoll; |
45 | s16 GyroHeading; // Heading in 0.1 deg |
45 | s16 GyroHeading; // Heading in 0.1 deg |
46 | s16 GyroNick; |
46 | s16 GyroNick; |
47 | s16 GyroRoll; |
47 | s16 GyroRoll; |
48 | s16 GyroYaw; |
48 | s16 GyroYaw; |
49 | u16 FCStatus; |
49 | u16 FCStatus; |
50 | union |
50 | union |
51 | { |
51 | { |
52 | u8 Byte[12]; |
52 | u8 Byte[12]; |
53 | s8 sByte[12]; |
53 | s8 sByte[12]; |
54 | u16 Int[6]; |
54 | u16 Int[6]; |
55 | s16 sInt[6]; |
55 | s16 sInt[6]; |
56 | u32 Long[3]; |
56 | u32 Long[3]; |
57 | s32 sLong[3]; |
57 | s32 sLong[3]; |
58 | float Float[3]; |
58 | float Float[3]; |
59 | } Param; |
59 | } Param; |
60 | u8 Chksum; |
60 | u8 Chksum; |
61 | } __attribute__((packed)) FromFlightCtrl_t; |
61 | } __attribute__((packed)) FromFlightCtrl_t; |
62 | 62 | ||
63 | #define SPI_NCCMD_OSD_DATA 100 |
63 | #define SPI_NCCMD_OSD_DATA 100 |
64 | #define SPI_NCCMD_GPS_POS 101 |
64 | #define SPI_NCCMD_GPS_POS 101 |
65 | #define SPI_NCCMD_GPS_TARGET 102 |
65 | #define SPI_NCCMD_GPS_TARGET 102 |
66 | #define SPI_NCCMD_KALMAN 103 |
66 | #define SPI_NCCMD_KALMAN 103 |
67 | #define SPI_NCCMD_VERSION 104 |
67 | #define SPI_NCCMD_VERSION 104 |
68 | #define SPI_NCCMD_GPSINFO 105 |
68 | #define SPI_NCCMD_GPSINFO 105 |
69 | #define SPI_NCCMD_HOTT_INFO 106 |
69 | #define SPI_NCCMD_HOTT_INFO 106 |
- | 70 | #define SPI_MISC 107 |
|
70 | 71 | ||
71 | #define HOTT_VARIO_PACKET_ID 0x89 |
72 | #define HOTT_VARIO_PACKET_ID 0x89 |
72 | #define HOTT_GPS_PACKET_ID 0x8A |
73 | #define HOTT_GPS_PACKET_ID 0x8A |
73 | #define HOTT_ELECTRIC_AIR_PACKET_ID 0x8E |
74 | #define HOTT_ELECTRIC_AIR_PACKET_ID 0x8E |
74 | #define HOTT_GENERAL_PACKET_ID 0x8D |
75 | #define HOTT_GENERAL_PACKET_ID 0x8D |
75 | 76 | ||
76 | typedef struct |
77 | typedef struct |
77 | { |
78 | { |
78 | u8 Command; |
79 | u8 Command; |
79 | GPS_Stick_t GPSStick; |
80 | GPS_Stick_t GPSStick; |
80 | s16 CompassHeading; |
81 | s16 CompassHeading; |
81 | s16 AccErrorN; // s16 MagVecX; |
82 | s16 AccErrorN; // s16 MagVecX; |
82 | s16 AccErrorR; // s16 MagVecY; |
83 | s16 AccErrorR; // s16 MagVecY; |
83 | s16 MagVecZ; |
84 | s16 MagVecZ; |
84 | s16 NCStatus; |
85 | s16 NCStatus; |
85 | u16 BeepTime; |
86 | u16 BeepTime; |
86 | union |
87 | union |
87 | { |
88 | { |
88 | u8 Byte[12]; |
89 | u8 Byte[12]; |
89 | s8 sByte[12]; |
90 | s8 sByte[12]; |
90 | u16 Int[6]; |
91 | u16 Int[6]; |
91 | s16 sInt[6]; |
92 | s16 sInt[6]; |
92 | u32 Long[3]; |
93 | u32 Long[3]; |
93 | s32 sLong[3]; |
94 | s32 sLong[3]; |
94 | float Float[3]; |
95 | float Float[3]; |
95 | }Param; |
96 | }Param; |
96 | u8 Chksum; |
97 | u8 Chksum; |
97 | } __attribute__((packed)) ToFlightCtrl_t; |
98 | } __attribute__((packed)) ToFlightCtrl_t; |
98 | 99 | ||
99 | 100 | ||
100 | typedef struct |
101 | typedef struct |
101 | { |
102 | { |
102 | u8 Major; |
103 | u8 Major; |
103 | u8 Minor; |
104 | u8 Minor; |
104 | u8 Patch; |
105 | u8 Patch; |
105 | u8 Compatible; |
106 | u8 Compatible; |
106 | u8 Hardware; |
107 | u8 Hardware; |
107 | } __attribute__((packed)) SPI_Version_t; |
108 | } __attribute__((packed)) SPI_Version_t; |
108 | 109 | ||
109 | extern FromFlightCtrl_t FromFlightCtrl; |
110 | extern FromFlightCtrl_t FromFlightCtrl; |
110 | extern ToFlightCtrl_t ToFlightCtrl; |
111 | extern ToFlightCtrl_t ToFlightCtrl; |
111 | extern volatile u32 SPI0_Timeout; |
112 | extern volatile u32 SPI0_Timeout; |
112 | extern SPI_Version_t FC_Version; |
113 | extern SPI_Version_t FC_Version; |
113 | extern u8 GPS_Aid_StickMultiplikator; |
114 | extern u8 GPS_Aid_StickMultiplikator; |
114 | 115 | ||
115 | void SPI0_Init(void); |
116 | void SPI0_Init(void); |
116 | void SPI0_GetFlightCtrlVersion(void); |
117 | void SPI0_GetFlightCtrlVersion(void); |
117 | void SPI0_UpdateBuffer(void); |
118 | void SPI0_UpdateBuffer(void); |
118 | 119 | ||
119 | 120 | ||
120 | 121 | ||
121 | #endif //_SPI_SLAVE_H |
122 | #endif //_SPI_SLAVE_H |
122 | 123 |