Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 254 → Rev 255

/trunk/logging.c
172,13 → 172,13
{
logtimer = SetDelay(LogDelay); // standard interval
 
if(FC.Flags & FCFLAG_MOTOR_RUN)
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN)
{
switch(logfilestate)
{
case LOGFILE_IDLE:
case LOGFILE_CLOSED:
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.Flags & FCFLAG_FLY))
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.StatusFlags & FC_STATUS_FLY))
{
logfilestate = LOGFILE_START;
}
299,13 → 299,13
{
logtimer = SetDelay(LogDelay); // standard interval
 
if(FC.Flags & FCFLAG_MOTOR_RUN)
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN)
{
switch(logfilestate)
{
case LOGFILE_IDLE:
case LOGFILE_CLOSED:
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.Flags & FCFLAG_FLY))
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.StatusFlags & FC_STATUS_FLY))
{
logfilestate = LOGFILE_START;
}
/trunk/main.c
89,7 → 89,7
u8 NCFlags = 0;
s16 GeoMagDec = 0; // local magnetic declination in 0.1 deg
 
u8 ClearFCFlags = 0;
u8 ClearFCStatusFlags = 0;
u8 StopNavigation = 0;
Param_t Parameter;
volatile FC_t FC;
129,21 → 129,6
}
 
//----------------------------------------------------------------------------------------------------
#define DEFEKT_G_NICK 0x01
#define DEFEKT_G_ROLL 0x02
#define DEFEKT_G_GIER 0x04
#define DEFEKT_A_NICK 0x08
#define DEFEKT_A_ROLL 0x10
#define DEFEKT_A_Z 0x20
#define DEFEKT_PRESSURE 0x40
#define DEFEKT_CAREFREE_ERR 0x80
 
#define DEFEKT_I2C 0x01
#define DEFEKT_BL_MISSING 0x02
#define DEFEKT_SPI_RX_ERR 0x04
#define DEFEKT_PPM_ERR 0x08
#define DEFEKT_MIXER_ERR 0x10
//----------------------------------------------------------------------------------------------------
#define ERROR_FC_COMMUNICATION 0x01
#define ERROR_MK3_COMMUNICATION 0x02
#define ERROR_FC_INCOMPATIBLE 0x04
159,7 → 144,7
if(/*(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) ||*/ CheckDelay(I2C1_Timeout) || (Compass_Heading < 0)) DebugOut.Status[1] |= 0x08;
else DebugOut.Status[1] &= ~0x08; // MK3Mag green status
 
if((FC_ErrorCode[1] & DEFEKT_I2C) || (FC_ErrorCode[1] & DEFEKT_BL_MISSING)) DebugOut.Status[1] |= 0x02;
if((FC.Error[1] & FC_ERROR1_I2C) || (FC.Error[1] & FC_ERROR1_BL_MISSING)) DebugOut.Status[1] |= 0x02;
else DebugOut.Status[1] &= ~0x02; // BL-Ctrl green status
 
if(CheckDelay(SPI0_Timeout))
193,61 → 178,61
UART_VersionInfo.HardwareError[0] |= ERROR_FC_INCOMPATIBLE;
}
 
else if(FC_ErrorCode[0] & DEFEKT_G_NICK)
else if(FC.Error[0] & FC_ERROR0_GYRO_NICK)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Nick Gyro");
ErrorCode = 10;
}
else if(FC_ErrorCode[0] & DEFEKT_G_ROLL)
else if(FC.Error[0] & FC_ERROR0_GYRO_ROLL)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Roll Gyro");
ErrorCode = 11;
}
else if(FC_ErrorCode[0] & DEFEKT_G_GIER)
else if(FC.Error[0] & FC_ERROR0_GYRO_YAW)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Yaw Gyro");
ErrorCode = 12;
}
else if(FC_ErrorCode[0] & DEFEKT_A_NICK)
else if(FC.Error[0] & FC_ERROR0_ACC_NICK)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Nick ACC");
ErrorCode = 13;
}
else if(FC_ErrorCode[0] & DEFEKT_A_ROLL)
else if(FC.Error[0] & FC_ERROR0_ACC_ROLL)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Roll ACC");
ErrorCode = 14;
}
else if(FC_ErrorCode[0] & DEFEKT_A_Z)
else if(FC.Error[0] & FC_ERROR0_ACC_TOP)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC Z-ACC");
ErrorCode = 15;
}
else if(FC_ErrorCode[0] & DEFEKT_PRESSURE)
else if(FC.Error[0] & FC_ERROR0_PRESSURE)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: Pressure sensor");
ErrorCode = 16;
}
else if(FC_ErrorCode[1] & DEFEKT_I2C)
else if(FC.Error[1] & FC_ERROR1_I2C)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: FC I2C");
ErrorCode = 17;
}
else if(FC_ErrorCode[1] & DEFEKT_BL_MISSING)
else if(FC.Error[1] & FC_ERROR1_BL_MISSING)
{
LED_RED_ON;
sprintf(ErrorMSG,"ERR: Bl Missing");
ErrorCode = 18;
}
else if(FC_ErrorCode[1] & DEFEKT_MIXER_ERR)
else if(FC.Error[1] & FC_ERROR1_MIXER)
{
LED_RED_ON;
sprintf(ErrorMSG,"Mixer Error");
277,7 → 262,7
StopNavigation = 1;
UART_VersionInfo.HardwareError[0] |= ERROR_COMPASS_VALUE;
}
else if(FC.Flags & FCFLAG_SPI_RX_ERR)
else if((FC.Error[1] & FC_ERROR1_SPI_RX))
{
LED_RED_ON;
sprintf(ErrorMSG,"FC spi rx error ");
284,13 → 269,13
ErrorCode = 8;
StopNavigation = 1;
}
else if(FC_ErrorCode[0] & DEFEKT_CAREFREE_ERR)
else if(FC.Error[0] & FC_ERROR0_CAREFREE)
{
LED_RED_ON;
sprintf(ErrorMSG,"FC: Carefree Error");
ErrorCode = 20;
}
else if(FC.RC_Quality < 100)
else if(FC.Error[1] & FC_ERROR1_PPM)
{
LED_RED_ON;
sprintf(ErrorMSG,"RC Signal lost ");
457,7 → 442,7
TimerCheckError = SetDelay(1000);
if(CheckDelay(SPI0_Timeout)) GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); // process the GPS data even if the FC is not connected
CheckErrors();
if(FC.Flags & FCFLAG_FLY) NaviData.FlyingTime++; // we want to count the battery-time
if(FC.StatusFlags & FC_STATUS_FLY) NaviData.FlyingTime++; // we want to count the battery-time
// else NaviData.FlyingTime = 0; // not the time per flight
if(SerialLinkOkay) SerialLinkOkay--;
if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication
/trunk/main.h
12,21 → 12,38
#define VERSION_SERIAL_MAJOR 11
#define VERSION_SERIAL_MINOR 0
 
#define FC_SPI_COMPATIBLE 14
#define FC_SPI_COMPATIBLE 15
#define MK3MAG_I2C_COMPATIBLE 3
 
// FC FLAGS
// tbd: Trennen in Error Flags und Status Flags!!!
// aufnehmen.
#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_I2CERR 0x80
// 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
 
// FC ERRORS FLAGS
#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
 
#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
 
// NC Errors
#define NCERR_FLAG_FC_COMPATIBLE 0x00000001
#define NCERR_FLAG_MK3MAG_COMPATIBLE 0x00000002
44,7 → 61,7
extern u8 BoardRelease;
extern u16 BeepTime;
extern u8 NCFlags;
extern u8 ClearFCFlags;
extern u8 ClearFCStatusFlags;
void Interrupt_Init(void);
extern s16 GeoMagDec;
 
95,7 → 112,8
u8 BAT_Voltage;
u16 BAT_Current;
u16 BAT_UsedCapacity;
u8 Flags;
u8 StatusFlags;
u8 Error[5];
} __attribute__((packed)) FC_t;
 
 
/trunk/spi_slave.c
92,7 → 92,6
volatile u8 SPI_RxBufferIndex = 0;
volatile u8 SPI_RxBuffer_Request = 0;
#define SPI_COMMAND_INDEX 0
volatile u8 FC_ErrorCode[5] = {0,0,0,0,0};
 
s32 Kalman_K = 32;
s32 Kalman_MaxDrift = 5 * 16;
106,8 → 105,6
 
SPI_Version_t FC_Version;
 
 
 
//--------------------------------------------------------------
void SSP0_IRQHandler(void)
{
335,15 → 332,15
Parameter.User6 = FromFlightCtrl.Param.Byte[5];
Parameter.User7 = FromFlightCtrl.Param.Byte[6];
Parameter.User8 = FromFlightCtrl.Param.Byte[7];
if(ClearFCFlags)
if(ClearFCStatusFlags)
{
FC.Flags = 0;
ClearFCFlags = 0;
FC.StatusFlags = 0;
ClearFCStatusFlags = 0;
}
FC.Flags |= FromFlightCtrl.Param.Byte[8];
FC.StatusFlags |= FromFlightCtrl.Param.Byte[8];
Parameter.ActiveSetting = FromFlightCtrl.Param.Byte[9];
DebugOut.Analog[5] = FC.Flags;
NaviData.FCFlags = FC.Flags;
DebugOut.Analog[5] = FC.StatusFlags;
NaviData.FCStatusFlags = FC.StatusFlags;
HeadFreeStartAngle = (s32) FromFlightCtrl.Param.Byte[10] * 20; // convert to 0.1°
break;
 
429,12 → 426,14
FC_Version.Patch = FromFlightCtrl.Param.Byte[2];
FC_Version.Compatible = FromFlightCtrl.Param.Byte[3];
FC_Version.Hardware = FromFlightCtrl.Param.Byte[4];
FC_ErrorCode[0] = FromFlightCtrl.Param.Byte[5];
FC_ErrorCode[1] = FromFlightCtrl.Param.Byte[6];
FC_ErrorCode[2] = FromFlightCtrl.Param.Byte[7];
FC.Error[0] = FromFlightCtrl.Param.Byte[5];
FC.Error[1] = FromFlightCtrl.Param.Byte[6];
FC.Error[2] = FromFlightCtrl.Param.Byte[7];
FC.Error[3] = FromFlightCtrl.Param.Byte[8];
FC.Error[4] = FromFlightCtrl.Param.Byte[9];
DebugOut.Status[0] |= 0x01; // status of FC Present
DebugOut.Status[0] |= 0x02; // status of BL Present
if(FC_ErrorCode[0] || FC_ErrorCode[1] || FC_ErrorCode[2]) DebugOut.Status[1] |= 0x01;
if(FC.Error[0] || FC.Error[1] || FC.Error[2] || FC.Error[3] || FC.Error[4]) DebugOut.Status[1] |= 0x01;
else DebugOut.Status[1] &= ~0x01;
break;
default:
444,7 → 443,7
// every time we got new data from the FC via SPI call the navigation routine
// and update GPSStick that are returned to FC
GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick));
ClearFCFlags = 1;
ClearFCStatusFlags = 1;
 
if(counter)
{
/trunk/spi_slave.h
21,7 → 21,6
extern s32 ToFcGpsZ;
extern s32 ToFC_Rotate_C, ToFC_Rotate_S;
extern s32 HeadFreeStartAngle;
extern volatile u8 FC_ErrorCode[5];
 
typedef struct
{
/trunk/uart1.c
421,7 → 421,7
DebugUART = UART2;
break;
case UART_MK3MAG:
if(FC.Flags & FCFLAG_MOTOR_RUN) break; // not if the motors are running
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN) break; // not if the motors are running
UART0_Connect_to_MK3MAG(); // mux UART0 to MK3MAG pins
GPSData.Status = INVALID;
fifo_purge(&UART1_rx_fifo);
428,7 → 428,7
DebugUART = UART0;
break;
case UART_MKGPS:
if(FC.Flags & FCFLAG_MOTOR_RUN) break; // not if the motors are running
if(FC.StatusFlags & FC_STATUS_MOTOR_RUN) break; // not if the motors are running
TIMER2_Deinit(); // disable servo outputs to reduce irq load
UART0_Connect_to_MKGPS(UART0_BAUD_RATE); // connect UART0 to MKGPS pins
GPSData.Status = INVALID;
/trunk/uart1.h
93,7 → 93,7
s8 AngleNick; // current Nick angle in 1°
s8 AngleRoll; // current Rick angle in 1°
u8 RC_Quality; // RC_Quality
u8 FCFlags; // Flags from FC
u8 FCStatusFlags; // Flags from FC
u8 NCFlags; // Flags from NC
u8 Errorcode; // 0 --> okay
u8 OperatingRadius; // current operation radius around the Home Position in m