Rev 1 | Rev 41 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 27 | ||
---|---|---|---|
1 | #ifndef _SPI_H |
1 | #ifndef _SPI_H |
2 | #define _SPI_H |
2 | #define _SPI_H |
3 | 3 | ||
4 | #define SPI_PROTOCOL_COMP 1 |
4 | #define SPI_PROTOCOL_COMP 1 |
5 | - | ||
6 | 5 | ||
7 | #define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7) |
6 | #define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7) |
8 | 7 | ||
9 | // IMPORTANT: no syncbytes in structure ! |
8 | // IMPORTANT: no syncbytes in structure ! |
10 | #define SPI_CMD_USER 10 |
9 | #define SPI_CMD_USER 10 |
11 | #define SPI_CMD_STICK 11 |
10 | #define SPI_CMD_STICK 11 |
12 | #define SPI_CMD_CAL_COMPASS 12 |
11 | #define SPI_CMD_CAL_COMPASS 12 |
- | 12 | #define SPI_CMD_PARAMETER1 13 |
|
13 | 13 | ||
14 | struct str_FromFlightCtrl |
14 | struct str_FromFlightCtrl |
15 | { |
15 | { |
16 | u8 Command; |
16 | u8 Command; |
17 | s16 IntegralNick; |
17 | s16 IntegralNick; |
18 | s16 IntegralRoll; |
18 | s16 IntegralRoll; |
19 | s16 AccNick; |
19 | s16 AccNick; |
20 | s16 AccRoll; |
20 | s16 AccRoll; |
21 | s16 GyroCompass; |
21 | s16 GyroCompass; |
22 | s16 GyroNick; |
22 | s16 GyroNick; |
23 | s16 GyroRoll; |
23 | s16 GyroRoll; |
24 | s16 GyroGier; |
24 | s16 GyroGier; |
25 | union |
25 | union |
26 | { u8 Byte[12]; |
26 | { u8 Byte[12]; |
27 | s8 sByte[12]; |
27 | s8 sByte[12]; |
28 | s16 Int[6]; |
28 | s16 Int[6]; |
29 | float Float[3]; |
29 | float Float[3]; |
30 | int Long[3]; |
30 | int Long[3]; |
31 | } Param; |
31 | } Param; |
32 | u8 Chksum; |
32 | u8 Chksum; |
33 | } __attribute__((packed)); |
33 | } __attribute__((packed)); |
34 | 34 | ||
35 | #define SPI_CMD_OSD_DATA 100 |
35 | #define SPI_CMD_OSD_DATA 100 |
36 | #define SPI_CMD_GPS_POS 101 |
36 | #define SPI_CMD_GPS_POS 101 |
37 | #define SPI_CMD_GPS_TARGET 102 |
37 | #define SPI_CMD_GPS_TARGET 102 |
38 | 38 | ||
39 | struct str_ToFlightCtrl |
39 | struct str_ToFlightCtrl |
40 | { |
40 | { |
41 | unsigned char Sync1, Sync2; |
41 | unsigned char Sync1, Sync2; |
42 | unsigned char Command; |
42 | unsigned char Command; |
43 | s16 GPS_Nick; |
43 | s16 GPS_Nick; |
44 | s16 GPS_Roll; |
44 | s16 GPS_Roll; |
45 | s16 GPS_Gier; |
45 | s16 GPS_Gier; |
46 | s16 CompassValue; |
46 | s16 CompassValue; |
47 | s16 Status; |
47 | s16 Status; |
48 | unsigned char BeepTime; |
48 | unsigned char BeepTime; |
49 | union |
49 | union |
50 | { u8 Byte[12]; |
50 | { u8 Byte[12]; |
51 | s16 Int[6]; |
51 | s16 Int[6]; |
52 | float Float[3]; |
52 | float Float[3]; |
53 | int Long[3]; |
53 | int Long[3]; |
54 | } Param; |
54 | } Param; |
55 | unsigned char Chksum; |
55 | unsigned char Chksum; |
56 | } __attribute__((packed)); |
56 | } __attribute__((packed)); |
57 | 57 | ||
58 | 58 | ||
59 | #define X_AXIS 1 |
59 | #define X_AXIS 1 |
60 | #define Y_AXIS 2 |
60 | #define Y_AXIS 2 |
61 | #define Z_AXIS 3 |
61 | #define Z_AXIS 3 |
62 | 62 | ||
63 | 63 | ||
64 | 64 | ||
65 | struct str_MicroMag |
65 | struct str_MicroMag |
66 | { |
66 | { |
67 | unsigned char ReadAxis, WaitingforMeasurement; |
67 | unsigned char ReadAxis, WaitingforMeasurement; |
68 | s16 Axis[3]; |
68 | s16 Axis[3]; |
69 | s16 Heading; |
69 | s16 Heading; |
70 | } __attribute__((packed)); |
70 | } __attribute__((packed)); |
71 | 71 | ||
72 | 72 | ||
73 | extern struct str_FromFlightCtrl FromFlightCtrl; |
73 | extern struct str_FromFlightCtrl FromFlightCtrl; |
74 | extern struct str_ToFlightCtrl ToFlightCtrl; |
74 | extern struct str_ToFlightCtrl ToFlightCtrl; |
75 | 75 | ||
76 | extern volatile struct str_MicroMag MicroMag; |
76 | extern volatile struct str_MicroMag MicroMag; |
77 | 77 | ||
78 | extern s16 GPS_Nick, GPS_Roll, CompassValue; |
78 | extern s16 GPS_Nick, GPS_Roll, CompassValue; |
79 | 79 | ||
80 | extern void SPI0_Init(void); |
80 | extern void SPI0_Init(void); |
81 | extern void SPI_CheckSlaveSelect(void); |
81 | extern void SPI_CheckSlaveSelect(void); |
82 | extern void UpdateSPI_Buffer(void); |
82 | extern void UpdateSPI_Buffer(void); |
83 | #endif |
83 | #endif |
84 | 84 |