Rev 1444 | Rev 1481 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1444 | Rev 1479 | ||
---|---|---|---|
Line 159... | Line 159... | ||
159 | //Hauptprogramm |
159 | //Hauptprogramm |
160 | int main (void) |
160 | int main (void) |
161 | //############################################################################ |
161 | //############################################################################ |
162 | { |
162 | { |
163 | unsigned int timer,i,timer2 = 0, timerPolling; |
163 | unsigned int timer,i,timer2 = 0, timerPolling; |
- | 164 | unsigned char RequiredMotors = 0; |
|
- | 165 | ||
164 | DDRB = 0x00; |
166 | DDRB = 0x00; |
165 | PORTB = 0x00; |
167 | PORTB = 0x00; |
166 | for(timer = 0; timer < 1000; timer++); // verzögern |
168 | for(timer = 0; timer < 1000; timer++); // verzögern |
167 | if(PINB & 0x01) |
169 | if(PINB & 0x01) |
168 | { |
170 | { |
Line 189... | Line 191... | ||
189 | 191 | ||
190 | beeptime = 2000; |
192 | beeptime = 2000; |
191 | StickGier = 0; PPM_in[K_GAS] = 0;StickRoll = 0; StickNick = 0; |
193 | StickGier = 0; PPM_in[K_GAS] = 0;StickRoll = 0; StickNick = 0; |
192 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1160; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
194 | if(PlatinenVersion >= 20) GIER_GRAD_FAKTOR = 1160; else GIER_GRAD_FAKTOR = 1291; // unterschiedlich für ME und ENC |
193 | ROT_OFF; |
195 | ROT_OFF; |
194 | 196 | ||
195 | Timer_Init(); |
197 | Timer_Init(); |
196 | TIMER2_Init(); |
198 | TIMER2_Init(); |
197 | UART_Init(); |
199 | UART_Init(); |
198 | rc_sum_init(); |
200 | rc_sum_init(); |
Line 208... | Line 210... | ||
208 | 210 | ||
209 | if((eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) && // Check Revision in the first Byte |
211 | if((eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) && // Check Revision in the first Byte |
210 | (eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != 0xff)) // Settings reset via Koptertool |
212 | (eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != 0xff)) // Settings reset via Koptertool |
211 | { |
213 | { |
212 | unsigned char i; |
- | |
213 | RequiredMotors = 0; |
214 | unsigned char i; |
214 | eeprom_read_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
215 | eeprom_read_block(&Mixer, &EEPromArray[EEPROM_ADR_MIXER_TABLE], sizeof(Mixer)); |
215 | for(i=0; i<16;i++) { if(Mixer.Motor[i][0] > 0) RequiredMotors++;} |
216 | for(i=0; i<16;i++) { if(Mixer.Motor[i][0] > 0) RequiredMotors++;} |
216 | } |
217 | } |
217 | else // default |
218 | else // default |
Line 245... | Line 246... | ||
245 | UpdateMotor = 0; |
246 | UpdateMotor = 0; |
246 | SendMotorData(); |
247 | SendMotorData(); |
247 | while(!UpdateMotor); |
248 | while(!UpdateMotor); |
248 | if(Mixer.Motor[i][0] > 0) // wait max 2 sec for the BL-Ctrls to wake up |
249 | if(Mixer.Motor[i][0] > 0) // wait max 2 sec for the BL-Ctrls to wake up |
249 | { |
250 | { |
250 | while(!CheckDelay(timer) && !MotorPresent[i]) {UpdateMotor = 0; SendMotorData(); while(!UpdateMotor);}; |
251 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) {UpdateMotor = 0; SendMotorData(); while(!UpdateMotor);}; |
251 | } |
252 | } |
252 | if(MotorPresent[i]) printf("%d ",i+1); |
253 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) printf("%d ",i+1); |
253 | } |
254 | } |
254 | for(i=0; i < MAX_MOTORS; i++) |
255 | for(i=0; i < MAX_MOTORS; i++) |
255 | { |
256 | { |
256 | if(!MotorPresent[i] && Mixer.Motor[i][0] > 0) |
257 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
257 | { |
258 | { |
258 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
259 | printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
259 | ServoActive = 1; // just in case the FC would be used as camera-stabilizer |
260 | ServoActive = 1; // just in case the FC would be used as camera-stabilizer |
260 | } |
261 | } |
261 | MotorError[i] = 0; |
262 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
262 | } |
263 | } |
263 | printf("\n\r==================================="); |
264 | printf("\n\r==================================="); |
264 | SendMotorData(); |
265 | SendMotorData(); |
265 | //printf("\n size: %u",STRUCT_PARAM_LAENGE); |
266 | //printf("\n size: %u",STRUCT_PARAM_LAENGE); |