Rev 1283 | Rev 1451 | 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 | //----------------------------------------- |
||
10 | #define DDR_SPI DDRB |
||
11 | #define DD_SS PB4 |
||
12 | #define DD_SCK PB7 |
||
13 | #define DD_MOSI PB5 |
||
1051 | killagreg | 14 | #define DD_MISO PB6 |
827 | ingob | 15 | |
1051 | killagreg | 16 | // for compatibility reasons gcc3.x <-> gcc4.x |
17 | #ifndef SPCR |
||
827 | ingob | 18 | #define SPCR SPCR0 |
1051 | killagreg | 19 | #endif |
20 | #ifndef SPE |
||
827 | ingob | 21 | #define SPE SPE0 |
1051 | killagreg | 22 | #endif |
23 | #ifndef MSTR |
||
827 | ingob | 24 | #define MSTR MSTR0 |
1051 | killagreg | 25 | #endif |
26 | #ifndef SPR1 |
||
827 | ingob | 27 | #define SPR1 SPR01 |
1051 | killagreg | 28 | #endif |
29 | #ifndef SPR0 |
||
827 | ingob | 30 | #define SPR0 SPR00 |
1051 | killagreg | 31 | #endif |
32 | #ifndef SPIE |
||
827 | ingob | 33 | #define SPIE SPIE0 |
1051 | killagreg | 34 | #endif |
35 | #ifndef SPDR |
||
827 | ingob | 36 | #define SPDR SPDR0 |
1051 | killagreg | 37 | #endif |
38 | #ifndef SPIF |
||
827 | ingob | 39 | #define SPIF SPIF0 |
1051 | killagreg | 40 | #endif |
41 | #ifndef SPSR |
||
827 | ingob | 42 | #define SPSR SPSR0 |
1051 | killagreg | 43 | #endif |
827 | ingob | 44 | // ------------------------- |
45 | |||
46 | #define SLAVE_SELECT_DDR_PORT DDRC |
||
47 | #define SLAVE_SELECT_PORT PORTC |
||
48 | #define SPI_SLAVE_SELECT PC5 |
||
49 | |||
50 | |||
1448 | killagreg | 51 | #define SPI_FCCMD_USER 10 |
52 | #define SPI_FCCMD_STICK 11 |
||
53 | #define SPI_FCCMD_MISC 12 |
||
54 | #define SPI_FCCMD_PARAMETER1 13 |
||
55 | #define SPI_FCCMD_VERSION 14 |
||
56 | #define SPI_FCCMD_SERVOS 15 |
||
991 | ingob | 57 | |
827 | ingob | 58 | struct str_ToNaviCtrl |
59 | { |
||
1231 | killagreg | 60 | unsigned char Sync1, Sync2; |
61 | unsigned char Command; |
||
62 | signed int IntegralNick; |
||
63 | signed int IntegralRoll; |
||
64 | signed int AccNick; |
||
65 | signed int AccRoll; |
||
66 | signed int GyroCompass; |
||
67 | signed int GyroNick; |
||
68 | signed int GyroRoll; |
||
69 | signed int GyroGier; |
||
70 | union |
||
71 | { |
||
72 | char sByte[12]; |
||
73 | unsigned char Byte[12]; |
||
74 | int Int[6]; |
||
75 | long Long[3]; |
||
76 | float Float[3]; |
||
77 | } Param; |
||
78 | unsigned char Chksum; |
||
1051 | killagreg | 79 | }; |
827 | ingob | 80 | |
1448 | killagreg | 81 | #define SPI_NCCMD_KALMAN 103 |
82 | #define SPI_NCCMD_VERSION 104 |
||
1241 | killagreg | 83 | |
827 | ingob | 84 | struct str_FromNaviCtrl |
85 | { |
||
1231 | killagreg | 86 | unsigned char Command; |
87 | signed int GPS_Nick; |
||
88 | signed int GPS_Roll; |
||
89 | signed int GPS_Gier; |
||
90 | signed int CompassValue; |
||
91 | signed int Status; |
||
92 | unsigned int BeepTime; |
||
93 | union |
||
94 | { |
||
95 | char sByte[12]; |
||
96 | unsigned char Byte[12]; |
||
97 | int Int[6]; |
||
98 | long Long[3]; |
||
99 | float Float[3]; |
||
100 | } Param; |
||
101 | unsigned char Chksum; |
||
1051 | killagreg | 102 | }; |
827 | ingob | 103 | |
978 | hbuss | 104 | struct str_FromNaviCtrl_Value |
105 | { |
||
992 | hbuss | 106 | signed char Kalman_K; |
107 | signed char Kalman_MaxDrift; |
||
108 | signed char Kalman_MaxFusion; |
||
1215 | hbuss | 109 | unsigned char SerialDataOkay; |
1283 | hbuss | 110 | signed char GpsZ; |
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; |
||
1448 | killagreg | 119 | unsigned char Hardware; |
1051 | killagreg | 120 | }; |
121 | |||
827 | ingob | 122 | #ifdef USE_SPI_COMMUNICATION |
123 | |||
1448 | killagreg | 124 | extern struct str_SPI_VersionInfo NC_Version; |
978 | hbuss | 125 | extern struct str_FromNaviCtrl_Value FromNaviCtrl_Value; |
827 | ingob | 126 | extern struct str_ToNaviCtrl ToNaviCtrl; |
127 | extern struct str_FromNaviCtrl FromNaviCtrl; |
||
1215 | hbuss | 128 | extern unsigned char SPI_CommandCounter,NaviDataOkay; |
827 | ingob | 129 | |
130 | //#define SPI_CMD_VALUE 0x03 |
||
131 | |||
132 | extern void SPI_MasterInit(void); |
||
133 | extern void SPI_StartTransmitPacket(void); |
||
134 | extern void UpdateSPI_Buffer(void); |
||
135 | extern void SPI_TransmitByte(void); |
||
136 | #else |
||
137 | |||
138 | |||
139 | // -------------------------------- Dummy ----------------------------------------- |
||
1051 | killagreg | 140 | #define SPI_MasterInit() ; |
827 | ingob | 141 | #define SPI_StartTransmitPacket() ; |
142 | #define UpdateSPI_Buffer() ; |
||
143 | #define SPI_TransmitByte() ; |
||
144 | #endif |
||
145 | |||
146 | |||
147 | #endif |