Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1765 → Rev 1766

/beta/Code Redesign killagreg/analog.c
157,7 → 157,7
SetParamByte(PID_PRESSURE_OFFSET, off);
PressureSensorOffset = off;
#endif
if((ParamSet.Config0 & CFG0_AIRPRESS_SENSOR) && ((PressureSensorOffset < 10) || (PressureSensorOffset >= 245))) UART_VersionInfo.HardwareError[0] |= DEFECT_PRESSURE;
if((ParamSet.Config0 & CFG0_AIRPRESS_SENSOR) && ((PressureSensorOffset < 10) || (PressureSensorOffset >= 245))) UART_VersionInfo.HardwareError[0] |= FC_ERROR0_PRESSURE;
AirPressure = AIR_PRESSURE_SCALE * (int32_t)AdAirPressure; // init IIR Filter
Delay_ms_Mess(300);
}
179,9 → 179,9
if(AdValueGyroRoll < 1020) DacOffsetGyroRoll--; else if(AdValueGyroRoll > 1030) DacOffsetGyroRoll++; else ready++;
if(AdValueGyroYaw < 1020) DacOffsetGyroYaw-- ; else if(AdValueGyroYaw > 1030) DacOffsetGyroYaw++ ; else ready++;
I2C_Start(TWI_STATE_GYRO_OFFSET_TX); // initiate data transmission
if(DacOffsetGyroNick < 10) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_NICK; DacOffsetGyroNick = 10;}; if(DacOffsetGyroNick > 245) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_NICK; DacOffsetGyroNick = 245;};
if(DacOffsetGyroRoll < 10) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_ROLL; DacOffsetGyroRoll = 10;}; if(DacOffsetGyroRoll > 245) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_ROLL; DacOffsetGyroRoll = 245;};
if(DacOffsetGyroYaw < 10) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_YAW; DacOffsetGyroYaw = 10;}; if(DacOffsetGyroYaw > 245) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_YAW; DacOffsetGyroYaw = 245;};
if(DacOffsetGyroNick < 10) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_NICK; DacOffsetGyroNick = 10;}; if(DacOffsetGyroNick > 245) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_NICK; DacOffsetGyroNick = 245;};
if(DacOffsetGyroRoll < 10) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_ROLL; DacOffsetGyroRoll = 10;}; if(DacOffsetGyroRoll > 245) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_ROLL; DacOffsetGyroRoll = 245;};
if(DacOffsetGyroYaw < 10) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_YAW; DacOffsetGyroYaw = 10;}; if(DacOffsetGyroYaw > 245) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_YAW; DacOffsetGyroYaw = 245;};
while(twi_state)
{
if(CheckDelay(timeout))
/beta/Code Redesign killagreg/fc.c
133,7 → 133,10
 
// MK flags
uint16_t ModelIsFlying = 0;
uint8_t volatile FCFlags = 0;
 
volatile uint8_t FC_StatusFlags = 0;
volatile uint8_t FC_ErrorFlags = 0;
 
int8_t VarioCharacter = ' ';
uint8_t CareFree = 0;
 
220,7 → 223,7
/************************************************************************/
void Beep(uint8_t numbeeps, uint16_t duration)
{
if(FCFlags & FCFLAG_MOTOR_RUN) return; // never with running motors!!!
if(FC_StatusFlags & FC_STATUS_MOTOR_RUN) return; // never with running motors!!!
while(numbeeps--)
{
BeepTime = duration; // in ms second
364,7 → 367,7
GPSStickNick = 0;
GPSStickRoll = 0;
 
FCFlags |= FCFLAG_CALIBRATE;
FC_StatusFlags |= FC_STATUS_CALIBRATE;
 
FCParam.KalmanK = -1;
FCParam.KalmanMaxDrift = 0;
378,12 → 381,12
//Servo_On(); //enable servo output
RC_Quality = 100;
 
if((BiasHiResGyroNick < 150 * 16) || (BiasHiResGyroNick > 850 * 16)) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_NICK; };
if((BiasHiResGyroRoll < 150 * 16) || (BiasHiResGyroRoll > 850 * 16)) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_ROLL; };
if((AdBiasGyroYaw < 150 * 2) || (AdBiasGyroYaw > 850 * 2 )) { UART_VersionInfo.HardwareError[0] |= DEFECT_G_YAW; };
if((AdBiasAccNick < 300 * 2) || (AdBiasAccNick > 750 * 2)) { UART_VersionInfo.HardwareError[0] |= DEFECT_A_NICK; };
if((AdBiasAccRoll < 300 * 2) || (AdBiasAccRoll > 750 * 2)) { UART_VersionInfo.HardwareError[0] |= DEFECT_A_ROLL; };
if((AdBiasAccTop < 512) || (AdBiasAccTop > 850 )) { UART_VersionInfo.HardwareError[0] |= DEFECT_A_TOP; };
if((BiasHiResGyroNick < 150 * 16) || (BiasHiResGyroNick > 850 * 16)) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_NICK; };
if((BiasHiResGyroRoll < 150 * 16) || (BiasHiResGyroRoll > 850 * 16)) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_ROLL; };
if((AdBiasGyroYaw < 150 * 2) || (AdBiasGyroYaw > 850 * 2 )) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_GYRO_YAW; };
if((AdBiasAccNick < 300 * 2) || (AdBiasAccNick > 750 * 2)) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_NICK; };
if((AdBiasAccRoll < 300 * 2) || (AdBiasAccRoll > 750 * 2)) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_ROLL; };
if((AdBiasAccTop < 512) || (AdBiasAccTop > 850 )) { UART_VersionInfo.HardwareError[0] |= FC_ERROR0_ACC_TOP; };
}
 
/************************************************************************/
593,9 → 596,9
void SendMotorData(void)
{
uint8_t i;
if(!(FCFlags & FCFLAG_MOTOR_RUN))
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN))
{
FCFlags &= ~(FCFLAG_FLY|FCFLAG_START); // clear flag FLY and START if motors are off
FC_StatusFlags &= ~(FC_STATUS_FLY|FC_STATUS_START); // clear flag FLY and START if motors are off
for(i = 0; i < MAX_MOTORS; i++)
{
if(!MotorTest_Active)
682,12 → 685,12
if(!CareFree) ControlHeading = (((int16_t) ParamSet.OrientationAngle * 15 + CompassHeading) % 360) / 2;
#endif
CareFree = 1;
if(FromNaviCtrl.CompassHeading < 0) UART_VersionInfo.HardwareError[0] |= DEFECT_CAREFREE_ERR;
else UART_VersionInfo.HardwareError[0] &= ~DEFECT_CAREFREE_ERR;
if(FromNaviCtrl.CompassHeading < 0) UART_VersionInfo.HardwareError[0] |= FC_ERROR0_CAREFREE;
else UART_VersionInfo.HardwareError[0] &= ~FC_ERROR0_CAREFREE;
}
else CareFree = 0;
 
if((FromNaviCtrl.CompassHeading < 0) && (BeepModulation == 0xFFFF) && CareFree && (FCFlags & FCFLAG_MOTOR_RUN))
if((FromNaviCtrl.CompassHeading < 0) && (BeepModulation == 0xFFFF) && CareFree && (FC_StatusFlags & FC_STATUS_MOTOR_RUN))
{
BeepTime = 15000; // 1.5 seconds
BeepModulation = 0xA400;
759,12 → 762,12
if(RcLostTimer) RcLostTimer--; // decremtent timer after rc sigal lost
else // rc lost countdown finished
{
FCFlags &= ~(FCFLAG_MOTOR_RUN|FCFLAG_EMERGENCY_LANDING); // clear motor run flag that stop the motors in SendMotorData()
FC_StatusFlags &= ~(FC_STATUS_MOTOR_RUN|FC_STATUS_EMERGENCY_LANDING); // clear motor run flag that stop the motors in SendMotorData()
}
RED_ON; // set red led
if(ModelIsFlying > 1000) // wahrscheinlich in der Luft --> langsam absenken
{
FCFlags |= (FCFLAG_EMERGENCY_LANDING); // set flag for emergency landing
FC_StatusFlags |= (FC_STATUS_EMERGENCY_LANDING); // set flag for emergency landing
// set neutral rc inputs
PPM_diff[ParamSet.ChannelAssignment[CH_NICK]] = 0;
PPM_diff[ParamSet.ChannelAssignment[CH_ROLL]] = 0;
773,7 → 776,7
PPM_in[ParamSet.ChannelAssignment[CH_ROLL]] = 0;
PPM_in[ParamSet.ChannelAssignment[CH_YAW]] = 0;
}
else FCFlags &= ~(FCFLAG_MOTOR_RUN); // clear motor run flag that stop the motors in SendMotorData()
else FC_StatusFlags &= ~(FC_STATUS_MOTOR_RUN); // clear motor run flag that stop the motors in SendMotorData()
} // eof RC_Quality < 100
else
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
781,11 → 784,11
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(RC_Quality > 140)
{
FCFlags &= ~(FCFLAG_EMERGENCY_LANDING); // clear flag for emergency landing
FC_StatusFlags &= ~(FC_STATUS_EMERGENCY_LANDING); // clear flag for emergency landing
// reset emergency timer
RcLostTimer = ParamSet.EmergencyGasDuration * 50;
#define GAS_FLIGHT_THRESHOLD 40
if(StickGas > GAS_FLIGHT_THRESHOLD && (FCFlags & FCFLAG_MOTOR_RUN) )
if(StickGas > GAS_FLIGHT_THRESHOLD && (FC_StatusFlags & FC_STATUS_MOTOR_RUN) )
{
if(ModelIsFlying < 0xFFFF) ModelIsFlying++;
}
801,7 → 804,7
UpdateCompassCourse = 1;
}
}
else FCFlags |= FCFLAG_FLY; // set fly flag
else FC_StatusFlags |= FC_STATUS_FLY; // set fly flag
 
// update poti values
// limit poti values
821,7 → 824,7
}
 
// if motors are off and the gas stick is in the upper position
if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && !(FCFlags & FCFLAG_MOTOR_RUN) )
if((PPM_in[ParamSet.ChannelAssignment[CH_GAS]] > 80) && !(FC_StatusFlags & FC_STATUS_MOTOR_RUN) )
{
// and if the yaw stick is in the leftmost position
if(PPM_in[ParamSet.ChannelAssignment[CH_YAW]] > 75)
954,7 → 957,7
DebugOut.Analog[16] = ParamSet.MotorSafetySwitch;
if(PPM_in[ParamSet.ChannelAssignment[CH_GAS]] < -85)
{
if(!(FCFlags&FCFLAG_MOTOR_RUN)) // motors are not running
if(!(FC_StatusFlags&FC_STATUS_MOTOR_RUN)) // motors are not running
{
if((PPM_in[ParamSet.ChannelAssignment[CH_YAW]] < -75) && ( (PPM_in[ParamSet.MotorSafetySwitch] < -75) || (ParamSet.MotorSafetySwitch == 0)) )
{
973,7 → 976,7
if(!UART_VersionInfo.HardwareError[0] && Calibration_Done)
{
ModelIsFlying = 1;
FCFlags |= (FCFLAG_MOTOR_RUN|FCFLAG_START); // set flag RUN and START
FC_StatusFlags |= (FC_STATUS_MOTOR_RUN|FC_STATUS_START); // set flag RUN and START
SetPointYaw = 0;
ReadingIntegralGyroYaw = 0;
ReadingIntegralGyroNick = ParamSet.GyroAccFactor * (int32_t)AccNick;
1009,7 → 1012,7
{
delay_stopmotors = 0;
ModelIsFlying = 0;
FCFlags &= ~(FCFLAG_MOTOR_RUN);
FC_StatusFlags &= ~(FC_STATUS_MOTOR_RUN);
}
}
else delay_stopmotors = 0; // reset delay timer if sticks are not in this position
1021,7 → 1024,7
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// new values from RC
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(!NewPpmData-- || (FCFlags & FCFLAG_EMERGENCY_LANDING) ) // NewData = 0 means new data from RC
if(!NewPpmData-- || (FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING) ) // NewData = 0 means new data from RC
{
static int16_t stick_nick = 0, stick_roll = 0;
 
1168,7 → 1171,7
// in case of emergency landing
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// set all inputs to save values
if(FCFlags & FCFLAG_EMERGENCY_LANDING)
if(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING)
{
StickYaw = 0;
StickNick = 0;
1212,7 → 1215,7
}
 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(! LoopingNick && !LoopingRoll && ( (AdValueAccZ > 512) || (FCFlags & FCFLAG_MOTOR_RUN) ) ) // if not lopping in any direction
if(! LoopingNick && !LoopingRoll && ( (AdValueAccZ > 512) || (FC_StatusFlags & FC_STATUS_MOTOR_RUN) ) ) // if not lopping in any direction
{
if( FCParam.KalmanK != -1)
{
1459,7 → 1462,7
{
int16_t w, v, r,correction, error;
 
if(CompassCalState && !(FCFlags & FCFLAG_MOTOR_RUN) )
if(CompassCalState && !(FC_StatusFlags & FC_STATUS_MOTOR_RUN) )
{
SetCompassCalState();
}
1689,7 → 1692,7
CosAttitude = c_cos_8192(CosAttitude); // cos of actual attitude
VarioCharacter = ' ';
 
if(HCActive && !(FCFlags & FCFLAG_EMERGENCY_LANDING))
if(HCActive && !(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING))
{
#define HC_TRIM_UP 0x01
#define HC_TRIM_DOWN 0x02
1713,7 → 1716,7
// the setpoint will be fine adjusted with the gas stick position
#define HC_STICKTHRESHOLD 15
 
if(FCFlags & FCFLAG_FLY) // trim setpoint only when flying
if(FC_StatusFlags & FC_STATUS_FLY) // trim setpoint only when flying
{ // gas stick is above hover point
if(StickGas > (StickGasHover + HC_STICKTHRESHOLD) && !(BaroFlags & BARO_LIMIT_MAX))
{
1768,7 → 1771,7
}
} // EOF trimming height set point
if(BaroExpandActive) SetPointHeight = ReadingHeight; // update setpoint to current altitude if expanding is active
} //if FCFlags & FCFLAG_FLY
} //if FC_StatusFlags & FC_STATUS_FLY
else // not flying but height control is already active
{
SetPointHeight = ReadingHeight - 400; // setpoint should be 4 meters below actual height to avoid a take off
1894,7 → 1897,7
// ----------------- Hover Gas Estimation --------------------------------
// Hover gas estimation by averaging gas control output on small z-velocities
// this is done only if height contol option is selected in global config and aircraft is flying
if((FCFlags & FCFLAG_FLY))// && !(FCFlags & FCFLAG_EMERGENCY_LANDING))
if((FC_StatusFlags & FC_STATUS_FLY))// && !(FC_StatusFlags & FC_STATUS_EMERGENCY_LANDING))
{
if((HoverGasFilter == 0) || (HoverGasState == HOVER_GAS_STATE_START)) HoverGasFilter = HOVER_GAS_AVERAGE * (uint32_t)(GasMixFraction); // init estimation
if(HoverGasState == HOVER_GAS_STATE_START) HoverGasState = HOVER_GAS_STATE_RUNNING;
1932,7 → 1935,7
HoverGasMin = 0;
HoverGasMax = 255 * STICK_GAIN;
}
}// EOF if(FCFlags & FCFLAG_FLY)
}// EOF if(FC_StatusFlags & FC_STATUS_FLY)
else // not flying yet
{ // reset hover gas filter
HoverGasState = HOVER_GAS_STATE_NONE;
/beta/Code Redesign killagreg/fc.h
139,17 → 139,17
extern int32_t IPartNick;
extern int32_t IPartRoll;
 
// FCFlags
#define FCFLAG_MOTOR_RUN 0x01
#define FCFLAG_FLY 0x02
#define FCFLAG_CALIBRATE 0x04
#define FCFLAG_START 0x08
#define FCFLAG_EMERGENCY_LANDING 0x10
#define FCFLAG_LOWBAT 0x20
#define FCFLAG_SPI_RX_ERR 0x40
#define FCFLAG_I2C_ERR 0x80
extern volatile uint8_t FC_StatusFlags;
 
extern volatile uint8_t FCFlags;
// FC STATUS FLAGS
#define FC_STATUS_MOTOR_RUN 0x01
#define FC_STATUS_FLY 0x02
#define FC_STATUS_CALIBRATE 0x04
#define FC_STATUS_START 0x08
#define FC_STATUS_EMERGENCY_LANDING 0x10
#define FC_STATUS_LOWBAT 0x20
#define FC_STATUS_RES1 0x40
#define FC_STATUS_RES2 0x80
 
#endif //_FC_H
 
/beta/Code Redesign killagreg/led.c
53,6 → 53,7
#include "led.h"
#include "fc.h"
#include "eeprom.h"
#include "uart0.h"
 
uint8_t J16Blinkcount = 0, J16Mask = 1;
uint8_t J17Blinkcount = 0, J17Mask = 1;
81,7 → 82,7
if(!delay--) // 10 ms intervall
{
delay = 4;
if(FCFlags & (FCFLAG_LOWBAT|FCFLAG_EMERGENCY_LANDING|FCFLAG_I2C_ERR))
if( (FC_StatusFlags & (FC_STATUS_LOWBAT|FC_STATUS_EMERGENCY_LANDING)) || (UART_VersionInfo.HardwareError[1] & FC_ERROR1_I2C) )
{
if(ParamSet.J16Bitmask_Warning)
{
105,7 → 106,7
 
if(!J16Warn)
{
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN))
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FC_StatusFlags & FC_STATUS_MOTOR_RUN))
{
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED1) J16_ON;
else J16_OFF;
136,7 → 137,7
 
if(!J17Warn)
{
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN))
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FC_StatusFlags & FC_STATUS_MOTOR_RUN))
{
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED2) J17_ON;
else J17_OFF;
/beta/Code Redesign killagreg/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/libfc644.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/beta/Code Redesign killagreg/main.c
240,7 → 240,7
Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter
}
// if mismatch between mixer setup and hardware setup
if(RequiredMotors < FoundMotors) UART_VersionInfo.HardwareError[1] |= DEFECT_MIXER_ERR;
if(RequiredMotors < FoundMotors) UART_VersionInfo.HardwareError[1] |= FC_ERROR1_MIXER;
 
printf("\n\r===================================");
 
323,13 → 323,13
if(RC_Quality)
{
RC_Quality--;
UART_VersionInfo.HardwareError[1] &= ~DEFECT_PPM_ERR;
UART_VersionInfo.HardwareError[1] &= ~FC_ERROR1_PPM;
}
else
{
PPM_INPUT_ON; // if RC-Quality is lost, enable PPM input (could be disabled by a receiver on uart1)
PPM_in[0] = 0; // set RSSI to zero on data timeout
UART_VersionInfo.HardwareError[1] |= DEFECT_PPM_ERR;
UART_VersionInfo.HardwareError[1] |= FC_ERROR1_PPM;
}
 
if(!--I2CTimeout || MissingMotor) // try to reset the i2c if motor is missing or timeout
340,11 → 340,10
I2C_Reset();
I2CTimeout = 5;
DebugOut.Analog[28]++; // I2C-Error
FCFlags |= FCFLAG_I2C_ERR;
UART_VersionInfo.HardwareError[1] |= DEFECT_I2C;
UART_VersionInfo.HardwareError[1] |= FC_ERROR1_I2C;
DebugOut.Status[1] |= 0x02; // BL-Error-Status
}
if((BeepModulation == 0xFFFF) && (FCFlags & FCFLAG_MOTOR_RUN) )
if((BeepModulation == 0xFFFF) && (FC_StatusFlags & FC_STATUS_MOTOR_RUN) )
{
BeepTime = 10000; // 1 second
BeepModulation = 0x0080;
353,7 → 352,7
else
{
RED_OFF;
if(!BeepTime) FCFlags &= ~FCFLAG_I2C_ERR;
if(!BeepTime) UART_VersionInfo.HardwareError[1] |= FC_ERROR1_I2C;
}
 
// allow Serial Data Transmit if motors must not updated at this time
372,16 → 371,16
 
if(MissingMotor)
{
UART_VersionInfo.HardwareError[1] |= DEFECT_BL_MISSING;
UART_VersionInfo.HardwareError[1] |= FC_ERROR1_BL_MISSING;
DebugOut.Status[1] |= 0x02; // BL-Error-Status
}
else
{
UART_VersionInfo.HardwareError[1] &= ~DEFECT_BL_MISSING;
UART_VersionInfo.HardwareError[1] &= ~FC_ERROR1_BL_MISSING;
if(I2CTimeout > 6) DebugOut.Status[1] &= ~0x02; // BL-Error-Status
}
 
if(I2CTimeout > 6) UART_VersionInfo.HardwareError[1] &= ~DEFECT_I2C;
if(I2CTimeout > 6) UART_VersionInfo.HardwareError[1] &= ~FC_ERROR1_I2C;
 
if(PcAccess) PcAccess--;
else
400,16 → 399,14
if(NCDataOkay > 200)
{
NCDataOkay--;
FCFlags &= ~FCFLAG_SPI_RX_ERR;
UART_VersionInfo.HardwareError[1] &= ~DEFECT_SPI_RX_ERR;
UART_VersionInfo.HardwareError[1] &= ~FC_ERROR1_SPI_RX;
}
else // no data from NC
{
if(NC_Version.Compatible)
{
FCFlags |= FCFLAG_SPI_RX_ERR;
UART_VersionInfo.HardwareError[1] |= DEFECT_SPI_RX_ERR;
if((BeepModulation == 0xFFFF) && (FCFlags & FCFLAG_MOTOR_RUN) )
UART_VersionInfo.HardwareError[1] |= FC_ERROR1_SPI_RX;
if((BeepModulation == 0xFFFF) && (FC_StatusFlags & FC_STATUS_MOTOR_RUN) )
{
BeepTime = 15000;
BeepModulation = 0xA800;
424,7 → 421,7
#endif
if(UBat < LowVoltageWarning)
{
FCFlags |= FCFLAG_LOWBAT;
FC_StatusFlags |= FC_STATUS_LOWBAT;
BeepModulation = 0x0300;
if(!BeepTime )
{
433,7 → 430,7
}
else
{
if(!BeepTime) FCFlags &= ~FCFLAG_LOWBAT;
if(!BeepTime) FC_StatusFlags &= ~FC_STATUS_LOWBAT;
}
#ifdef USE_NAVICTRL
SPI_StartTransmitPacket();
440,7 → 437,7
SendSPI = 4;
#endif
 
if(!(FCFlags & FCFLAG_MOTOR_RUN)) counter_minute = 1450; // 0.5 minutes round up
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN)) counter_minute = 1450; // 0.5 minutes round up
else
{
if(++counter_second == 49) // one second
/beta/Code Redesign killagreg/makefile
10,7 → 10,7
 
VERSION_SERIAL_MAJOR = 11 # Serial Protocol Major Version
VERSION_SERIAL_MINOR = 0 # Serial Protocol Minor Version
NC_SPI_COMPATIBLE = 14 # SPI Protocol Version
NC_SPI_COMPATIBLE = 15 # SPI Protocol Version
 
#-------------------------------------------------------------------
#OPTIONS
/beta/Code Redesign killagreg/menu.c
120,7 → 120,7
LCD_printfxy(0,3,"Missing BL-Ctrl:%d", MissingMotor);
}
else
if(UART_VersionInfo.HardwareError[1] & DEFECT_MIXER_ERR) LCD_printfxy(0,3,"Mixer Error!")
if(UART_VersionInfo.HardwareError[1] & FC_ERROR1_MIXER) LCD_printfxy(0,3,"Mixer Error!")
else
//if(UART_VersionInfo.HardwareError[1]) LCD_printfxy(0,3,"Error 2:%d !!",UART_VersionInfo.HardwareError[1])
//else
/beta/Code Redesign killagreg/rc.c
217,7 → 217,7
RED_ON;
}
// store max channels transmitted
if(!(FCFlags & FCFLAG_MOTOR_RUN)) RC_Channels = index;
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN)) RC_Channels = index;
// reset channel index
index = 1;
}
/beta/Code Redesign killagreg/spi.c
231,8 → 231,8
ToNaviCtrl.Param.Byte[5] = FCParam.UserParam6;
ToNaviCtrl.Param.Byte[6] = FCParam.UserParam7;
ToNaviCtrl.Param.Byte[7] = FCParam.UserParam8;
ToNaviCtrl.Param.Byte[8] = FCFlags;
FCFlags &= ~(FCFLAG_CALIBRATE | FCFLAG_START); // calibrate and start are temporal states that are cleared immediately after transmitting
ToNaviCtrl.Param.Byte[8] = FC_StatusFlags;
FC_StatusFlags &= ~(FC_STATUS_CALIBRATE | FC_STATUS_START); // calibrate and start are temporal states that are cleared immediately after transmitting
ToNaviCtrl.Param.Byte[9] = GetActiveParamSet();
ToNaviCtrl.Param.Byte[10] = ControlHeading; // 0 to 180 in stepsof 2°
break;
306,6 → 306,8
ToNaviCtrl.Param.Byte[5] = UART_VersionInfo.HardwareError[0];
ToNaviCtrl.Param.Byte[6] = UART_VersionInfo.HardwareError[1];
ToNaviCtrl.Param.Byte[7] = UART_VersionInfo.HardwareError[2];
ToNaviCtrl.Param.Byte[8] = UART_VersionInfo.HardwareError[3];
ToNaviCtrl.Param.Byte[9] = UART_VersionInfo.HardwareError[4];
break;
 
case SPI_FCCMD_SERVOS:
/beta/Code Redesign killagreg/twimaster.c
302,7 → 302,7
{
if(BLFlags & BLFLAG_READ_VERSION)
{
if(!(FCFlags & FCFLAG_MOTOR_RUN) && (Motor[motor_read].MaxPWM == 250) ) Motor[motor_read].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK;
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN) && (Motor[motor_read].MaxPWM == 250) ) Motor[motor_read].Version |= MOTOR_STATE_NEW_PROTOCOL_MASK;
else Motor[motor_read].Version = 0;
}
if(++motor_read >= MAX_MOTORS)
383,7 → 383,7
uint8_t i;
static uint16_t timer;
 
if((FCFlags & FCFLAG_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if((FC_StatusFlags & FC_STATUS_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if(motor > MAX_MOTORS) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
if(motor)
{
432,7 → 432,7
uint8_t i;
uint16_t timer;
 
if((FCFlags & FCFLAG_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if((FC_StatusFlags & FC_STATUS_MOTOR_RUN) || MotorTest_Active) return(BLCONFIG_ERR_MOTOR_RUNNING); // not when motors are running!
if(motor > MAX_MOTORS) return (BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
if(motor == 0) return (BLCONFIG_ERR_READ_NOT_POSSIBLE); // motor read any
if(!(Motor[motor-1].State & MOTOR_STATE_PRESENT_MASK)) return(BLCONFIG_ERR_MOTOR_NOT_EXIST); // motor does not exist!
/beta/Code Redesign killagreg/uart0.c
525,7 → 525,7
MixerTable_WriteToEEProm();
tempchar1 = 1;
// ?? the bit is cleared here but the error check is only done once during startup
UART_VersionInfo.HardwareError[1] &= ~DEFECT_MIXER_ERR;
UART_VersionInfo.HardwareError[1] &= ~FC_ERROR1_MIXER;
}
else
{
574,7 → 574,7
break;
 
case 's': // save settings
if(!(FCFlags & FCFLAG_MOTOR_RUN)) // save settings only if motors are off
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN)) // save settings only if motors are off
{
if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_REVISION)) // check for setting to be in range and version of settings
{
603,7 → 603,7
tempchar1 = GetActiveParamSet();
while(!txd_complete); // wait for previous frame to be sent
SendOutData('F', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1));
if(!(FCFlags & FCFLAG_MOTOR_RUN)) Beep(tempchar1, 110);
if(!(FC_StatusFlags & FC_STATUS_MOTOR_RUN)) Beep(tempchar1, 110);
LipoDetection(0);
LIBFC_ReceiverInit(ParamSet.Receiver);
break;
/beta/Code Redesign killagreg/uart0.h
63,22 → 63,29
 
extern ExternControl_t ExternControl;
 
 
// FC hardware errors
 
// bitmask for UART_VersionInfo_t.HardwareError[0]
#define DEFECT_G_NICK 0x01
#define DEFECT_G_ROLL 0x02
#define DEFECT_G_YAW 0x04
#define DEFECT_A_NICK 0x08
#define DEFECT_A_ROLL 0x10
#define DEFECT_A_TOP 0x20
#define DEFECT_PRESSURE 0x40
#define DEFECT_CAREFREE_ERR 0x80
#define FC_ERROR0_GYRO_NICK 0x01
#define FC_ERROR0_GYRO_ROLL 0x02
#define FC_ERROR0_GYRO_YAW 0x04
#define FC_ERROR0_ACC_NICK 0x08
#define FC_ERROR0_ACC_ROLL 0x10
#define FC_ERROR0_ACC_TOP 0x20
#define FC_ERROR0_PRESSURE 0x40
#define FC_ERROR0_CAREFREE 0x80
// bitmask for UART_VersionInfo_t.HardwareError[1]
#define DEFECT_I2C 0x01
#define DEFECT_BL_MISSING 0x02
#define DEFECT_SPI_RX_ERR 0x04
#define DEFECT_PPM_ERR 0x08
#define DEFECT_MIXER_ERR 0x10
#define FC_ERROR1_I2C 0x01
#define FC_ERROR1_BL_MISSING 0x02
#define FC_ERROR1_SPI_RX 0x04
#define FC_ERROR1_PPM 0x08
#define FC_ERROR1_MIXER 0x10
#define FC_ERROR1_RES1 0x20
#define FC_ERROR1_RES2 0x40
#define FC_ERROR1_RES3 0x80
 
 
typedef struct
{
uint8_t SWMajor;