Subversion Repositories FlightCtrl

Rev

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

Rev 806 Rev 821
Line 82... Line 82...
82
ISR(TIMER1_OVF_vect)
82
ISR(TIMER1_OVF_vect)
83
{
83
{
84
        static uint16_t lastICR1 = 0;
84
        static uint16_t lastICR1 = 0;
85
        // if ICR1 has not changed
85
        // if ICR1 has not changed
86
        // then no new input capture event has occured since last timer overflow
86
        // then no new input capture event has occured since last timer overflow
87
        if (lastICR1 == ICR1) RC_Quality = 0;
87
        if (lastICR1 == ICR1) RC_Quality /= 2;
88
        lastICR1 = ICR1; // store last ICR1
88
        lastICR1 = ICR1; // store last ICR1
89
}
89
}
Line 90... Line 90...
90
 
90
 
Line 123... Line 123...
123
        // calculatiing the difference of the two uint16_t and converting the result to an int16_t
123
        // calculatiing the difference of the two uint16_t and converting the result to an int16_t
124
        // implicit handles a timer overflow 65535 -> 0 the right way.
124
        // implicit handles a timer overflow 65535 -> 0 the right way.
125
        signal = (uint16_t) ICR1 - oldICR1;
125
        signal = (uint16_t) ICR1 - oldICR1;
126
        oldICR1 = ICR1;
126
        oldICR1 = ICR1;
Line 127... Line -...
127
 
-
 
128
    // lost frame?
-
 
129
    if(signal > 8000)
-
 
130
    {
-
 
131
                RC_Quality /= 2;
-
 
132
        }
-
 
133
        else
127
 
134
    //sync gap? (3.52 ms < signal < 25.6 ms)
128
    //sync gap? (3.52 ms < signal < 25.6 ms)
135
        if((signal > 1100) && (signal < 8000))
129
        if((signal > 1100) && (signal < 8000))
136
        {
130
        {
137
                // if a sync gap happens and there where at least 4 channels decoded before
131
                // if a sync gap happens and there where at least 4 channels decoded before
Line 162... Line 156...
162
                // calculate signal difference on good signal level
156
                // calculate signal difference on good signal level
163
                if(RC_Quality >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for nois reduction
157
                if(RC_Quality >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for nois reduction
164
                else PPM_diff[index] = 0;
158
                else PPM_diff[index] = 0;
165
                PPM_in[index] = tmp; // update channel value
159
                PPM_in[index] = tmp; // update channel value
166
            }
160
            }
167
            else
-
 
168
            {   // invalid PPM time
-
 
169
                                RC_Quality /= 2;
-
 
170
                        }
-
 
171
            index++; // next channel
161
            index++; // next channel
172
            // demux sum signal for channels 5 to 7 to J3, J4, J5
162
            // demux sum signal for channels 5 to 7 to J3, J4, J5
173
                if(index == 5) PORTD |= (1<<PORTD5); else PORTD &= ~(1<<PORTD5);
163
                if(index == 5) PORTD |= (1<<PORTD5); else PORTD &= ~(1<<PORTD5);
174
                if(index == 6) PORTD |= (1<<PORTD4); else PORTD &= ~(1<<PORTD4);
164
                if(index == 6) PORTD |= (1<<PORTD4); else PORTD &= ~(1<<PORTD4);
175
                if(BoardRelease == 10)
165
                if(BoardRelease == 10)