Subversion Repositories NaviCtrl

Rev

Rev 280 | Rev 285 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 280 Rev 284
Line 64... Line 64...
64
#include "compass.h"
64
#include "compass.h"
65
#include "timer1.h"
65
#include "timer1.h"
66
#include "timer2.h"
66
#include "timer2.h"
67
#include "config.h"
67
#include "config.h"
68
#include "main.h"
68
#include "main.h"
69
#include "compass.h" 
69
#include "compass.h"
Line 70... Line 70...
70
 
70
 
71
 
71
 
72
#define SPI_RXSYNCBYTE1 0xAA
72
#define SPI_RXSYNCBYTE1 0xAA
Line 278... Line 278...
278
                // avoid sending data via SPI during the update of the  ToFlightCtrl structure
278
                // avoid sending data via SPI during the update of the  ToFlightCtrl structure
279
                VIC_ITCmd(SSP0_ITLine, DISABLE); // disable SPI interrupt
279
                VIC_ITCmd(SSP0_ITLine, DISABLE); // disable SPI interrupt
280
                ToFlightCtrl.CompassHeading = Compass_Heading;
280
                ToFlightCtrl.CompassHeading = Compass_Heading;
281
                DebugOut.Analog[10] = ToFlightCtrl.CompassHeading;
281
                DebugOut.Analog[10] = ToFlightCtrl.CompassHeading;
282
                if(ToFlightCtrl.CompassHeading >= 0) ToFlightCtrl.CompassHeading = (360 + ToFlightCtrl.CompassHeading + FromFlightCtrl.GyroYaw / 12) % 360;
282
                if(ToFlightCtrl.CompassHeading >= 0) ToFlightCtrl.CompassHeading = (360 + ToFlightCtrl.CompassHeading + FromFlightCtrl.GyroYaw / 12) % 360;
-
 
283
                ToFlightCtrl.MagVecX = MagVector.X;
-
 
284
                ToFlightCtrl.MagVecY = MagVector.Y;
-
 
285
                ToFlightCtrl.MagVecZ = MagVector.Z;
-
 
286
                ToFlightCtrl.NCStatus = 0;
283
                // cycle spi commands
287
                // cycle spi commands
284
                ToFlightCtrl.Command = SPI_CommandSequence[SPI_CommandCounter++];
288
                ToFlightCtrl.Command = SPI_CommandSequence[SPI_CommandCounter++];
285
                // restart command cycle at the end
289
                // restart command cycle at the end
286
                if (SPI_CommandCounter >= sizeof(SPI_CommandSequence)) SPI_CommandCounter = 0;
290
                if (SPI_CommandCounter >= sizeof(SPI_CommandSequence)) SPI_CommandCounter = 0;
Line 349... Line 353...
349
                                {
353
                                {
350
                                        FC.StatusFlags = 0;
354
                                        FC.StatusFlags = 0;
351
                                        ClearFCStatusFlags = 0;
355
                                        ClearFCStatusFlags = 0;
352
                                }
356
                                }
353
                                FC.StatusFlags |= FromFlightCtrl.Param.Byte[8];
357
                                FC.StatusFlags |= FromFlightCtrl.Param.Byte[8];
354
                                if(FC.StatusFlags&FC_STATUS_CALIBRATE && !FCCalibActive)
358
                                if(FC.StatusFlags&FC_STATUS_CALIBRATE && !FCCalibActive)
355
                                {
359
                                {
356
                                        Compass_Init();
360
                                        Compass_Init();
357
                                        FCCalibActive = 1;
361
                                        FCCalibActive = 1;
358
                                }
362
                                }
359
                                else
363
                                else
360
                                {
364
                                {
361
                                        FCCalibActive = 0;     
365
                                        FCCalibActive = 0;
362
                                }
366
                                }
363
                                Parameter.ActiveSetting = FromFlightCtrl.Param.Byte[9];
367
                                Parameter.ActiveSetting = FromFlightCtrl.Param.Byte[9];
364
                                DebugOut.Analog[5] = FC.StatusFlags;
368
                                DebugOut.Analog[5] = FC.StatusFlags;
365
                                NaviData.FCStatusFlags = FC.StatusFlags;
369
                                NaviData.FCStatusFlags = FC.StatusFlags;
366
                                HeadFreeStartAngle = (s32) FromFlightCtrl.Param.Byte[10] * 20; // convert to 0.1°
370
                                HeadFreeStartAngle = (s32) FromFlightCtrl.Param.Byte[10] * 20; // convert to 0.1°