Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 357 → Rev 358

/trunk/gpx.c
394,14 → 394,18
sprintf(string, "<MagnetInclination>%02d,%02d</MagnetInclination>\r\n",(s16)EarthMagneticInclinationFiltered/10,(s16)(EarthMagneticInclinationFiltered/10 - EarthMagneticInclinationTheoretic));
fputs_(string, doc->file);
// BL Information
sprintf(string, "<MotorCurrent>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</MotorCurrent>\r\n",MotorCurrent[0],MotorCurrent[1],MotorCurrent[2],MotorCurrent[3],MotorCurrent[4],MotorCurrent[5],MotorCurrent[6],MotorCurrent[7],MotorCurrent[8],MotorCurrent[9],MotorCurrent[10],MotorCurrent[11]);
sprintf(string, "<MotorCurrent>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</MotorCurrent>\r\n",Motor[0].Current,Motor[1].Current,Motor[2].Current,Motor[3].Current,Motor[4].Current,Motor[5].Current,Motor[6].Current,Motor[7].Current,Motor[8].Current,Motor[9].Current,Motor[10].Current,Motor[11].Current);
fputs_(string, doc->file);
sprintf(string, "<BL_Temperature>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_Temperature>\r\n",MotorTemperature[0],MotorTemperature[1],MotorTemperature[2],MotorTemperature[3],MotorTemperature[4],MotorTemperature[5],MotorTemperature[6],MotorTemperature[7],MotorTemperature[8],MotorTemperature[9],MotorTemperature[10],MotorTemperature[11]);
sprintf(string, "<BL_Temperature>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_Temperature>\r\n",Motor[0].Temperature,Motor[1].Temperature,Motor[2].Temperature,Motor[3].Temperature,Motor[4].Temperature,Motor[5].Temperature,Motor[6].Temperature,Motor[7].Temperature,Motor[8].Temperature,Motor[9].Temperature,Motor[10].Temperature,Motor[11].Temperature);
fputs_(string, doc->file);
break;
case 6:
sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM);
/* sprintf(string, "<BL_State>0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x</BL_State>\r\n",Motor.State[0],Motor.State[1],Motor.State[2],Motor.State[3],Motor.State[4],Motor.State[5],Motor.State[6],Motor.State[7],Motor.State[8],Motor.State[9],Motor.State[10],Motor.State[11]);
fputs_(string, doc->file);
sprintf(string, "<BL_MaxPWM>%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d</BL_MaxPWM>\r\n",Motor.MaxPWM[0],Motor.MaxPWM[1],Motor.MaxPWM[2],Motor.MaxPWM[3],Motor.MaxPWM[4],Motor.MaxPWM[5],Motor.MaxPWM[6],Motor.MaxPWM[7],Motor.MaxPWM[8],Motor.MaxPWM[9],Motor.MaxPWM[10],Motor.MaxPWM[11]);
fputs_(string, doc->file);
*/ sprintf(string, "<AvaiableMotorPower>%03d</AvaiableMotorPower>\r\n",BL_MinOfMaxPWM);
fputs_(string, doc->file);
sprintf(string, "<FC_I2C_ErrorCounter>%03d</FC_I2C_ErrorCounter>\r\n",(s16)FC_I2C_ErrorConter);
fputs_(string, doc->file);
// Analog inputs of the NC
/trunk/main.h
39,7 → 39,7
#define VERSION_SERIAL_MINOR 0
 
#ifndef FOLLOW_ME
#define FC_SPI_COMPATIBLE 30
#define FC_SPI_COMPATIBLE 31
#else
#define FC_SPI_COMPATIBLE 0xFF
#endif
/trunk/spi_slave.c
113,8 → 113,7
u8 NC_GPS_ModeCharacter = ' ';
u8 FCCalibActive = 0;
u8 FC_is_Calibrated = 0;
u8 MotorCurrent[12];
u8 MotorTemperature[12];
Motor_t Motor[12];
u8 NC_To_FC_Flags = 0;
u8 BL_MinOfMaxPWM; // indication if all BL-controllers run on full power
u32 FC_I2C_ErrorConter;
603,10 → 602,10
FC.BAT_Voltage = FromFlightCtrl.Param.Byte[4];
Parameter.LowVoltageWarning = FromFlightCtrl.Param.Byte[5];
FromFC_VarioCharacter = FromFlightCtrl.Param.Byte[6];
Parameter.GlobalConfig = FromFlightCtrl.Param.Byte[7];
Parameter.ExtraConfig = FromFlightCtrl.Param.Byte[8];
MotorTemperature[FromFlightCtrl.Param.Byte[9]] = FromFlightCtrl.Param.Byte[10];
MotorCurrent[FromFlightCtrl.Param.Byte[9]] = FromFlightCtrl.Param.Byte[11];
Motor[FromFlightCtrl.Param.Byte[7]].MaxPWM = FromFlightCtrl.Param.Byte[8];
Motor[FromFlightCtrl.Param.Byte[7]].State = FromFlightCtrl.Param.Byte[9];
Motor[FromFlightCtrl.Param.Byte[7]].Temperature = FromFlightCtrl.Param.Byte[10];
Motor[FromFlightCtrl.Param.Byte[7]].Current = FromFlightCtrl.Param.Byte[11];
if(FromFC_VarioCharacter == '+' || FromFC_VarioCharacter == '-') // manual setpoint clears the NC-Parameter command
{
NCParams_ClearValue(NCPARAMS_ALTITUDE_RATE);
692,8 → 691,8
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];
Parameter.GlobalConfig = FromFlightCtrl.Param.Byte[8];
Parameter.ExtraConfig = FromFlightCtrl.Param.Byte[9];
Parameter.OrientationAngle = FromFlightCtrl.Param.Byte[10];
Parameter.GlobalConfig3 = FromFlightCtrl.Param.Byte[11];
DebugOut.StatusGreen |= AMPEL_FC; // status of FC Present
707,13 → 706,6
 
/*
//+++++++++++++++++++++++++++++++++++++++++++++++++++
// Einkommentieren, falls der Flug simultert werden soll
if(Parameter.User8 < 100) FC.StatusFlags = 0;
else
if(Parameter.User8 < 150) FC.StatusFlags = FC_STATUS_START;
else FC.StatusFlags = FC_STATUS_FLY | FC_STATUS_MOTOR_RUN;
BL_MinOfMaxPWM = 255;
//+++++++++++++++++++++++++++++++++++++++++++++++++++
*/
// every time we got new data from the FC via SPI call the navigation routine
// and update GPSStick that are returned to FC
/trunk/spi_slave.h
28,8 → 28,11
extern u8 NC_GPS_ModeCharacter;
extern u8 FC_is_Calibrated;
extern u8 FCCalibActive;
extern u8 MotorCurrent[12];
/*extern u8 MotorCurrent[12];
extern u8 MotorTemperature[12];
extern u8 MotorState[12];
extern u8 MotorMaxPwm[12];
*/
extern u8 BL_MinOfMaxPWM; // indication if all BL-controllers run on full power
extern u32 FC_I2C_ErrorConter;
extern u8 FromFC_VarioCharacter;
102,7 → 105,16
u8 Chksum;
} __attribute__((packed)) ToFlightCtrl_t;
 
typedef struct
{
u8 Current;
u8 Temperature;
u8 MaxPWM;
u8 State;
} __attribute__((packed)) Motor_t;
 
extern Motor_t Motor[12];
 
typedef struct
{
u8 Major;
/trunk/uart1.c
76,6 → 76,7
#include "params.h"
#include "fifo.h"
#include "debug.h"
#include "spi_slave.h"
#include "ftphelper.h"
 
#define FALSE 0
95,6 → 96,7
u8 UART1_Request_WritePoint = 0xFF;
u8 UART1_Request_ReadPoint = 0;
u8 UART1_Request_Data3D = FALSE;
u8 UART1_Request_MotorData = FALSE;
u8 UART1_Request_Echo = FALSE;
u8 UART1_Request_ParameterId = 0;
u8 UART1_Request_Parameter = FALSE;
181,6 → 183,8
u32 UART1_NaviData_Interval = 0; // in ms
u32 UART1_Data3D_Timer = 0;
u32 UART1_Data3D_Interval = 0; // in ms
u32 UART1_MotorData_Timer = 0;
u32 UART1_MotorData_Interval = 0; // in ms
u32 UART1_Display_Timer = 0;
u32 UART1_Display_Interval = 0; // in ms
 
550,6 → 554,12
UART1_AboTimeOut = SetDelay(ABO_TIMEOUT);
break;
 
case 'k': // request for Motor data;
UART1_MotorData_Interval = (u32) SerialMsg.pData[0] * 10;
if(UART1_MotorData_Interval > 0) UART1_Request_MotorData = TRUE;
UART1_AboTimeOut = SetDelay(ABO_TIMEOUT);
break;
 
case 'h':// reqest for display line
if((SerialMsg.pData[0]& 0x80) == 0x00)// old format
{
659,6 → 669,7
/**************************************************************/
void UART1_TransmitTxData(void)
{
static u8 motorindex1 = 255, motorindex2 = 0;
if(DebugUART != UART1) return;
 
if(CheckDelay(UART1_AboTimeOut))
728,10 → 739,29
}
else if((( (UART1_Data3D_Interval > 0) && CheckDelay(UART1_Data3D_Timer) ) || UART1_Request_Data3D) && (UART1_tx_buffer.Locked == FALSE))
{
Data3D.StickNick = FC.StickNick;
Data3D.StickRoll = FC.StickRoll;
Data3D.StickYaw = FC.StickYaw;
Data3D.StickGas = FC.StickGas;
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D));
UART1_Data3D_Timer = SetDelay(UART1_Data3D_Interval);
UART1_Request_Data3D = FALSE;
}
else if((((UART1_MotorData_Interval > 0) && CheckDelay(UART1_MotorData_Timer) ) || UART1_Request_MotorData) && (UART1_tx_buffer.Locked == FALSE))
{
do
{
motorindex1++;
motorindex1%=12;
if(!motorindex1) {motorindex2++; motorindex2 %= 12;};
if(motorindex1 == motorindex2) break;
}
while((Motor[motorindex1].State & 0x80) != 0x80); // skip unused Motors
 
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'K', NC_ADDRESS, 2, &motorindex1, sizeof(motorindex1),(u8 *)&Motor[motorindex1], sizeof(Motor_t));
UART1_MotorData_Timer = SetDelay(UART1_MotorData_Interval);
UART1_Request_MotorData = FALSE;
}
/*
else if(UART1_ConfirmFrame && (UART1_tx_buffer.Locked == FALSE))
{
/trunk/uart1.h
31,7 → 31,11
s16 AngleNick; // in 0.1 deg
s16 AngleRoll; // in 0.1 deg
s16 Heading; // in 0.1 deg
u8 reserve[8];
u8 StickNick;
u8 StickRoll;
u8 StickYaw;
u8 StickGas;
u8 reserve[4];
} __attribute__((packed)) Data3D_t;
 
extern Data3D_t Data3D;