Subversion Repositories FlightCtrl

Rev

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

Rev 886 Rev 908
Line 15... Line 15...
15
#include "timer0.h"
15
#include "timer0.h"
16
#include "uart.h"
16
#include "uart.h"
17
#include "fc.h"
17
#include "fc.h"
18
#include "_Settings.h"
18
#include "_Settings.h"
19
#include "rc.h"
19
#include "rc.h"
20
#ifdef USE_KILLAGREG
20
#if defined (USE_KILLAGREG) || defined (USE_MK3MAG)
21
#include "ubx.h"
21
#include "ubx.h"
22
#endif
22
#endif
23
#if !defined(USE_KILLAGREG) && !defined (USE_NAVICTRL)
23
#ifdef USE_MK3MAG
24
#include "mk3mag.h"
24
#include "mk3mag.h"
25
#endif
25
#endif
Line 55... Line 55...
55
ExternControl_t ExternControl;
55
ExternControl_t ExternControl;
56
VersionInfo_t   VersionInfo;
56
VersionInfo_t   VersionInfo;
Line 57... Line 57...
57
 
57
 
Line 58... Line 58...
58
int16_t  Debug_Timer;
58
int16_t  Debug_Timer;
59
 
59
 
60
#if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
60
#ifdef USE_MK3MAG
Line 61... Line 61...
61
int16_t Compass_Timer;
61
int16_t Compass_Timer;
Line 161... Line 161...
161
        rxd_buffer_locked = FALSE;
161
        rxd_buffer_locked = FALSE;
162
        txd_complete = TRUE;
162
        txd_complete = TRUE;
Line 163... Line 163...
163
 
163
 
Line 164... Line 164...
164
        Debug_Timer = SetDelay(200);
164
        Debug_Timer = SetDelay(200);
165
 
165
 
166
        #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
166
        #ifdef USE_MK3MAG
Line 167... Line 167...
167
        Compass_Timer = SetDelay(220);
167
        Compass_Timer = SetDelay(220);
168
        #endif
168
        #endif
Line 204... Line 204...
204
        uint8_t crc1, crc2;
204
        uint8_t crc1, crc2;
205
        uint8_t c;
205
        uint8_t c;
Line 206... Line 206...
206
 
206
 
Line 207... Line 207...
207
        c = UDR0;  // catch the received byte
207
        c = UDR0;  // catch the received byte
208
 
208
 
209
        #ifdef USE_KILLAGREG
209
        #if defined (USE_KILLAGREG) || defined (USE_MK3MAG)
210
        // If the FC 1.0 cpu is used the ublox module should be conneced to rxd of the 1st uart.
210
        // If the FC 1.0 cpu is used the ublox module should be conneced to rxd of the 1st uart.
211
        // The FC 1.1 /1.2 has the ATMEGA644p cpu with a 2nd uart to which the ublox should be connected.
211
        // The FC 1.1 /1.2 has the ATMEGA644p cpu with a 2nd uart to which the ublox should be connected.
212
        #if defined (__AVR_ATmega644P__)
212
        #if defined (__AVR_ATmega644P__)
213
        if(BoardRelease == 10) ubx_parser(c);
213
        if(BoardRelease == 10) ubx_parser(c);
214
        #else
214
        #else
215
        ubx_parser(c);
215
        ubx_parser(c);
Line 216... Line 216...
216
        #endif
216
        #endif
Line 217... Line 217...
217
        #endif // USE_KILLAGREG
217
        #endif
218
 
218
 
Line 353... Line 353...
353
        uint8_t tmp_char_arr2[2]; // local char buffer
353
        uint8_t tmp_char_arr2[2]; // local char buffer
Line 354... Line 354...
354
 
354
 
355
 
355
 
356
        switch(rxd_buffer[2])
356
        switch(rxd_buffer[2])
357
        {
357
        {
358
                #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
358
                #ifdef USE_MK3MAG
359
                case 'K':// Compass value
359
                case 'K':// Compass value
360
                        Decode64((uint8_t *) &tmp_int_arr1[0], sizeof(tmp_int_arr1), 3, ReceivedBytes);
360
                        Decode64((uint8_t *) &tmp_int_arr1[0], sizeof(tmp_int_arr1), 3, ReceivedBytes);
361
                        CompassHeading = tmp_int_arr1[0];
361
                        CompassHeading = tmp_int_arr1[0];
Line 458... Line 458...
458
        {
458
        {
459
                SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl));
459
                SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl));
460
                RequestExternalControl = FALSE;
460
                RequestExternalControl = FALSE;
461
        }
461
        }
Line 462... Line 462...
462
 
462
 
463
        #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
463
        #ifdef USE_MK3MAG
464
    if((CheckDelay(Compass_Timer)) && txd_complete)
464
    if((CheckDelay(Compass_Timer)) && txd_complete)
465
        {
465
        {
466
                ToMk3Mag.Attitude[0] = (int16_t) (IntegralPitch / 108);  // approx. 0,1 Deg
466
                ToMk3Mag.Attitude[0] = (int16_t) (IntegralPitch / 108);  // approx. 0,1 Deg
467
                ToMk3Mag.Attitude[1] = (int16_t) (IntegralRoll / 108);   // approx. 0,1 Deg
467
                ToMk3Mag.Attitude[1] = (int16_t) (IntegralRoll / 108);   // approx. 0,1 Deg