Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1538 | killagreg | 1 | // ######################## SPI - FlightCtrl ################### |
2 | #ifndef _SPI_H |
||
3 | #define _SPI_H |
||
4 | |||
5 | //#include <util/delay.h> |
||
6 | #include <inttypes.h> |
||
7 | |||
8 | |||
9 | #define SPI_PROTOCOL_COMP 1 |
||
10 | |||
11 | |||
12 | #define SPI_CMD_USER 10 |
||
13 | #define SPI_CMD_STICK 11 |
||
14 | #define SPI_CMD_MISC 12 |
||
15 | #define SPI_CMD_PARAMETER1 13 |
||
16 | #define SPI_CMD_VERSION 14 |
||
17 | #define SPI_CMD_SERVOS 15 |
||
18 | |||
19 | typedef struct |
||
20 | { |
||
21 | uint8_t Sync1; |
||
22 | uint8_t Sync2; |
||
23 | uint8_t Command; |
||
24 | int16_t IntegralNick; |
||
25 | int16_t IntegralRoll; |
||
26 | int16_t AccNick; |
||
27 | int16_t AccRoll; |
||
28 | int16_t GyroHeading; |
||
29 | int16_t GyroNick; |
||
30 | int16_t GyroRoll; |
||
31 | int16_t GyroYaw; |
||
32 | union |
||
33 | { |
||
34 | int8_t sByte[12]; |
||
35 | uint8_t Byte[12]; |
||
36 | int16_t Int[6]; |
||
37 | int32_t Long[3]; |
||
38 | float Float[3]; |
||
39 | } Param; |
||
40 | uint8_t Chksum; |
||
41 | } __attribute__((packed)) ToNaviCtrl_t; |
||
42 | |||
43 | |||
44 | |||
45 | #define SPI_CMD_OSD_DATA 100 |
||
46 | #define SPI_CMD_GPS_POS 101 |
||
47 | #define SPI_CMD_GPS_TARGET 102 |
||
48 | #define SPI_KALMAN 103 |
||
49 | |||
50 | typedef struct |
||
51 | { |
||
52 | uint8_t Command; |
||
53 | int16_t GPSStickNick; |
||
54 | int16_t GPSStickRoll; |
||
55 | int16_t GPS_Yaw; |
||
56 | int16_t CompassHeading; |
||
57 | int16_t Status; |
||
58 | uint16_t BeepTime; |
||
59 | union |
||
60 | { |
||
61 | int8_t sByte[12]; |
||
62 | uint8_t Byte[12]; |
||
63 | int16_t Int[6]; |
||
64 | int32_t Long[3]; |
||
65 | float Float[3]; |
||
66 | } Param; |
||
67 | uint8_t Chksum; |
||
68 | } __attribute__((packed)) FromNaviCtrl_t; |
||
69 | |||
70 | |||
71 | typedef struct |
||
72 | { |
||
73 | uint8_t Major; |
||
74 | uint8_t Minor; |
||
75 | uint8_t Patch; |
||
76 | uint8_t Compatible; |
||
77 | } __attribute__((packed)) SPI_VersionInfo_t; |
||
78 | |||
79 | |||
80 | extern ToNaviCtrl_t ToNaviCtrl; |
||
81 | extern FromNaviCtrl_t FromNaviCtrl; |
||
82 | |||
83 | |||
84 | typedef struct |
||
85 | { |
||
86 | int8_t KalmanK; |
||
87 | int8_t KalmanMaxDrift; |
||
88 | int8_t KalmanMaxFusion; |
||
89 | uint8_t SerialDataOkay; |
||
90 | } __attribute__((packed)) NCData_t; |
||
91 | |||
92 | |||
93 | extern uint8_t NCDataOkay; |
||
94 | extern uint8_t NCSerialDataOkay; |
||
95 | extern int8_t NCGpsZ; |
||
96 | |||
97 | void SPI_MasterInit(void); |
||
98 | void SPI_StartTransmitPacket(void); |
||
99 | void SPI_TransmitByte(void); |
||
100 | |||
101 | |||
102 | |||
103 | #endif //_SPI_H |