Rev 1210 | Rev 1212 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1210 | Rev 1211 | ||
---|---|---|---|
Line 119... | Line 119... | ||
119 | //############################################################################ |
119 | //############################################################################ |
120 | //Hauptprogramm |
120 | //Hauptprogramm |
121 | int main (void) |
121 | int main (void) |
122 | //############################################################################ |
122 | //############################################################################ |
123 | { |
123 | { |
124 | unsigned int timer; |
124 | unsigned int timer,i; |
125 | DDRB = 0x00; |
125 | DDRB = 0x00; |
126 | PORTB = 0x00; |
126 | PORTB = 0x00; |
127 | for(timer = 0; timer < 1000; timer++); // verzögern |
127 | for(timer = 0; timer < 1000; timer++); // verzögern |
128 | if(PINB & 0x01) |
128 | if(PINB & 0x01) |
129 | { |
129 | { |
Line 163... | Line 163... | ||
163 | i2c_init(); |
163 | i2c_init(); |
164 | SPI_MasterInit(); |
164 | SPI_MasterInit(); |
Line 165... | Line 165... | ||
165 | 165 | ||
Line -... | Line 166... | ||
- | 166 | sei(); |
|
166 | sei(); |
167 | |
167 | 168 | printf("\n\r==================================="); |
|
168 | printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR,VERSION_PATCH + 'a'); |
169 | printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR,VERSION_PATCH + 'a'); |
169 | if(UCSR1A == 0x20 && UCSR1C == 0x06) // initial Values for 644P |
170 | if(UCSR1A == 0x20 && UCSR1C == 0x06) // initial Values for 644P |
170 | { |
171 | { |
171 | Uart1Init(); |
172 | Uart1Init(); |
172 | } |
173 | } |
Line 173... | Line 174... | ||
173 | GRN_ON; |
174 | GRN_ON; |
174 | ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 9); // read only the first bytes |
175 | ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 9); // read only the first bytes |
175 | 176 | ||
176 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_REVISION]) == EE_MIXER_REVISION) |
177 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) // Check Revision in the first Byte |
177 | { |
178 | { |
178 | unsigned char i; |
179 | unsigned char i; |
179 | RequiredMotors = 0; |
180 | RequiredMotors = 0; |
180 | eeprom_read_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
181 | eeprom_read_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
181 | for(i=0; i<16;i++) { if(Mixer.Motor[i][0] > 0) RequiredMotors++;} |
182 | for(i=0; i<16;i++) { if(Mixer.Motor[i][0] > 0) RequiredMotors++;} |
182 | } |
183 | } |
- | 184 | else // default |
|
183 | else // default |
185 | { |
184 | { |
186 | unsigned char i; |
185 | unsigned char i; |
187 | printf("\n\rGenerating default Mixer Table"); |
186 | for(i=0; i<16;i++) { Mixer.Motor[i][0] = 0;Mixer.Motor[i][1] = 0;Mixer.Motor[i][2] = 0;Mixer.Motor[i][3] = 0;}; |
188 | for(i=0; i<16;i++) { Mixer.Motor[i][0] = 0;Mixer.Motor[i][1] = 0;Mixer.Motor[i][2] = 0;Mixer.Motor[i][3] = 0;}; |
187 | // default = Quadro |
189 | // default = Quadro |
188 | Mixer.Motor[0][0] = 64; Mixer.Motor[0][1] = +64; Mixer.Motor[0][2] = 0; Mixer.Motor[0][3] = +64; |
190 | Mixer.Motor[0][0] = 64; Mixer.Motor[0][1] = +64; Mixer.Motor[0][2] = 0; Mixer.Motor[0][3] = +64; |
- | 191 | Mixer.Motor[1][0] = 64; Mixer.Motor[1][1] = -64; Mixer.Motor[1][2] = 0; Mixer.Motor[1][3] = +64; |
|
189 | Mixer.Motor[1][0] = 64; Mixer.Motor[1][1] = -64; Mixer.Motor[1][2] = 0; Mixer.Motor[1][3] = +64; |
192 | Mixer.Motor[2][0] = 64; Mixer.Motor[2][1] = 0; Mixer.Motor[2][2] = -64; Mixer.Motor[2][3] = -64; |
190 | Mixer.Motor[2][0] = 64; Mixer.Motor[2][1] = 0; Mixer.Motor[2][2] = -64; Mixer.Motor[2][3] = -64; |
193 | Mixer.Motor[3][0] = 64; Mixer.Motor[3][1] = 0; Mixer.Motor[3][2] = +64; Mixer.Motor[3][3] = -64; |
191 | Mixer.Motor[3][0] = 64; Mixer.Motor[3][1] = 0; Mixer.Motor[3][2] = +64; Mixer.Motor[3][3] = -64; |
- | |
192 | memcpy(Mixer.Name, "Quadro\0", 11); |
194 | Mixer.Revision = MIXER_REVISION; |
193 | eeprom_write_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
195 | memcpy(Mixer.Name, "Quadro\0", 11); |
- | 196 | eeprom_write_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
|
- | 197 | } |
|
- | 198 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name,RequiredMotors); |
|
- | 199 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 200 | // + Check connected BL-Ctrls |
|
- | 201 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 202 | printf("\n\rFound BL-Ctrl: "); |
|
- | 203 | motorread = 0; UpdateMotor = 0; SendMotorData(); while(!UpdateMotor); motorread = 0; // read the first I2C-Data |
|
- | 204 | for(i=0; i < MAX_MOTORS; i++) |
|
- | 205 | { |
|
- | 206 | UpdateMotor = 0; |
|
- | 207 | SendMotorData(); |
|
- | 208 | while(!UpdateMotor); |
|
- | 209 | if(MotorPresent[i]) printf("%d ",i+1); |
|
- | 210 | } |
|
- | 211 | for(i=0; i < MAX_MOTORS; i++) |
|
- | 212 | { |
|
194 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_MIXER_REVISION],EE_MIXER_REVISION); // Länge der Datensätze merken |
213 | if(!MotorPresent[i] && Mixer.Motor[i][0] > 0) printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
- | 214 | MotorError[i] = 0; |
|
- | 215 | } |
|
- | 216 | printf("\n\r==================================="); |
|
195 | } |
217 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
196 | printf("\n\rMixer-Config: '%s' (%u Motors)",Mixer.Name,RequiredMotors); |
218 | // + Check Settings |
197 | printf("\n\r=============================="); |
219 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
198 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION) |
220 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION) |
199 | { |
221 | { |
Line 231... | Line 253... | ||
231 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION); |
253 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION); |
232 | } |
254 | } |
Line 233... | Line 255... | ||
233 | 255 | ||
234 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) |
256 | if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4) |
235 | { |
257 | { |
236 | printf("\n\rACC nicht abgeglichen!"); |
258 | printf("\n\rACC not calibrated !"); |
Line 237... | Line 259... | ||
237 | } |
259 | } |
238 | 260 | ||
Line 239... | Line 261... | ||
239 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
261 | ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
240 | printf("\n\rBenutze Parametersatz %d", GetActiveParamSetNumber()); |
262 | printf("\n\rUsing parameterset %d", GetActiveParamSetNumber()); |
241 | 263 | ||
242 | 264 | ||
243 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
265 | if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
244 | { |
266 | { |
245 | printf("\n\rAbgleich Luftdrucksensor.."); |
267 | printf("\n\rCalibrating pressure sensor.."); |
246 | timer = SetDelay(1000); |
268 | timer = SetDelay(1000); |
Line 255... | Line 277... | ||
255 | 277 | ||
256 | beeptime = 2000; |
278 | beeptime = 2000; |
Line 257... | Line 279... | ||
257 | ExternControl.Digital[0] = 0x55; |
279 | ExternControl.Digital[0] = 0x55; |
258 | 280 | ||
259 | 281 | ||
Line 260... | Line 282... | ||
260 | printf("\n\rSteuerung: "); |
282 | printf("\n\rControl: "); |
Line 261... | Line 283... | ||
261 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
283 | if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
262 | else printf("Neutral"); |
284 | else printf("Normal (ACC-Mode)"); |
263 | 285 | ||
264 | printf("\n\n\r"); |
286 | printf("\n\r===================================\n\r"); |