Subversion Repositories FlightCtrl

Rev

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

Rev 903 Rev 909
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 170... Line 170...
170
        rxd_buffer_locked = FALSE;
170
        rxd_buffer_locked = FALSE;
171
        txd_complete = TRUE;
171
        txd_complete = TRUE;
Line 172... Line 172...
172
 
172
 
Line 173... Line 173...
173
        Debug_Timer = SetDelay(200);
173
        Debug_Timer = SetDelay(200);
174
 
174
 
175
        #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
175
        #ifdef USE_MK3MAG
Line 176... Line 176...
176
        Compass_Timer = SetDelay(220);
176
        Compass_Timer = SetDelay(220);
177
        #endif
177
        #endif
Line 213... Line 213...
213
        uint8_t crc1, crc2;
213
        uint8_t crc1, crc2;
214
        uint8_t c;
214
        uint8_t c;
Line 215... Line 215...
215
 
215
 
Line 216... Line 216...
216
        c = UDR0;  // catch the received byte
216
        c = UDR0;  // catch the received byte
217
 
217
 
218
        #ifdef USE_KILLAGREG
218
        #if defined (USE_KILLAGREG) || defined (USE_MK3MAG)
219
        // If the FC 1.0 cpu is used the ublox module should be conneced to rxd of the 1st uart.
219
        // If the FC 1.0 cpu is used the ublox module should be conneced to rxd of the 1st uart.
220
        // The FC 1.1 /1.2 has the ATMEGA644p cpu with a 2nd uart to which the ublox should be connected.
220
        // The FC 1.1 /1.2 has the ATMEGA644p cpu with a 2nd uart to which the ublox should be connected.
221
        #if defined (__AVR_ATmega644P__)
221
        #if defined (__AVR_ATmega644P__)
222
        if(BoardRelease == 10) ubx_parser(c);
222
        if(BoardRelease == 10) ubx_parser(c);
223
        #else
223
        #else
224
        ubx_parser(c);
224
        ubx_parser(c);
Line 225... Line 225...
225
        #endif
225
        #endif
Line 226... Line 226...
226
        #endif // USE_KILLAGREG
226
        #endif
227
 
227
 
Line 362... Line 362...
362
        uint8_t tmp_char_arr2[2]; // local char buffer
362
        uint8_t tmp_char_arr2[2]; // local char buffer
Line 363... Line 363...
363
 
363
 
364
 
364
 
365
        switch(rxd_buffer[2])
365
        switch(rxd_buffer[2])
366
        {
366
        {
367
                #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
367
                #ifdef USE_MK3MAG
368
                case 'K':// Compass value
368
                case 'K':// Compass value
369
                        Decode64((uint8_t *) &tmp_int_arr1[0], sizeof(tmp_int_arr1), 3, ReceivedBytes);
369
                        Decode64((uint8_t *) &tmp_int_arr1[0], sizeof(tmp_int_arr1), 3, ReceivedBytes);
370
                        CompassHeading = tmp_int_arr1[0];
370
                        CompassHeading = tmp_int_arr1[0];
Line 467... Line 467...
467
        {
467
        {
468
                SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl));
468
                SendOutData('G',MySlaveAddr,(uint8_t *) &ExternControl,sizeof(ExternControl));
469
                RequestExternalControl = FALSE;
469
                RequestExternalControl = FALSE;
470
        }
470
        }
Line 471... Line 471...
471
 
471
 
472
        #if  !defined (USE_KILLAGREG)  && !defined (USE_NAVICTRL)
472
        #ifdef USE_MK3MAG
473
    if((CheckDelay(Compass_Timer)) && txd_complete)
473
    if((CheckDelay(Compass_Timer)) && txd_complete)
474
        {
474
        {
475
                ToMk3Mag.Attitude[0] = (int16_t) (IntegralPitch / 108);  // approx. 0,1 Deg
475
                ToMk3Mag.Attitude[0] = (int16_t) (IntegralPitch / 108);  // approx. 0,1 Deg
476
                ToMk3Mag.Attitude[1] = (int16_t) (IntegralRoll / 108);   // approx. 0,1 Deg
476
                ToMk3Mag.Attitude[1] = (int16_t) (IntegralRoll / 108);   // approx. 0,1 Deg