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