Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1653 → Rev 1654

/trunk/eeprom.c
74,6 → 74,7
 
paramset_t EE_Parameter;
MixerTable_t Mixer;
uint8_t RequiredMotors;
 
 
uint8_t RAM_Checksum(uint8_t* pBuffer, uint16_t len)
/trunk/eeprom.h
34,6 → 34,7
} __attribute__((packed)) MixerTable_t;
 
extern MixerTable_t Mixer;
extern uint8_t RequiredMotors;
 
#define CFG_HOEHENREGELUNG 0x01
#define CFG_HOEHEN_SCHALTER 0x02
/trunk/fc.c
96,7 → 96,6
volatile unsigned char SenderOkay = 0;
int StickNick = 0,StickRoll = 0,StickGier = 0,StickGas = 0;
char MotorenEin = 0;
unsigned char RequiredMotors = 0;
long HoehenWert = 0;
long SollHoehe = 0;
int LageKorrekturRoll = 0,LageKorrekturNick = 0;
1635,7 → 1634,7
if(Mixer.Motor[i][0] > 0)
{
// Gas
if(Mixer.Motor[i][0] == 64) tmp_int = GasMischanteil * 2; else tmp_int = ((long)GasMischanteil * Mixer.Motor[i][0]) / 32L;
if(Mixer.Motor[i][0] == 64) tmp_int = GasMischanteil * 2; else tmp_int = ((long)GasMischanteil * Mixer.Motor[i][0]) / 32L;
// Nick
if(Mixer.Motor[i][1] == 64) tmp_int += pd_ergebnis_nick;
else if(Mixer.Motor[i][1] == -64) tmp_int -= pd_ergebnis_nick;
/trunk/fc.h
76,7 → 76,6
extern volatile unsigned char SenderOkay;
extern int StickNick,StickRoll,StickGier;
extern char MotorenEin;
extern unsigned char RequiredMotors;
extern unsigned char Parameter_Servo3,Parameter_Servo4,Parameter_Servo5;
extern char VarioCharacter;
 
/trunk/main.c
79,37 → 79,30
}
 
 
 
void LipoDetection(unsigned char print)
{
unsigned int timer;
if(print) printf("\n\rBatt:");
if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung
{
timer = SetDelay(500);
if(print) while (!CheckDelay(timer));
if(UBat < 130)
{
BattLowVoltageWarning = 3 * EE_Parameter.UnterspannungsWarnung;
if(print)
{
Piep(3,200);
printf(" 3 Cells ");
#define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO
unsigned int timer, cells;
if(print) printf("\n\rBatt:");
if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung
{
timer = SetDelay(500);
if(print) while (!CheckDelay(timer));
// up to 6s LiPo
for(cells = 1; cells < 7; cells++)
{
if(UBat < cells * MAX_CELL_VOLTAGE) break;
}
}
else
{
BattLowVoltageWarning = 4 * EE_Parameter.UnterspannungsWarnung;
if(print)
{
Piep(4,200);
printf(" 4 Cells ");
 
BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung;
if(print)
{
Piep(cells, 200);
printf(" %d Cells ", cells);
}
}
}
else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
// if(BattLowVoltageWarning < 93) BattLowVoltageWarning = 93;
if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
}
else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung;
if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10);
}
 
//############################################################################
169,24 → 162,22
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Check connected BL-Ctrls
BLFlags |= BLFLAG_READ_VERSION;
UpdateMotor = 0;
motorread = 0;
motorread = 0; // read the first I2C-Data
SendMotorData();
while(!UpdateMotor);
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
 
printf("\n\rFound BL-Ctrl: ");
timer = SetDelay(4000);
for(i=0; i < MAX_MOTORS; i++)
{
UpdateMotor = 0;
SendMotorData();
while(!UpdateMotor);
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up
{
while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) )
{
UpdateMotor = 0;
SendMotorData();
while(!UpdateMotor);
while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer
}
}
if(Motor[i].State & MOTOR_STATE_PRESENT_MASK)
193,7 → 184,6
{
printf("%d",i+1);
// if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) ");
// else printf(" ");
}
}
for(i=0; i < MAX_MOTORS; i++)
207,8 → 197,6
}
printf("\n\r===================================");
 
I2C_SendBLConfig();
 
//if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
{
printf("\n\rCalibrating pressure sensor..");
/trunk/twimaster.c
86,11 → 86,11
break;
case 1:
i2c_write_byte(Motor[motor].SetPoint);
if(!(Motor[motor].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) || RequiredMotors > 6)
if(!(Motor[motor].Version & MOTOR_STATE_NEW_PROTOCOL_MASK))
{
twi_state = 4; //jump over sending more data
}
else if(!(Motor[motor].SetPointLowerBits || (BLFlags & BLFLAG_SEND_CONFIG)))
else if(!( (Motor[motor].SetPointLowerBits && RequiredMotors < 7) || (BLFlags & BLFLAG_SEND_CONFIG)))
{
twi_state = 4; // skip state
}
172,7 → 172,7
else
{
Motor[motorread].State |= MOTOR_STATE_PRESENT_MASK; // set present bit
if(motorread == motorread_temperature)
if( (motorread == motorread_temperature) || (BLFlags & BLFLAG_READ_VERSION) )
{
read_more = 1;
I2C_ReceiveByte();
/trunk/uart.c
341,7 → 341,7
}
while(!UebertragungAbgeschlossen);
SendOutData('M', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1));
 
break;
 
case 'p': // get PPM Channels
364,7 → 364,7
while(!UebertragungAbgeschlossen);
SendOutData('Q', FC_ADDRESS, 2, &tempchar1, sizeof(tempchar1), (unsigned char *) &EE_Parameter, sizeof(EE_Parameter) - 1);
Debug("Lese Setting %d", tempchar1);
 
break;
 
case 's': // Parametersatz speichern
409,7 → 409,7
{
// 't' comand placed here only for compatibility to BL
case 't':// Motortest
if(AnzahlEmpfangsBytes > 20) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest));
if(AnzahlEmpfangsBytes > 10) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest));
else memcpy(&MotorTest[0], (unsigned char *)pRxData, 4);
while(!UebertragungAbgeschlossen);
SendOutData('T', MeineSlaveAdresse, 0);
615,7 → 615,7
SendOutData('P', FC_ADDRESS, 1, (unsigned char *) &PPM_in, sizeof(PPM_in));
GetPPMChannelAnforderung = 0;
}
 
#ifdef DEBUG // only include functions if DEBUG is defined
if(SendDebugOutput && UebertragungAbgeschlossen)
{
622,7 → 622,7
SendOutData('0', FC_ADDRESS, 1, (unsigned char *) &tDebug, sizeof(tDebug));
SendDebugOutput = 0;
}
#endif
#endif
 
}