Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
41 | ingob | 1 | #ifndef _SPI_SLAVE_H |
2 | #define _SPI_SLAVE_H |
||
1 | ingob | 3 | |
41 | ingob | 4 | #include "fifo.h" |
1 | ingob | 5 | |
41 | ingob | 6 | |
1 | ingob | 7 | #define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7) |
8 | |||
41 | ingob | 9 | #define SPI_CMD_USER 10 |
10 | #define SPI_CMD_STICK 11 |
||
11 | #define SPI_CMD_MISC 12 |
||
12 | #define SPI_CMD_PARAMETER1 13 |
||
13 | #define SPI_CMD_VERSION 14 |
||
121 | killagreg | 14 | #define SPI_CMD_SERVOS 15 |
41 | ingob | 15 | |
149 | killagreg | 16 | extern s32 Kalman_K; |
41 | ingob | 17 | extern s32 Kalman_MaxDrift; |
18 | extern s32 Kalman_MaxFusion; |
||
148 | holgerb | 19 | extern s32 ToFcGpsZ; |
118 | killagreg | 20 | |
41 | ingob | 21 | typedef struct |
118 | killagreg | 22 | { |
23 | u8 Command; |
||
24 | s16 AngleNick; // NickAngle in 0.1 deg |
||
25 | s16 AngleRoll; // RollAngle in 0.1 deg |
||
26 | s16 AccNick; |
||
27 | s16 AccRoll; |
||
28 | s16 GyroHeading; // Heading in 0.1 deg |
||
29 | s16 GyroNick; |
||
30 | s16 GyroRoll; |
||
31 | s16 GyroYaw; |
||
32 | union |
||
33 | { |
||
34 | s8 sByte[12]; |
||
35 | u8 Byte[12]; |
||
36 | s16 Int[6]; |
||
37 | s32 Long[3]; |
||
38 | float Float[3]; |
||
39 | } Param; |
||
40 | u8 Chksum; |
||
41 | ingob | 41 | } __attribute__((packed)) FromFlightCtrl_t; |
42 | |||
1 | ingob | 43 | |
118 | killagreg | 44 | #define SPI_KALMAN 103 |
45 | |||
41 | ingob | 46 | typedef struct |
47 | { |
||
48 | u8 Command; |
||
49 | s16 GPS_Nick; |
||
50 | s16 GPS_Roll; |
||
51 | s16 GPS_Yaw; |
||
52 | s16 CompassHeading; |
||
53 | s16 Status; |
||
54 | u16 BeepTime; |
||
55 | union |
||
56 | { |
||
57 | s8 sByte[12]; |
||
58 | u8 Byte[12]; |
||
59 | s16 Int[6]; |
||
60 | s32 Long[3]; |
||
61 | float Float[3]; |
||
62 | }Param; |
||
63 | u8 Chksum; |
||
64 | } __attribute__((packed)) ToFlightCtrl_t; |
||
1 | ingob | 65 | |
66 | |||
41 | ingob | 67 | typedef struct |
1 | ingob | 68 | { |
41 | ingob | 69 | u8 Major; |
70 | u8 Minor; |
||
71 | u8 Patch; |
||
72 | u8 Compatible; |
||
61 | holgerb | 73 | u8 Hardware; |
41 | ingob | 74 | } __attribute__((packed)) SPI_Version_t; |
1 | ingob | 75 | |
41 | ingob | 76 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
77 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
||
146 | killagreg | 78 | extern volatile u32 SPI0_Timeout; |
41 | ingob | 79 | extern SPI_Version_t FC_Version; |
80 | extern fifo_t CompassCalcStateFiFo; |
||
1 | ingob | 81 | |
41 | ingob | 82 | void SPI0_Init(void); |
83 | void SPI0_GetFlightCtrlVersion(void); |
||
84 | void SPI0_UpdateBuffer(void); |
||
1 | ingob | 85 | |
86 | |||
87 | |||
41 | ingob | 88 | #endif //_SPI_SLAVE_H |