Rev 27 | Rev 48 | Go to most recent revision | Details | Compare with Previous | 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_PROTOCOL_COMP 2 |
1 | ingob | 10 | |
41 | ingob | 11 | #define SPI_CMD_USER 10 |
12 | #define SPI_CMD_STICK 11 |
||
13 | #define SPI_CMD_MISC 12 |
||
14 | #define SPI_CMD_PARAMETER1 13 |
||
15 | #define SPI_CMD_VERSION 14 |
||
16 | |||
17 | extern s32 FC_Kalman_K; |
||
18 | extern s32 Kalman_MaxDrift; |
||
19 | extern s32 Kalman_MaxFusion; |
||
20 | typedef struct |
||
1 | ingob | 21 | { |
22 | u8 Command; |
||
23 | s16 IntegralNick; |
||
24 | s16 IntegralRoll; |
||
25 | s16 AccNick; |
||
26 | s16 AccRoll; |
||
41 | ingob | 27 | s16 GyroHeading; |
1 | ingob | 28 | s16 GyroNick; |
29 | s16 GyroRoll; |
||
41 | ingob | 30 | s16 GyroYaw; |
31 | union |
||
32 | { |
||
33 | s8 sByte[12]; |
||
34 | u8 Byte[12]; |
||
35 | s16 Int[6]; |
||
36 | s32 Long[3]; |
||
1 | ingob | 37 | float Float[3]; |
38 | } Param; |
||
39 | u8 Chksum; |
||
41 | ingob | 40 | } __attribute__((packed)) FromFlightCtrl_t; |
41 | |||
1 | ingob | 42 | #define SPI_CMD_OSD_DATA 100 |
43 | #define SPI_CMD_GPS_POS 101 |
||
44 | #define SPI_CMD_GPS_TARGET 102 |
||
41 | ingob | 45 | #define SPI_KALMAN 103 |
1 | ingob | 46 | |
41 | ingob | 47 | typedef struct |
48 | { |
||
49 | u8 Command; |
||
50 | s16 GPS_Nick; |
||
51 | s16 GPS_Roll; |
||
52 | s16 GPS_Yaw; |
||
53 | s16 CompassHeading; |
||
54 | s16 Status; |
||
55 | u16 BeepTime; |
||
56 | union |
||
57 | { |
||
58 | s8 sByte[12]; |
||
59 | u8 Byte[12]; |
||
60 | s16 Int[6]; |
||
61 | s32 Long[3]; |
||
62 | float Float[3]; |
||
63 | }Param; |
||
64 | u8 Chksum; |
||
65 | } __attribute__((packed)) ToFlightCtrl_t; |
||
1 | ingob | 66 | |
67 | |||
41 | ingob | 68 | typedef struct |
1 | ingob | 69 | { |
41 | ingob | 70 | u8 Major; |
71 | u8 Minor; |
||
72 | u8 Patch; |
||
73 | u8 Compatible; |
||
74 | } __attribute__((packed)) SPI_Version_t; |
||
1 | ingob | 75 | |
41 | ingob | 76 | extern volatile FromFlightCtrl_t FromFlightCtrl; |
77 | extern volatile ToFlightCtrl_t ToFlightCtrl; |
||
78 | extern SPI_Version_t FC_Version; |
||
79 | extern fifo_t CompassCalcStateFiFo; |
||
80 | extern u32 CheckSPIOkay; |
||
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 |