Subversion Repositories FlightCtrl

Rev

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

Rev 821 Rev 832
Line 18... Line 18...
18
volatile int16_t PPM_in[15]; //PPM24 supports 12 channels per frame
18
volatile int16_t PPM_in[15]; //PPM24 supports 12 channels per frame
19
volatile int16_t PPM_diff[15];
19
volatile int16_t PPM_diff[15];
20
volatile uint8_t NewPpmData = 1;
20
volatile uint8_t NewPpmData = 1;
21
volatile int16_t RC_Quality = 0;
21
volatile int16_t RC_Quality = 0;
Line -... Line 22...
-
 
22
 
-
 
23
volatile uint8_t NewRCFrames = 0;
Line 22... Line 24...
22
 
24
 
23
 
25
 
24
/***************************************************************/
26
/***************************************************************/
25
/*  16bit timer 1 is used to decode the PPM-Signal            */
27
/*  16bit timer 1 is used to decode the PPM-Signal            */
Line 76... Line 78...
76
    SREG = sreg;
78
    SREG = sreg;
77
}
79
}
Line 78... Line 80...
78
 
80
 
79
 
81
 
80
// happens every 0.209712 s.
82
// happens every 0.209712 s.
81
// check for at least one input capture event per timer overflow (timeout)
83
// check for at least one new frame per timer overflow (timeout)
82
ISR(TIMER1_OVF_vect)
-
 
83
{
-
 
84
        static uint16_t lastICR1 = 0;
-
 
85
        // if ICR1 has not changed
84
ISR(TIMER1_OVF_vect)
86
        // then no new input capture event has occured since last timer overflow
85
{
87
        if (lastICR1 == ICR1) RC_Quality /= 2;
86
        if (NewRCFrames == 0) RC_Quality /= 2;
Line 88... Line 87...
88
        lastICR1 = ICR1; // store last ICR1
87
        NewRCFrames = 0;
89
}
88
}
Line 128... Line 127...
128
    //sync gap? (3.52 ms < signal < 25.6 ms)
127
    //sync gap? (3.52 ms < signal < 25.6 ms)
129
        if((signal > 1100) && (signal < 8000))
128
        if((signal > 1100) && (signal < 8000))
130
        {
129
        {
131
                // if a sync gap happens and there where at least 4 channels decoded before
130
                // if a sync gap happens and there where at least 4 channels decoded before
132
                // then the NewPpmData flag is reset indicating valid data in the PPM_in[] array.
131
                // then the NewPpmData flag is reset indicating valid data in the PPM_in[] array.
-
 
132
                if(index >= 4)
-
 
133
                {
133
                if(index >= 4)  NewPpmData = 0;  // Null means NewData for the first 4 channels
134
                        NewPpmData = 0;  // Null means NewData for the first 4 channels
-
 
135
                        NewRCFrames++;
-
 
136
                }
134
                // synchronize channel index
137
                // synchronize channel index
135
                index = 1;
138
                index = 1;
136
        }
139
        }
137
        else // within the PPM frame
140
        else // within the PPM frame
138
    {
141
    {