Rev 1231 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
827 | ingob | 1 | // ######################## SPI - FlightCtrl ################### |
2 | #ifndef _SPI_H |
||
3 | #define _SPI_H |
||
4 | |||
5 | #include <util/delay.h> |
||
6 | |||
1051 | killagreg | 7 | #define USE_SPI_COMMUNICATION |
827 | ingob | 8 | |
9 | #define SPI_PROTOCOL_COMP 1 |
||
10 | |||
11 | //----------------------------------------- |
||
12 | #define DDR_SPI DDRB |
||
13 | #define DD_SS PB4 |
||
14 | #define DD_SCK PB7 |
||
15 | #define DD_MOSI PB5 |
||
1051 | killagreg | 16 | #define DD_MISO PB6 |
827 | ingob | 17 | |
1051 | killagreg | 18 | // for compatibility reasons gcc3.x <-> gcc4.x |
19 | #ifndef SPCR |
||
827 | ingob | 20 | #define SPCR SPCR0 |
1051 | killagreg | 21 | #endif |
22 | #ifndef SPE |
||
827 | ingob | 23 | #define SPE SPE0 |
1051 | killagreg | 24 | #endif |
25 | #ifndef MSTR |
||
827 | ingob | 26 | #define MSTR MSTR0 |
1051 | killagreg | 27 | #endif |
28 | #ifndef SPR1 |
||
827 | ingob | 29 | #define SPR1 SPR01 |
1051 | killagreg | 30 | #endif |
31 | #ifndef SPR0 |
||
827 | ingob | 32 | #define SPR0 SPR00 |
1051 | killagreg | 33 | #endif |
34 | #ifndef SPIE |
||
827 | ingob | 35 | #define SPIE SPIE0 |
1051 | killagreg | 36 | #endif |
37 | #ifndef SPDR |
||
827 | ingob | 38 | #define SPDR SPDR0 |
1051 | killagreg | 39 | #endif |
40 | #ifndef SPIF |
||
827 | ingob | 41 | #define SPIF SPIF0 |
1051 | killagreg | 42 | #endif |
43 | #ifndef SPSR |
||
827 | ingob | 44 | #define SPSR SPSR0 |
1051 | killagreg | 45 | #endif |
827 | ingob | 46 | // ------------------------- |
47 | |||
48 | #define SLAVE_SELECT_DDR_PORT DDRC |
||
49 | #define SLAVE_SELECT_PORT PORTC |
||
50 | #define SPI_SLAVE_SELECT PC5 |
||
51 | |||
52 | |||
53 | #define SPI_CMD_USER 10 |
||
54 | #define SPI_CMD_STICK 11 |
||
1036 | hbuss | 55 | #define SPI_CMD_MISC 12 |
921 | hbuss | 56 | #define SPI_CMD_PARAMETER1 13 |
991 | ingob | 57 | #define SPI_CMD_VERSION 14 |
1241 | killagreg | 58 | #define SPI_CMD_SERVOS 15 |
991 | ingob | 59 | |
827 | ingob | 60 | struct str_ToNaviCtrl |
61 | { |
||
1231 | killagreg | 62 | unsigned char Sync1, Sync2; |
63 | unsigned char Command; |
||
64 | signed int IntegralNick; |
||
65 | signed int IntegralRoll; |
||
66 | signed int AccNick; |
||
67 | signed int AccRoll; |
||
68 | signed int GyroCompass; |
||
69 | signed int GyroNick; |
||
70 | signed int GyroRoll; |
||
71 | signed int GyroGier; |
||
72 | union |
||
73 | { |
||
74 | char sByte[12]; |
||
75 | unsigned char Byte[12]; |
||
76 | int Int[6]; |
||
77 | long Long[3]; |
||
78 | float Float[3]; |
||
79 | } Param; |
||
80 | unsigned char Chksum; |
||
1051 | killagreg | 81 | }; |
827 | ingob | 82 | |
1231 | killagreg | 83 | #define SPI_KALMAN 103 |
1241 | killagreg | 84 | |
827 | ingob | 85 | struct str_FromNaviCtrl |
86 | { |
||
1231 | killagreg | 87 | unsigned char Command; |
88 | signed int GPS_Nick; |
||
89 | signed int GPS_Roll; |
||
90 | signed int GPS_Gier; |
||
91 | signed int CompassValue; |
||
92 | signed int Status; |
||
93 | unsigned int BeepTime; |
||
94 | union |
||
95 | { |
||
96 | char sByte[12]; |
||
97 | unsigned char Byte[12]; |
||
98 | int Int[6]; |
||
99 | long Long[3]; |
||
100 | float Float[3]; |
||
101 | } Param; |
||
102 | unsigned char Chksum; |
||
1051 | killagreg | 103 | }; |
827 | ingob | 104 | |
978 | hbuss | 105 | struct str_FromNaviCtrl_Value |
106 | { |
||
992 | hbuss | 107 | signed char Kalman_K; |
108 | signed char Kalman_MaxDrift; |
||
109 | signed char Kalman_MaxFusion; |
||
1215 | hbuss | 110 | unsigned char SerialDataOkay; |
978 | hbuss | 111 | }; |
827 | ingob | 112 | |
1051 | killagreg | 113 | struct str_SPI_VersionInfo |
114 | { |
||
115 | unsigned char Major; |
||
116 | unsigned char Minor; |
||
117 | unsigned char Patch; |
||
118 | unsigned char Compatible; |
||
119 | }; |
||
120 | |||
827 | ingob | 121 | #ifdef USE_SPI_COMMUNICATION |
122 | |||
978 | hbuss | 123 | extern struct str_FromNaviCtrl_Value FromNaviCtrl_Value; |
827 | ingob | 124 | extern struct str_ToNaviCtrl ToNaviCtrl; |
125 | extern struct str_FromNaviCtrl FromNaviCtrl; |
||
1215 | hbuss | 126 | extern unsigned char SPI_CommandCounter,NaviDataOkay; |
827 | ingob | 127 | |
128 | //#define SPI_CMD_VALUE 0x03 |
||
129 | |||
130 | extern void SPI_MasterInit(void); |
||
131 | extern void SPI_StartTransmitPacket(void); |
||
132 | extern void UpdateSPI_Buffer(void); |
||
133 | extern void SPI_TransmitByte(void); |
||
134 | #else |
||
135 | |||
136 | |||
137 | // -------------------------------- Dummy ----------------------------------------- |
||
1051 | killagreg | 138 | #define SPI_MasterInit() ; |
827 | ingob | 139 | #define SPI_StartTransmitPacket() ; |
140 | #define UpdateSPI_Buffer() ; |
||
141 | #define SPI_TransmitByte() ; |
||
142 | #endif |
||
143 | |||
144 | |||
145 | #endif |