Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1213 → Rev 1214

/branches/V0.72p Code Redesign killagreg/rc.c
60,7 → 60,6
volatile uint8_t NewPpmData = 1;
volatile int16_t RC_Quality = 0;
 
volatile uint8_t NewRCFrames = 0;
 
 
/***************************************************************/
110,8 → 109,8
// Enable Input Capture Interrupt (bit: ICIE1=1)
// Disable Output Compare A & B Match Interrupts (bit: OCIE1B=0, OICIE1A=0)
// Enable Overflow Interrupt (bit: TOIE1=0)
TIMSK1 &= ~((1<<OCIE1B)|(1<<OCIE1A));
TIMSK1 |= (1<<ICIE1)|(1<<TOIE1);
TIMSK1 &= ~((1<<OCIE1B)|(1<<OCIE1A)|(1<<TOIE1));
TIMSK1 |= (1<<ICIE1);
 
RC_Quality = 0;
 
119,15 → 118,6
}
 
 
// happens every 0.209712 s.
// check for at least one new frame per timer overflow (timeout)
ISR(TIMER1_OVF_vect)
{
if (NewRCFrames == 0) RC_Quality -= RC_Quality/8;
NewRCFrames = 0;
}
 
 
/********************************************************************/
/* Every time a positive edge is detected at PD6 */
/********************************************************************/
169,10 → 159,9
{
// if a sync gap happens and there where at least 4 channels decoded before
// then the NewPpmData flag is reset indicating valid data in the PPM_in[] array.
if(index == 4)
if(index >= 4)
{
NewPpmData = 0; // Null means NewData for the first 4 channels
NewRCFrames++;
}
// synchronize channel index
index = 1;
188,7 → 177,7
// shift signal to zero symmetric range -154 to 159
signal -= 466; // offset of 1.4912 ms ??? (469 * 3.2µs = 1.5008 ms)
// check for stable signal
if(abs(signal-PPM_in[index]) < 6)
if(abs(signal - PPM_in[index]) < 6)
{
if(RC_Quality < 200) RC_Quality +=10;
else RC_Quality = 200;
212,7 → 201,6
}
}
}
if(RC_Quality) RC_Quality--;
}