Rev 2179 | Rev 2190 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2179 | Rev 2183 | ||
---|---|---|---|
1 | // ######################## SPI - FlightCtrl ################### |
1 | // ######################## SPI - FlightCtrl ################### |
2 | #include "main.h" |
2 | #include "main.h" |
3 | #include "eeprom.h" |
3 | #include "eeprom.h" |
4 | 4 | ||
5 | //struct str_ToNaviCtrl_Version ToNaviCtrl_Version; |
5 | //struct str_ToNaviCtrl_Version ToNaviCtrl_Version; |
6 | //struct str_FromNaviCtrl_Version FromNaviCtrl_Version; |
6 | //struct str_FromNaviCtrl_Version FromNaviCtrl_Version; |
7 | struct str_ToNaviCtrl ToNaviCtrl; |
7 | struct str_ToNaviCtrl ToNaviCtrl; |
8 | struct str_FromNaviCtrl FromNaviCtrl; |
8 | struct str_FromNaviCtrl FromNaviCtrl; |
9 | struct str_FromNaviCtrl_Value FromNaviCtrl_Value; |
9 | struct str_FromNaviCtrl_Value FromNaviCtrl_Value; |
10 | struct str_SPI_VersionInfo NC_Version; |
10 | struct str_SPI_VersionInfo NC_Version; |
11 | struct str_GPSInfo GPSInfo; |
11 | struct str_GPSInfo GPSInfo; |
12 | 12 | ||
13 | unsigned char SPI_BufferIndex; |
13 | unsigned char SPI_BufferIndex; |
14 | unsigned char SPI_RxBufferIndex; |
14 | unsigned char SPI_RxBufferIndex; |
15 | signed char FromNC_Rotate_C = 32, FromNC_Rotate_S = 0; |
15 | signed char FromNC_Rotate_C = 32, FromNC_Rotate_S = 0; |
16 | 16 | ||
17 | volatile unsigned char SPI_Buffer[sizeof(FromNaviCtrl)]; |
17 | volatile unsigned char SPI_Buffer[sizeof(FromNaviCtrl)]; |
18 | unsigned char *SPI_TX_Buffer; |
18 | unsigned char *SPI_TX_Buffer; |
19 | 19 | ||
20 | unsigned char SPITransferCompleted, SPI_ChkSum; |
20 | unsigned char SPITransferCompleted, SPI_ChkSum; |
21 | unsigned char SPI_RxDataValid,NaviDataOkay = 250; |
21 | unsigned char SPI_RxDataValid,NaviDataOkay = 250; |
22 | 22 | ||
- | 23 | unsigned char SPI_CommandSequence[] = { SPI_FCCMD_STICK, SPI_FCCMD_USER, SPI_FCCMD_PARAMETER1, |
|
- | 24 | SPI_FCCMD_STICK, SPI_FCCMD_MISC, SPI_FCCMD_VERSION, |
|
- | 25 | SPI_FCCMD_STICK, SPI_FCCMD_SERVOS, SPI_FCCMD_ACCU, |
|
- | 26 | SPI_FCCMD_STICK, SPI_FCCMD_PARAMETER2 |
|
23 | unsigned char SPI_CommandSequence[] = {SPI_FCCMD_STICK, SPI_FCCMD_USER, SPI_FCCMD_PARAMETER1, SPI_FCCMD_STICK, SPI_FCCMD_MISC, SPI_FCCMD_VERSION, SPI_FCCMD_STICK, SPI_FCCMD_SERVOS, SPI_FCCMD_ACCU}; |
27 | }; |
24 | unsigned char SPI_CommandCounter = 0; |
28 | unsigned char SPI_CommandCounter = 0; |
25 | unsigned char NC_ErrorCode = 0; |
29 | unsigned char NC_ErrorCode = 0; |
26 | unsigned char NC_GPS_ModeCharacter = ' '; |
30 | unsigned char NC_GPS_ModeCharacter = ' '; |
27 | unsigned char EarthMagneticField = 0; |
31 | unsigned char EarthMagneticField = 0; |
28 | unsigned char EarthMagneticInclination = 0, EarthMagneticInclinationTheoretic = 0; |
32 | unsigned char EarthMagneticInclination = 0, EarthMagneticInclinationTheoretic = 0; |
29 | unsigned char NC_To_FC_Flags = 0; |
33 | unsigned char NC_To_FC_Flags = 0; |
30 | unsigned char NC_To_FC_MaxAltitude = 0; // this is a Parameter on the SD-card |
34 | unsigned char NC_To_FC_MaxAltitude = 0; // this is a Parameter on the SD-card |
31 | signed int POI_KameraNick = 0; // in 0,1° |
35 | signed int POI_KameraNick = 0; // in 0,1° |
32 | vector16_t MagVec = {0,0,0}; |
36 | vector16_t MagVec = {0,0,0}; |
33 | 37 | ||
34 | #ifdef USE_SPI_COMMUNICATION |
38 | #ifdef USE_SPI_COMMUNICATION |
35 | 39 | ||
36 | //------------------------------------------------------ |
40 | //------------------------------------------------------ |
37 | void SPI_MasterInit(void) |
41 | void SPI_MasterInit(void) |
38 | { |
42 | { |
39 | DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK); // Set MOSI and SCK output, all others input |
43 | DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK); // Set MOSI and SCK output, all others input |
40 | SLAVE_SELECT_DDR_PORT |= (1 << SPI_SLAVE_SELECT); |
44 | SLAVE_SELECT_DDR_PORT |= (1 << SPI_SLAVE_SELECT); |
41 | 45 | ||
42 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(0<<SPR0)|(0<<SPIE); // Enable SPI, Master, set clock rate fck/64 |
46 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(0<<SPR0)|(0<<SPIE); // Enable SPI, Master, set clock rate fck/64 |
43 | SPSR = 0;//(1<<SPI2X); |
47 | SPSR = 0;//(1<<SPI2X); |
44 | 48 | ||
45 | SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); |
49 | SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); |
46 | SPITransferCompleted = 1; |
50 | SPITransferCompleted = 1; |
47 | 51 | ||
48 | //SPDR = 0x00; // dummy write |
52 | //SPDR = 0x00; // dummy write |
49 | 53 | ||
50 | ToNaviCtrl.Sync1 = 0xAA; |
54 | ToNaviCtrl.Sync1 = 0xAA; |
51 | ToNaviCtrl.Sync2 = 0x83; |
55 | ToNaviCtrl.Sync2 = 0x83; |
52 | 56 | ||
53 | ToNaviCtrl.Command = SPI_FCCMD_USER; |
57 | ToNaviCtrl.Command = SPI_FCCMD_USER; |
54 | ToNaviCtrl.IntegralNick = 0; |
58 | ToNaviCtrl.IntegralNick = 0; |
55 | ToNaviCtrl.IntegralRoll = 0; |
59 | ToNaviCtrl.IntegralRoll = 0; |
56 | FromNaviCtrl_Value.SerialDataOkay = 0; |
60 | FromNaviCtrl_Value.SerialDataOkay = 0; |
57 | SPI_RxDataValid = 0; |
61 | SPI_RxDataValid = 0; |
58 | 62 | ||
59 | } |
63 | } |
60 | 64 | ||
61 | //------------------------------------------------------ |
65 | //------------------------------------------------------ |
62 | void SPI_StartTransmitPacket(void) |
66 | void SPI_StartTransmitPacket(void) |
63 | { |
67 | { |
64 | //if ((SLAVE_SELECT_PORT & (1 << SPI_SLAVE_SELECT)) == 0) return; // transfer of prev. packet not completed |
68 | //if ((SLAVE_SELECT_PORT & (1 << SPI_SLAVE_SELECT)) == 0) return; // transfer of prev. packet not completed |
65 | if (!SPITransferCompleted) return; |
69 | if (!SPITransferCompleted) return; |
66 | // _delay_us(30); |
70 | // _delay_us(30); |
67 | 71 | ||
68 | SLAVE_SELECT_PORT &= ~(1 << SPI_SLAVE_SELECT); // SelectSlave |
72 | SLAVE_SELECT_PORT &= ~(1 << SPI_SLAVE_SELECT); // SelectSlave |
69 | SPI_TX_Buffer = (unsigned char *) &ToNaviCtrl; |
73 | SPI_TX_Buffer = (unsigned char *) &ToNaviCtrl; |
70 | 74 | ||
71 | ToNaviCtrl.Command = SPI_CommandSequence[SPI_CommandCounter++]; |
75 | ToNaviCtrl.Command = SPI_CommandSequence[SPI_CommandCounter++]; |
72 | if (SPI_CommandCounter >= sizeof(SPI_CommandSequence)) SPI_CommandCounter = 0; |
76 | if (SPI_CommandCounter >= sizeof(SPI_CommandSequence)) SPI_CommandCounter = 0; |
73 | 77 | ||
74 | SPITransferCompleted = 0; |
78 | SPITransferCompleted = 0; |
75 | UpdateSPI_Buffer(); // update buffer |
79 | UpdateSPI_Buffer(); // update buffer |
76 | 80 | ||
77 | SPI_BufferIndex = 1; |
81 | SPI_BufferIndex = 1; |
78 | //ebugOut.Analog[16]++; |
- | |
79 | // -- Debug-Output --- |
82 | // -- Debug-Output --- |
80 | //---- |
83 | //---- |
81 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
84 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
82 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
85 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
83 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
86 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
84 | ToNaviCtrl.Chksum = ToNaviCtrl.Sync1; |
87 | ToNaviCtrl.Chksum = ToNaviCtrl.Sync1; |
85 | SPDR = ToNaviCtrl.Sync1; // Start transmission |
88 | SPDR = ToNaviCtrl.Sync1; // Start transmission |
86 | // SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
89 | // SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
87 | 90 | ||
88 | } |
91 | } |
89 | 92 | ||
90 | //------------------------------------------------------ |
93 | //------------------------------------------------------ |
91 | //SIGNAL(SIG_SPI) |
94 | //SIGNAL(SIG_SPI) |
92 | void SPI_TransmitByte(void) |
95 | void SPI_TransmitByte(void) |
93 | { |
96 | { |
94 | static unsigned char SPI_RXState = 0; |
97 | static unsigned char SPI_RXState = 0; |
95 | unsigned char rxdata; |
98 | unsigned char rxdata; |
96 | static unsigned char rxchksum; |
99 | static unsigned char rxchksum; |
97 | 100 | ||
98 | if (SPITransferCompleted) return; |
101 | if (SPITransferCompleted) return; |
99 | if (!(SPSR & (1 << SPIF))) return; |
102 | if (!(SPSR & (1 << SPIF))) return; |
100 | SendSPI = 4; |
103 | SendSPI = 4; |
101 | 104 | ||
102 | // _delay_us(30); |
105 | // _delay_us(30); |
103 | SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
106 | SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
104 | 107 | ||
105 | rxdata = SPDR; |
108 | rxdata = SPDR; |
106 | switch ( SPI_RXState) |
109 | switch ( SPI_RXState) |
107 | { |
110 | { |
108 | case 0: |
111 | case 0: |
109 | 112 | ||
110 | SPI_RxBufferIndex = 0; |
113 | SPI_RxBufferIndex = 0; |
111 | rxchksum = rxdata; |
114 | rxchksum = rxdata; |
112 | if (rxdata == 0x81 ) { SPI_RXState = 1; } // 1. Syncbyte ok |
115 | if (rxdata == 0x81 ) { SPI_RXState = 1; } // 1. Syncbyte ok |
113 | 116 | ||
114 | break; |
117 | break; |
115 | 118 | ||
116 | case 1: |
119 | case 1: |
117 | if (rxdata == 0x55) { rxchksum += rxdata; SPI_RXState = 2; } // 2. Syncbyte ok |
120 | if (rxdata == 0x55) { rxchksum += rxdata; SPI_RXState = 2; } // 2. Syncbyte ok |
118 | else SPI_RXState = 0; |
121 | else SPI_RXState = 0; |
119 | break; |
122 | break; |
120 | 123 | ||
121 | case 2: |
124 | case 2: |
122 | SPI_Buffer[SPI_RxBufferIndex++]= rxdata; // get data |
125 | SPI_Buffer[SPI_RxBufferIndex++]= rxdata; // get data |
123 | //DebugOut.Analog[19]++; |
126 | //DebugOut.Analog[19]++; |
124 | if (SPI_RxBufferIndex >= sizeof(FromNaviCtrl)) |
127 | if (SPI_RxBufferIndex >= sizeof(FromNaviCtrl)) |
125 | { |
128 | { |
126 | 129 | ||
127 | if (rxdata == rxchksum) |
130 | if (rxdata == rxchksum) |
128 | { |
131 | { |
129 | unsigned char *ptr = (unsigned char *)&FromNaviCtrl; |
132 | unsigned char *ptr = (unsigned char *)&FromNaviCtrl; |
130 | memcpy(ptr, (unsigned char *) SPI_Buffer, sizeof(SPI_Buffer)); |
133 | memcpy(ptr, (unsigned char *) SPI_Buffer, sizeof(SPI_Buffer)); |
131 | SPI_RxDataValid = 1; |
134 | SPI_RxDataValid = 1; |
132 | } |
135 | } |
133 | else |
136 | else |
134 | { |
137 | { |
135 | SPI_RxDataValid = 0; |
138 | SPI_RxDataValid = 0; |
136 | } |
139 | } |
137 | 140 | ||
138 | 141 | ||
139 | SPI_RXState = 0; |
142 | SPI_RXState = 0; |
140 | } |
143 | } |
141 | else rxchksum += rxdata; |
144 | else rxchksum += rxdata; |
142 | break; |
145 | break; |
143 | 146 | ||
144 | } |
147 | } |
145 | 148 | ||
146 | if (SPI_BufferIndex < sizeof(ToNaviCtrl)) |
149 | if (SPI_BufferIndex < sizeof(ToNaviCtrl)) |
147 | { |
150 | { |
148 | SLAVE_SELECT_PORT &= ~(1 << SPI_SLAVE_SELECT); // SelectSlave |
151 | SLAVE_SELECT_PORT &= ~(1 << SPI_SLAVE_SELECT); // SelectSlave |
149 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
152 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
150 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
153 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
151 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
154 | asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); |
152 | 155 | ||
153 | SPDR = SPI_TX_Buffer[SPI_BufferIndex]; |
156 | SPDR = SPI_TX_Buffer[SPI_BufferIndex]; |
154 | ToNaviCtrl.Chksum += SPI_TX_Buffer[SPI_BufferIndex]; |
157 | ToNaviCtrl.Chksum += SPI_TX_Buffer[SPI_BufferIndex]; |
155 | // SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
158 | // SLAVE_SELECT_PORT |= (1 << SPI_SLAVE_SELECT); // DeselectSlave |
156 | 159 | ||
157 | } |
160 | } |
158 | else SPITransferCompleted = 1; |
161 | else SPITransferCompleted = 1; |
159 | 162 | ||
160 | SPI_BufferIndex++; |
163 | SPI_BufferIndex++; |
161 | } |
164 | } |
162 | 165 | ||
163 | 166 | ||
164 | //------------------------------------------------------ |
167 | //------------------------------------------------------ |
165 | void UpdateSPI_Buffer(void) |
168 | void UpdateSPI_Buffer(void) |
166 | { |
169 | { |
167 | signed int tmp; |
170 | signed int tmp; |
168 | static unsigned char motorindex, oldcommand = SPI_NCCMD_VERSION; |
171 | static unsigned char motorindex, oldcommand = SPI_NCCMD_VERSION; |
169 | ToNaviCtrl.IntegralNick = (int) (IntegralNick / (long)(EE_Parameter.GyroAccFaktor * 4)); |
172 | ToNaviCtrl.IntegralNick = (int) (IntegralNick / (long)(EE_Parameter.GyroAccFaktor * 4)); |
170 | ToNaviCtrl.IntegralRoll = (int) (IntegralRoll / (long)(EE_Parameter.GyroAccFaktor * 4)); |
173 | ToNaviCtrl.IntegralRoll = (int) (IntegralRoll / (long)(EE_Parameter.GyroAccFaktor * 4)); |
171 | ToNaviCtrl.GyroCompass = (10 * ErsatzKompass) / GIER_GRAD_FAKTOR; |
174 | ToNaviCtrl.GyroCompass = (10 * ErsatzKompass) / GIER_GRAD_FAKTOR; |
172 | ToNaviCtrl.GyroGier = (signed int) AdNeutralGier - AdWertGier; |
175 | ToNaviCtrl.GyroGier = (signed int) AdNeutralGier - AdWertGier; |
173 | ToNaviCtrl.AccNick = ((int) ACC_AMPLIFY * (NaviAccNick / NaviCntAcc))/4; |
176 | ToNaviCtrl.AccNick = ((int) ACC_AMPLIFY * (NaviAccNick / NaviCntAcc))/4; |
174 | ToNaviCtrl.AccRoll = ((int) ACC_AMPLIFY * (NaviAccRoll / NaviCntAcc))/4; |
177 | ToNaviCtrl.AccRoll = ((int) ACC_AMPLIFY * (NaviAccRoll / NaviCntAcc))/4; |
175 | NaviCntAcc = 0; NaviAccNick = 0; NaviAccRoll = 0; |
178 | NaviCntAcc = 0; NaviAccNick = 0; NaviAccRoll = 0; |
176 | // ToNaviCtrl.User8 = Parameter_UserParam8; |
179 | // ToNaviCtrl.User8 = Parameter_UserParam8; |
177 | // ToNaviCtrl.CalState = WinkelOut.CalcState; |
180 | // ToNaviCtrl.CalState = WinkelOut.CalcState; |
178 | switch(ToNaviCtrl.Command) // |
181 | switch(ToNaviCtrl.Command) // |
179 | { |
182 | { |
180 | case SPI_FCCMD_USER: |
183 | case SPI_FCCMD_USER: |
181 | ToNaviCtrl.Param.Byte[0] = Parameter_UserParam1; |
184 | ToNaviCtrl.Param.Byte[0] = Parameter_UserParam1; |
182 | ToNaviCtrl.Param.Byte[1] = Parameter_UserParam2; |
185 | ToNaviCtrl.Param.Byte[1] = Parameter_UserParam2; |
183 | ToNaviCtrl.Param.Byte[2] = Parameter_UserParam3; |
186 | ToNaviCtrl.Param.Byte[2] = Parameter_UserParam3; |
184 | ToNaviCtrl.Param.Byte[3] = Parameter_UserParam4; |
187 | ToNaviCtrl.Param.Byte[3] = Parameter_UserParam4; |
185 | ToNaviCtrl.Param.Byte[4] = Parameter_UserParam5; |
188 | ToNaviCtrl.Param.Byte[4] = Parameter_UserParam5; |
186 | ToNaviCtrl.Param.Byte[5] = Parameter_UserParam6; |
189 | ToNaviCtrl.Param.Byte[5] = Parameter_UserParam6; |
187 | ToNaviCtrl.Param.Byte[6] = Parameter_UserParam7; |
190 | ToNaviCtrl.Param.Byte[6] = Parameter_UserParam7; |
188 | ToNaviCtrl.Param.Byte[7] = Parameter_UserParam8; |
191 | ToNaviCtrl.Param.Byte[7] = Parameter_UserParam8; |
189 | ToNaviCtrl.Param.Byte[8] = FC_StatusFlags; |
192 | ToNaviCtrl.Param.Byte[8] = FC_StatusFlags; |
190 | FC_StatusFlags &= ~(FC_STATUS_CALIBRATE | FC_STATUS_START); |
193 | FC_StatusFlags &= ~(FC_STATUS_CALIBRATE | FC_STATUS_START); |
191 | ToNaviCtrl.Param.Byte[9] = GetActiveParamSet(); |
194 | ToNaviCtrl.Param.Byte[9] = GetActiveParamSet(); |
192 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.ComingHomeAltitude; |
195 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.ComingHomeAltitude; |
193 | ToNaviCtrl.Param.Byte[11] = FC_StatusFlags2; |
196 | ToNaviCtrl.Param.Byte[11] = FC_StatusFlags2; |
194 | break; |
197 | break; |
195 | 198 | ||
196 | case SPI_FCCMD_ACCU: |
199 | case SPI_FCCMD_ACCU: |
197 | ToNaviCtrl.Param.Int[0] = Capacity.ActualCurrent; // 0.1A |
200 | ToNaviCtrl.Param.Int[0] = Capacity.ActualCurrent; // 0.1A |
198 | ToNaviCtrl.Param.Int[1] = Capacity.UsedCapacity; // mAh |
201 | ToNaviCtrl.Param.Int[1] = Capacity.UsedCapacity; // mAh |
199 | ToNaviCtrl.Param.Byte[4] = (unsigned char) UBat; // 0.1V |
202 | ToNaviCtrl.Param.Byte[4] = (unsigned char) UBat; // 0.1V |
200 | ToNaviCtrl.Param.Byte[5] = (unsigned char) BattLowVoltageWarning; //0.1V |
203 | ToNaviCtrl.Param.Byte[5] = (unsigned char) BattLowVoltageWarning; //0.1V |
201 | ToNaviCtrl.Param.Byte[6] = VarioCharacter; |
204 | ToNaviCtrl.Param.Byte[6] = VarioCharacter; |
202 | ToNaviCtrl.Param.Byte[7] = motorindex; |
205 | ToNaviCtrl.Param.Byte[7] = motorindex; |
203 | ToNaviCtrl.Param.Byte[8] = Motor[motorindex].MaxPWM; |
206 | ToNaviCtrl.Param.Byte[8] = Motor[motorindex].MaxPWM; |
204 | ToNaviCtrl.Param.Byte[9] = Motor[motorindex].State; |
207 | ToNaviCtrl.Param.Byte[9] = Motor[motorindex].State; |
205 | ToNaviCtrl.Param.Byte[10] = Motor[motorindex].Temperature; |
208 | ToNaviCtrl.Param.Byte[10] = Motor[motorindex].Temperature; |
206 | ToNaviCtrl.Param.Byte[11] = Motor[motorindex++].Current; |
209 | ToNaviCtrl.Param.Byte[11] = Motor[motorindex++].Current; |
207 | motorindex %= 12; |
210 | motorindex %= 12; |
208 | break; |
211 | break; |
209 | case SPI_FCCMD_PARAMETER1: |
212 | case SPI_FCCMD_PARAMETER1: |
210 | ToNaviCtrl.Param.Byte[0] = EE_Parameter.NaviGpsModeControl; // Parameters for the Naviboard |
213 | ToNaviCtrl.Param.Byte[0] = EE_Parameter.NaviGpsModeControl; // Parameters for the Naviboard |
211 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviGpsGain; |
214 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviGpsGain; |
212 | ToNaviCtrl.Param.Byte[2] = EE_Parameter.NaviGpsP; |
215 | ToNaviCtrl.Param.Byte[2] = EE_Parameter.NaviGpsP; |
213 | ToNaviCtrl.Param.Byte[3] = EE_Parameter.NaviGpsI; |
216 | ToNaviCtrl.Param.Byte[3] = EE_Parameter.NaviGpsI; |
214 | ToNaviCtrl.Param.Byte[4] = EE_Parameter.NaviGpsD; |
217 | ToNaviCtrl.Param.Byte[4] = EE_Parameter.NaviGpsD; |
215 | ToNaviCtrl.Param.Byte[5] = EE_Parameter.NaviGpsACC; |
218 | ToNaviCtrl.Param.Byte[5] = EE_Parameter.NaviGpsACC; |
216 | ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsMinSat; |
219 | ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsMinSat; |
217 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviStickThreshold; |
220 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviStickThreshold; |
218 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviOperatingRadius; |
221 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviOperatingRadius; |
219 | ToNaviCtrl.Param.Byte[9] = EE_Parameter.NaviWindCorrection; |
222 | ToNaviCtrl.Param.Byte[9] = EE_Parameter.NaviWindCorrection; |
220 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.NaviAccCompensation; |
223 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.NaviAccCompensation; |
221 | ToNaviCtrl.Param.Byte[11] = EE_Parameter.NaviAngleLimitation; |
224 | ToNaviCtrl.Param.Byte[11] = EE_Parameter.NaviAngleLimitation; |
222 | break; |
225 | break; |
- | 226 | case SPI_FCCMD_PARAMETER2: |
|
- | 227 | ToNaviCtrl.Param.Byte[0] = EE_Parameter.NaviOut1Parameter; // Distance between Photo releases |
|
223 | 228 | break; |
|
224 | case SPI_FCCMD_STICK: |
229 | case SPI_FCCMD_STICK: |
225 | cli(); |
230 | cli(); |
226 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
231 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
227 | ToNaviCtrl.Param.Byte[0] = (char) tmp; |
232 | ToNaviCtrl.Param.Byte[0] = (char) tmp; |
228 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
233 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_GIER]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
229 | ToNaviCtrl.Param.Byte[1] = (char) tmp; |
234 | ToNaviCtrl.Param.Byte[1] = (char) tmp; |
230 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
235 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_ROLL]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
231 | ToNaviCtrl.Param.Byte[2] = (char) tmp; |
236 | ToNaviCtrl.Param.Byte[2] = (char) tmp; |
232 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
237 | tmp = PPM_in[EE_Parameter.Kanalbelegung[K_NICK]]; if(tmp > 127) tmp = 127; else if(tmp < -127) tmp = -127; |
233 | sei(); |
238 | sei(); |
234 | ToNaviCtrl.Param.Byte[3] = (char) tmp; |
239 | ToNaviCtrl.Param.Byte[3] = (char) tmp; |
235 | ToNaviCtrl.Param.Byte[4] = (unsigned char) Poti[0]; |
240 | ToNaviCtrl.Param.Byte[4] = (unsigned char) Poti[0]; |
236 | ToNaviCtrl.Param.Byte[5] = (unsigned char) Poti[1]; |
241 | ToNaviCtrl.Param.Byte[5] = (unsigned char) Poti[1]; |
237 | ToNaviCtrl.Param.Byte[6] = (unsigned char) Poti[2]; |
242 | ToNaviCtrl.Param.Byte[6] = (unsigned char) Poti[2]; |
238 | ToNaviCtrl.Param.Byte[7] = (unsigned char) Poti[3]; |
243 | ToNaviCtrl.Param.Byte[7] = (unsigned char) Poti[3]; |
239 | ToNaviCtrl.Param.Byte[8] = (unsigned char) Poti[4]; |
244 | ToNaviCtrl.Param.Byte[8] = (unsigned char) Poti[4]; |
240 | ToNaviCtrl.Param.Byte[9] = (unsigned char) Poti[5]; |
245 | ToNaviCtrl.Param.Byte[9] = (unsigned char) Poti[5]; |
241 | ToNaviCtrl.Param.Byte[10] = (unsigned char) Poti[6]; |
246 | ToNaviCtrl.Param.Byte[10] = (unsigned char) Poti[6]; |
242 | ToNaviCtrl.Param.Byte[11] = (unsigned char) Poti[7]; |
247 | ToNaviCtrl.Param.Byte[11] = (unsigned char) Poti[7]; |
243 | break; |
248 | break; |
244 | case SPI_FCCMD_MISC: |
249 | case SPI_FCCMD_MISC: |
245 | if(WinkelOut.CalcState > 5) |
250 | if(WinkelOut.CalcState > 5) |
246 | { |
251 | { |
247 | WinkelOut.CalcState = 0; |
252 | WinkelOut.CalcState = 0; |
248 | ToNaviCtrl.Param.Byte[0] = 5; |
253 | ToNaviCtrl.Param.Byte[0] = 5; |
249 | } |
254 | } |
250 | else ToNaviCtrl.Param.Byte[0] = WinkelOut.CalcState; |
255 | else ToNaviCtrl.Param.Byte[0] = WinkelOut.CalcState; |
251 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviPH_LoginTime; |
256 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.NaviPH_LoginTime; |
252 | ToNaviCtrl.Param.Int[1] = (int)(HoehenWert/5); |
257 | ToNaviCtrl.Param.Int[1] = (int)(HoehenWert/5); |
253 | ToNaviCtrl.Param.Int[2] = (int)(SollHoehe/5); |
258 | ToNaviCtrl.Param.Int[2] = (int)(SollHoehe/5); |
254 | ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsPLimit; |
259 | ToNaviCtrl.Param.Byte[6] = EE_Parameter.NaviGpsPLimit; |
255 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviGpsILimit; |
260 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.NaviGpsILimit; |
256 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviGpsDLimit; |
261 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.NaviGpsDLimit; |
257 | ToNaviCtrl.Param.Byte[9] = (unsigned char) SenderOkay; |
262 | ToNaviCtrl.Param.Byte[9] = (unsigned char) SenderOkay; |
258 | ToNaviCtrl.Param.Byte[10] = (unsigned char) PPM_in[0]; |
263 | ToNaviCtrl.Param.Byte[10] = (unsigned char) PPM_in[0]; |
259 | ToNaviCtrl.Param.Byte[11] = DebugOut.Analog[7] / 4; //GasMischanteil |
264 | ToNaviCtrl.Param.Byte[11] = DebugOut.Analog[7] / 4; //GasMischanteil |
260 | break; |
265 | break; |
261 | case SPI_FCCMD_VERSION: |
266 | case SPI_FCCMD_VERSION: |
262 | ToNaviCtrl.Param.Byte[0] = VERSION_MAJOR; |
267 | ToNaviCtrl.Param.Byte[0] = VERSION_MAJOR; |
263 | ToNaviCtrl.Param.Byte[1] = VERSION_MINOR; |
268 | ToNaviCtrl.Param.Byte[1] = VERSION_MINOR; |
264 | ToNaviCtrl.Param.Byte[2] = VERSION_PATCH; |
269 | ToNaviCtrl.Param.Byte[2] = VERSION_PATCH; |
265 | ToNaviCtrl.Param.Byte[3] = NC_SPI_COMPATIBLE; |
270 | ToNaviCtrl.Param.Byte[3] = NC_SPI_COMPATIBLE; |
266 | ToNaviCtrl.Param.Byte[4] = PlatinenVersion; |
271 | ToNaviCtrl.Param.Byte[4] = PlatinenVersion; |
267 | ToNaviCtrl.Param.Byte[5] = VersionInfo.HardwareError[0]; |
272 | ToNaviCtrl.Param.Byte[5] = VersionInfo.HardwareError[0]; |
268 | ToNaviCtrl.Param.Byte[6] = VersionInfo.HardwareError[1]; |
273 | ToNaviCtrl.Param.Byte[6] = VersionInfo.HardwareError[1]; |
269 | VersionInfo.HardwareError[0] = 0; |
274 | VersionInfo.HardwareError[0] = 0; |
270 | VersionInfo.HardwareError[1] &= FC_ERROR1_MIXER; |
275 | VersionInfo.HardwareError[1] &= FC_ERROR1_MIXER; |
271 | ToNaviCtrl.Param.Byte[7] = VersionInfo.HardwareError[2]; // unused |
276 | ToNaviCtrl.Param.Byte[7] = VersionInfo.HardwareError[2]; // unused |
272 | ToNaviCtrl.Param.Byte[8] = Parameter_GlobalConfig; |
277 | ToNaviCtrl.Param.Byte[8] = Parameter_GlobalConfig; |
273 | ToNaviCtrl.Param.Byte[9] = Parameter_ExtraConfig; |
278 | ToNaviCtrl.Param.Byte[9] = Parameter_ExtraConfig; |
274 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.OrientationAngle; |
279 | ToNaviCtrl.Param.Byte[10] = EE_Parameter.OrientationAngle; |
275 | ToNaviCtrl.Param.Byte[11] = EE_Parameter.GlobalConfig3; |
280 | ToNaviCtrl.Param.Byte[11] = EE_Parameter.GlobalConfig3; |
276 | break; |
281 | break; |
277 | case SPI_FCCMD_SERVOS: |
282 | case SPI_FCCMD_SERVOS: |
278 | ToNaviCtrl.Param.Byte[0] = EE_Parameter.ServoNickRefresh; // Parameters for the Servo Control |
283 | ToNaviCtrl.Param.Byte[0] = EE_Parameter.ServoNickRefresh; // Parameters for the Servo Control |
279 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.ServoCompInvert; |
284 | ToNaviCtrl.Param.Byte[1] = EE_Parameter.ServoCompInvert; |
280 | ToNaviCtrl.Param.Byte[2] = Parameter_ServoNickControl; |
285 | ToNaviCtrl.Param.Byte[2] = Parameter_ServoNickControl; |
281 | ToNaviCtrl.Param.Byte[3] = EE_Parameter.ServoNickComp; |
286 | ToNaviCtrl.Param.Byte[3] = EE_Parameter.ServoNickComp; |
282 | ToNaviCtrl.Param.Byte[4] = EE_Parameter.ServoNickMin; |
287 | ToNaviCtrl.Param.Byte[4] = EE_Parameter.ServoNickMin; |
283 | ToNaviCtrl.Param.Byte[5] = EE_Parameter.ServoNickMax; |
288 | ToNaviCtrl.Param.Byte[5] = EE_Parameter.ServoNickMax; |
284 | ToNaviCtrl.Param.Byte[6] = Parameter_ServoRollControl; |
289 | ToNaviCtrl.Param.Byte[6] = Parameter_ServoRollControl; |
285 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.ServoRollComp; |
290 | ToNaviCtrl.Param.Byte[7] = EE_Parameter.ServoRollComp; |
286 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.ServoRollMin; |
291 | ToNaviCtrl.Param.Byte[8] = EE_Parameter.ServoRollMin; |
287 | ToNaviCtrl.Param.Byte[9] = EE_Parameter.ServoRollMax; |
292 | ToNaviCtrl.Param.Byte[9] = EE_Parameter.ServoRollMax; |
288 | ToNaviCtrl.Param.Byte[10] = Capacity.MinOfMaxPWM; |
293 | ToNaviCtrl.Param.Byte[10] = Capacity.MinOfMaxPWM; |
289 | ToNaviCtrl.Param.Byte[11] = DebugOut.Analog[28]; // I2C-Error counter |
294 | ToNaviCtrl.Param.Byte[11] = DebugOut.Analog[28]; // I2C-Error counter |
290 | break; |
295 | break; |
291 | } |
296 | } |
292 | 297 | ||
293 | if(SPI_RxDataValid) |
298 | if(SPI_RxDataValid) |
294 | { |
299 | { |
295 | if(FromNaviCtrl.Command != oldcommand) NaviDataOkay = 250; |
300 | if(FromNaviCtrl.Command != oldcommand) NaviDataOkay = 250; |
296 | oldcommand = FromNaviCtrl.Command; |
301 | oldcommand = FromNaviCtrl.Command; |
297 | CalculateCompassTimer = 1; |
302 | CalculateCompassTimer = 1; |
298 | if(abs(FromNaviCtrl.GPS_Nick) < 512 && abs(FromNaviCtrl.GPS_Roll) < 512 && (EE_Parameter.GlobalConfig & CFG_GPS_AKTIV)) |
303 | if(abs(FromNaviCtrl.GPS_Nick) < 512 && abs(FromNaviCtrl.GPS_Roll) < 512 && (EE_Parameter.GlobalConfig & CFG_GPS_AKTIV)) |
299 | { |
304 | { |
300 | GPS_Nick = FromNaviCtrl.GPS_Nick; |
305 | GPS_Nick = FromNaviCtrl.GPS_Nick; |
301 | GPS_Roll = FromNaviCtrl.GPS_Roll; |
306 | GPS_Roll = FromNaviCtrl.GPS_Roll; |
302 | } |
307 | } |
303 | 308 | ||
304 | // update compass readings |
309 | // update compass readings |
305 | // MagVec.x = FromNaviCtrl.MagVecX; |
310 | // MagVec.x = FromNaviCtrl.MagVecX; |
306 | // MagVec.y = FromNaviCtrl.MagVecY; |
311 | // MagVec.y = FromNaviCtrl.MagVecY; |
307 | // MagVec.z = FromNaviCtrl.MagVecZ; |
312 | // MagVec.z = FromNaviCtrl.MagVecZ; |
308 | 313 | ||
309 | if(FromNaviCtrl.CompassValue <= 360) KompassValue = FromNaviCtrl.CompassValue; |
314 | if(FromNaviCtrl.CompassValue <= 360) KompassValue = FromNaviCtrl.CompassValue; |
310 | // KompassRichtung = ((540 + KompassValue - KompassSollWert) % 360) - 180; |
315 | // KompassRichtung = ((540 + KompassValue - KompassSollWert) % 360) - 180; |
311 | 316 | ||
312 | if(FromNaviCtrl.BeepTime > beeptime && !DisableRcOffBeeping) beeptime = FromNaviCtrl.BeepTime; |
317 | if(FromNaviCtrl.BeepTime > beeptime && !DisableRcOffBeeping) beeptime = FromNaviCtrl.BeepTime; |
313 | switch (FromNaviCtrl.Command) |
318 | switch (FromNaviCtrl.Command) |
314 | { |
319 | { |
315 | case SPI_NCCMD_KALMAN: |
320 | case SPI_NCCMD_KALMAN: |
316 | FromNaviCtrl_Value.Kalman_K = FromNaviCtrl.Param.sByte[0]; |
321 | FromNaviCtrl_Value.Kalman_K = FromNaviCtrl.Param.sByte[0]; |
317 | FromNaviCtrl_Value.Kalman_MaxFusion = FromNaviCtrl.Param.sByte[1]; |
322 | FromNaviCtrl_Value.Kalman_MaxFusion = FromNaviCtrl.Param.sByte[1]; |
318 | FromNaviCtrl_Value.Kalman_MaxDrift = FromNaviCtrl.Param.sByte[2]; |
323 | FromNaviCtrl_Value.Kalman_MaxDrift = FromNaviCtrl.Param.sByte[2]; |
319 | KompassFusion = FromNaviCtrl.Param.sByte[3]; |
324 | KompassFusion = FromNaviCtrl.Param.sByte[3]; |
320 | FromNaviCtrl_Value.GpsZ = FromNaviCtrl.Param.Byte[4]; |
325 | FromNaviCtrl_Value.GpsZ = FromNaviCtrl.Param.Byte[4]; |
321 | FromNC_Rotate_C = FromNaviCtrl.Param.Byte[5]; |
326 | FromNC_Rotate_C = FromNaviCtrl.Param.Byte[5]; |
322 | FromNC_Rotate_S = FromNaviCtrl.Param.Byte[6]; |
327 | FromNC_Rotate_S = FromNaviCtrl.Param.Byte[6]; |
323 | GPS_Aid_StickMultiplikator = FromNaviCtrl.Param.Byte[7]; |
328 | GPS_Aid_StickMultiplikator = FromNaviCtrl.Param.Byte[7]; |
324 | if(CareFree && FromNaviCtrl.Param.sInt[4] >= 0) |
329 | if(CareFree && FromNaviCtrl.Param.sInt[4] >= 0) |
325 | { |
330 | { |
326 | KompassSollWert = FromNaviCtrl.Param.sInt[4]; // bei Carefree kann NC den Kompass-Sollwinkel vorgeben |
331 | KompassSollWert = FromNaviCtrl.Param.sInt[4]; // bei Carefree kann NC den Kompass-Sollwinkel vorgeben |
327 | if(EE_Parameter.CamOrientation) // Kamera angle is not front |
332 | if(EE_Parameter.CamOrientation) // Kamera angle is not front |
328 | { |
333 | { |
329 | KompassSollWert += 360 - ((unsigned int) EE_Parameter.CamOrientation * 15); |
334 | KompassSollWert += 360 - ((unsigned int) EE_Parameter.CamOrientation * 15); |
330 | KompassSollWert %= 360; |
335 | KompassSollWert %= 360; |
331 | } |
336 | } |
332 | } |
337 | } |
333 | POI_KameraNick = (POI_KameraNick + FromNaviCtrl.Param.sInt[5]) / 2; // FromNaviCtrl.Param.sInt[5]; // Nickwinkel |
338 | POI_KameraNick = (POI_KameraNick + FromNaviCtrl.Param.sInt[5]) / 2; // FromNaviCtrl.Param.sInt[5]; // Nickwinkel |
334 | break; |
339 | break; |
335 | case SPI_NCCMD_VERSION: |
340 | case SPI_NCCMD_VERSION: |
336 | NC_Version.Major = FromNaviCtrl.Param.Byte[0]; |
341 | NC_Version.Major = FromNaviCtrl.Param.Byte[0]; |
337 | NC_Version.Minor = FromNaviCtrl.Param.Byte[1]; |
342 | NC_Version.Minor = FromNaviCtrl.Param.Byte[1]; |
338 | NC_Version.Patch = FromNaviCtrl.Param.Byte[2]; |
343 | NC_Version.Patch = FromNaviCtrl.Param.Byte[2]; |
339 | NC_Version.Compatible = FromNaviCtrl.Param.Byte[3]; |
344 | NC_Version.Compatible = FromNaviCtrl.Param.Byte[3]; |
340 | NC_Version.Hardware = FromNaviCtrl.Param.Byte[4]; |
345 | NC_Version.Hardware = FromNaviCtrl.Param.Byte[4]; |
341 | DebugOut.Status[0] |= FromNaviCtrl.Param.Byte[5]; |
346 | DebugOut.Status[0] |= FromNaviCtrl.Param.Byte[5]; |
342 | DebugOut.Status[1] = (DebugOut.Status[1] & (0x01|0x02)) | (FromNaviCtrl.Param.Byte[6] & (0x04 | 0x08)); |
347 | DebugOut.Status[1] = (DebugOut.Status[1] & (0x01|0x02)) | (FromNaviCtrl.Param.Byte[6] & (0x04 | 0x08)); |
343 | NC_ErrorCode = FromNaviCtrl.Param.Byte[7]; |
348 | NC_ErrorCode = FromNaviCtrl.Param.Byte[7]; |
344 | NC_GPS_ModeCharacter = FromNaviCtrl.Param.Byte[8]; |
349 | NC_GPS_ModeCharacter = FromNaviCtrl.Param.Byte[8]; |
345 | FromNaviCtrl_Value.SerialDataOkay = FromNaviCtrl.Param.Byte[9]; |
350 | FromNaviCtrl_Value.SerialDataOkay = FromNaviCtrl.Param.Byte[9]; |
346 | NC_To_FC_Flags = FromNaviCtrl.Param.Byte[10]; |
351 | NC_To_FC_Flags = FromNaviCtrl.Param.Byte[10]; |
347 | NC_To_FC_MaxAltitude = FromNaviCtrl.Param.Byte[11]; |
352 | NC_To_FC_MaxAltitude = FromNaviCtrl.Param.Byte[11]; |
348 | break; |
353 | break; |
349 | case SPI_NCCMD_GPSINFO: |
354 | case SPI_NCCMD_GPSINFO: |
350 | GPSInfo.Flags = FromNaviCtrl.Param.Byte[0]; |
355 | GPSInfo.Flags = FromNaviCtrl.Param.Byte[0]; |
351 | GPSInfo.NumOfSats = FromNaviCtrl.Param.Byte[1]; |
356 | GPSInfo.NumOfSats = FromNaviCtrl.Param.Byte[1]; |
352 | GPSInfo.SatFix = FromNaviCtrl.Param.Byte[2]; |
357 | GPSInfo.SatFix = FromNaviCtrl.Param.Byte[2]; |
353 | GPSInfo.Speed = FromNaviCtrl.Param.Byte[3]; |
358 | GPSInfo.Speed = FromNaviCtrl.Param.Byte[3]; |
354 | GPSInfo.HomeDistance = FromNaviCtrl.Param.Int[2]; |
359 | GPSInfo.HomeDistance = FromNaviCtrl.Param.Int[2]; |
355 | GPSInfo.HomeBearing = FromNaviCtrl.Param.sInt[3]; |
360 | GPSInfo.HomeBearing = FromNaviCtrl.Param.sInt[3]; |
356 | PPM_in[25] = (signed char) FromNaviCtrl.Param.Byte[8]; // WP_EVENT-Channel-Value |
361 | PPM_in[25] = (signed char) FromNaviCtrl.Param.Byte[8]; // WP_EVENT-Channel-Value |
357 | FromNC_AltitudeSpeed = FromNaviCtrl.Param.Byte[9]; |
362 | FromNC_AltitudeSpeed = FromNaviCtrl.Param.Byte[9]; |
358 | FromNC_AltitudeSetpoint = (long) FromNaviCtrl.Param.sInt[5] * 10; // in cm |
363 | FromNC_AltitudeSetpoint = (long) FromNaviCtrl.Param.sInt[5] * 10; // in cm |
359 | break; |
364 | break; |
360 | case SPI_MISC: |
365 | case SPI_MISC: |
361 | EarthMagneticField = FromNaviCtrl.Param.Byte[0]; |
366 | EarthMagneticField = FromNaviCtrl.Param.Byte[0]; |
362 | EarthMagneticInclination = FromNaviCtrl.Param.Byte[1]; |
367 | EarthMagneticInclination = FromNaviCtrl.Param.Byte[1]; |
363 | EarthMagneticInclinationTheoretic = FromNaviCtrl.Param.Byte[2]; |
368 | EarthMagneticInclinationTheoretic = FromNaviCtrl.Param.Byte[2]; |
364 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
369 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
365 | if(FromNaviCtrl.Param.Byte[3]) |
370 | if(FromNaviCtrl.Param.Byte[3]) |
366 | if(!SpeakHoTT || (SpeakHoTT >= SPEAK_GPS_HOLD && SpeakHoTT <= SPEAK_GPS_OFF)) SpeakHoTT = FromNaviCtrl.Param.Byte[3]; |
371 | if(!SpeakHoTT || (SpeakHoTT >= SPEAK_GPS_HOLD && SpeakHoTT <= SPEAK_GPS_OFF)) SpeakHoTT = FromNaviCtrl.Param.Byte[3]; |
367 | NaviData_WaypointIndex = FromNaviCtrl.Param.Byte[4]; |
372 | NaviData_WaypointIndex = FromNaviCtrl.Param.Byte[4]; |
368 | NaviData_WaypointNumber = FromNaviCtrl.Param.Byte[5]; |
373 | NaviData_WaypointNumber = FromNaviCtrl.Param.Byte[5]; |
369 | NaviData_TargetDistance = FromNaviCtrl.Param.Int[3]; |
374 | NaviData_TargetDistance = FromNaviCtrl.Param.Int[3]; |
370 | NaviData_TargetHoldTime = FromNaviCtrl.Param.Byte[8]; |
375 | NaviData_TargetHoldTime = FromNaviCtrl.Param.Byte[8]; |
371 | #endif |
376 | #endif |
372 | break; |
377 | break; |
373 | 378 | ||
374 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
379 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
375 | case SPI_NCCMD_HOTT_DATA: |
380 | case SPI_NCCMD_HOTT_DATA: |
376 | if(EE_Parameter.Receiver == RECEIVER_HOTT) NC_Fills_HoTT_Telemety(); |
381 | if(EE_Parameter.Receiver == RECEIVER_HOTT) NC_Fills_HoTT_Telemety(); |
377 | break; |
382 | break; |
378 | #endif |
383 | #endif |
379 | 384 | ||
380 | // 0 = 0,1 |
385 | // 0 = 0,1 |
381 | // 1 = 2,3 |
386 | // 1 = 2,3 |
382 | // 2 = 4,5 |
387 | // 2 = 4,5 |
383 | // 3 = 6,7 |
388 | // 3 = 6,7 |
384 | // 4 = 8,9 |
389 | // 4 = 8,9 |
385 | // 5 = 10,11 |
390 | // 5 = 10,11 |
386 | default: |
391 | default: |
387 | break; |
392 | break; |
388 | } |
393 | } |
389 | } |
394 | } |
390 | else |
395 | else |
391 | { |
396 | { |
392 | // KompassValue = 0; |
397 | // KompassValue = 0; |
393 | // KompassRichtung = 0; |
398 | // KompassRichtung = 0; |
394 | GPS_Nick = 0; |
399 | GPS_Nick = 0; |
395 | GPS_Roll = 0; |
400 | GPS_Roll = 0; |
396 | } |
401 | } |
397 | } |
402 | } |
398 | 403 | ||
399 | #endif |
404 | #endif |
400 | 405 | ||
401 | 406 | ||
402 | 407 |