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