Rev 1775 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1775 | Rev 1821 | ||
---|---|---|---|
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 | #define SPI_PROTOCOL_COMP 1 |
7 | #define SPI_PROTOCOL_COMP 1 |
8 | 8 | ||
9 | #define SPI_CMD_USER 10 |
9 | #define SPI_CMD_USER 10 |
10 | #define SPI_CMD_STICK 11 |
10 | #define SPI_CMD_STICK 11 |
11 | #define SPI_CMD_MISC 12 |
11 | #define SPI_CMD_MISC 12 |
12 | #define SPI_CMD_PARAMETER1 13 |
12 | #define SPI_CMD_PARAMETER1 13 |
13 | #define SPI_CMD_VERSION 14 |
13 | #define SPI_CMD_VERSION 14 |
14 | 14 | ||
15 | typedef struct { |
15 | typedef struct { |
16 | uint8_t Sync1; |
16 | uint8_t Sync1; |
17 | uint8_t Sync2; |
17 | uint8_t Sync2; |
18 | uint8_t Command; |
18 | uint8_t Command; |
19 | int16_t IntegralPitch; |
19 | int16_t IntegralPitch; |
20 | int16_t IntegralRoll; |
20 | int16_t IntegralRoll; |
21 | int16_t AccPitch; |
21 | int16_t AccPitch; |
22 | int16_t AccRoll; |
22 | int16_t AccRoll; |
23 | int16_t GyroHeading; |
23 | int16_t GyroHeading; |
24 | int16_t GyroPitch; |
24 | int16_t GyroPitch; |
25 | int16_t GyroRoll; |
25 | int16_t GyroRoll; |
26 | int16_t GyroYaw; |
26 | int16_t GyroYaw; |
27 | union { |
27 | union { |
28 | int8_t sByte[12]; |
28 | int8_t sByte[12]; |
29 | uint8_t Byte[12]; |
29 | uint8_t Byte[12]; |
30 | int16_t Int[6]; |
30 | int16_t Int[6]; |
31 | int32_t Long[3]; |
31 | int32_t Long[3]; |
32 | float Float[3]; |
32 | float Float[3]; |
33 | } Param; |
33 | } Param; |
34 | uint8_t Chksum; |
34 | uint8_t Chksum; |
35 | } __attribute__((packed)) ToNaviCtrl_t; |
35 | }__attribute__((packed)) ToNaviCtrl_t; |
36 | 36 | ||
37 | #define SPI_CMD_OSD_DATA 100 |
37 | #define SPI_CMD_OSD_DATA 100 |
38 | #define SPI_CMD_GPS_POS 101 |
38 | #define SPI_CMD_GPS_POS 101 |
39 | #define SPI_CMD_GPS_TARGET 102 |
39 | #define SPI_CMD_GPS_TARGET 102 |
40 | #define SPI_KALMAN 103 |
40 | #define SPI_KALMAN 103 |
41 | 41 | ||
42 | typedef struct { |
42 | typedef struct { |
43 | uint8_t Command; |
43 | uint8_t Command; |
44 | int16_t GPSStickPitch; |
44 | int16_t GPSStickPitch; |
45 | int16_t GPSStickRoll; |
45 | int16_t GPSStickRoll; |
46 | int16_t GPS_Yaw; |
46 | int16_t GPS_Yaw; |
47 | int16_t CompassHeading; |
47 | int16_t CompassHeading; |
48 | int16_t Status; |
48 | int16_t Status; |
49 | uint16_t BeepTime; |
49 | uint16_t BeepTime; |
50 | union { |
50 | union { |
51 | int8_t Byte[12]; |
51 | int8_t Byte[12]; |
52 | int16_t Int[6]; |
52 | int16_t Int[6]; |
53 | int32_t Long[3]; |
53 | int32_t Long[3]; |
54 | float Float[3]; |
54 | float Float[3]; |
55 | } Param; |
55 | } Param; |
56 | uint8_t Chksum; |
56 | uint8_t Chksum; |
57 | } __attribute__((packed)) FromNaviCtrl_t; |
57 | }__attribute__((packed)) FromNaviCtrl_t; |
58 | 58 | ||
59 | typedef struct { |
59 | typedef struct { |
60 | uint8_t Major; |
60 | uint8_t Major; |
61 | uint8_t Minor; |
61 | uint8_t Minor; |
62 | uint8_t Patch; |
62 | uint8_t Patch; |
63 | uint8_t Compatible; |
63 | uint8_t Compatible; |
64 | // unsigned char Hardware; |
64 | // unsigned char Hardware; |
65 | } __attribute__((packed)) SPI_VersionInfo_t; |
65 | }__attribute__((packed)) SPI_VersionInfo_t; |
66 | 66 | ||
67 | extern ToNaviCtrl_t toNaviCtrl; |
67 | extern ToNaviCtrl_t toNaviCtrl; |
68 | extern FromNaviCtrl_t fromNaviCtrl; |
68 | extern FromNaviCtrl_t fromNaviCtrl; |
69 | 69 | ||
70 | typedef struct { |
70 | typedef struct { |
71 | int8_t KalmanK; |
71 | int8_t KalmanK; |
72 | int8_t KalmanMaxDrift; |
72 | int8_t KalmanMaxDrift; |
73 | int8_t KalmanMaxFusion; |
73 | int8_t KalmanMaxFusion; |
74 | uint8_t SerialDataOkay; |
74 | uint8_t SerialDataOkay; |
75 | } __attribute__((packed)) NCData_t; |
75 | }__attribute__((packed)) NCData_t; |
76 | 76 | ||
77 | extern uint8_t NCDataOkay; |
77 | extern uint8_t NCDataOkay; |
78 | extern uint8_t NCSerialDataOkay; |
78 | extern uint8_t NCSerialDataOkay; |
79 | 79 | ||
80 | void SPI_MasterInit(void); |
80 | void SPI_MasterInit(void); |
81 | void SPI_StartTransmitPacket(void); |
81 | void SPI_StartTransmitPacket(void); |
82 | void SPI_TransmitByte(void); |
82 | void SPI_TransmitByte(void); |
83 | // new: |
83 | // new: |
84 | // extern void UpdateSPI_Buffer(void); |
84 | // extern void UpdateSPI_Buffer(void); |
85 | 85 | ||
86 | #endif //_SPI_H |
86 | #endif //_SPI_H |
87 | 87 |