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