Subversion Repositories NaviCtrl

Rev

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

Rev 312 Rev 321
Line 563... Line 563...
563
 
563
 
564
// --------------------------------------------------------
564
// --------------------------------------------------------
565
void NCMAG_Update(void)
565
void NCMAG_Update(void)
566
{
566
{
-
 
567
        static u32 TimerUpdate = 0;
Line 567... Line 568...
567
        static u32 TimerUpdate = 0;
568
        static u8 send_config = 0;
568
 
569
 
569
        if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present )
570
        if( (I2C_State == I2C_STATE_OFF) || !NCMAG_Present )
570
        {
571
        {
571
                Compass_Heading = -1;
572
                Compass_Heading = -1;
Line 572... Line 573...
572
                return;
573
                return;
573
        }
574
        }
-
 
575
 
-
 
576
        if(CheckDelay(TimerUpdate))
-
 
577
        {
-
 
578
       if(++send_config == 100)   // every two seconds 
-
 
579
            {
-
 
580
                 send_config = 0;
-
 
581
                 MagConfig.mode = MODE_CONTINUOUS;
-
 
582
             // activate positive bias field
-
 
583
             NCMAG_SetMagConfig();
-
 
584
                 TimerUpdate = SetDelay(15);    // back into the old time-slot
574
 
585
            }
575
        if(CheckDelay(TimerUpdate))
586
                else
576
        {
587
                {
577
                // check for new calibration state
588
                // check for new calibration state
-
 
589
                Compass_UpdateCalState();
578
                Compass_UpdateCalState();
590
                if(Compass_CalState) NCMAG_Calibrate();
-
 
591
                NCMAG_GetMagVector(); //Get new data;
579
                if(Compass_CalState) NCMAG_Calibrate();
592
                if(send_config == 99) TimerUpdate = SetDelay(5);    // next event is the re-configuration
580
                NCMAG_GetMagVector(); //Get new data;
593
                else TimerUpdate = SetDelay(20);    // every 20 ms are 50 Hz
Line 581... Line 594...
581
                TimerUpdate = SetDelay(20);    // every 20 ms are 50 Hz
594
                }
582
        }
595
        }