|
|
@ -36,10 +36,10 @@ volatile int16_t timer4diff = 1500 * 2; |
|
|
|
#define CH_4 3 |
|
|
|
#define CH_4 3 |
|
|
|
|
|
|
|
|
|
|
|
volatile int8_t _rc_ch_read; |
|
|
|
volatile int8_t _rc_ch_read; |
|
|
|
volatile uint8_t _timer_out; |
|
|
|
volatile uint16_t _timer_out; |
|
|
|
volatile uint8_t _timer_ovf_a; |
|
|
|
volatile uint16_t _timer_ovf_a; |
|
|
|
volatile uint8_t _timer_ovf_b; |
|
|
|
volatile uint16_t _timer_ovf_b; |
|
|
|
volatile uint8_t _timer_ovf; |
|
|
|
volatile uint16_t _timer_ovf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AP_RC::AP_RC() |
|
|
|
AP_RC::AP_RC() |
|
|
@ -117,27 +117,33 @@ AP_RC::output_ch_pwm(uint8_t ch, uint16_t pwm) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch(ch){ |
|
|
|
switch(ch){ |
|
|
|
case CH_1: |
|
|
|
case CH_1: |
|
|
|
pwm <<= 1; |
|
|
|
pwm <<= 1; // multiplies by 2
|
|
|
|
OCR1A = pwm; |
|
|
|
OCR1A = pwm; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case CH_2: |
|
|
|
case CH_2: |
|
|
|
pwm <<= 1; |
|
|
|
pwm <<= 1; |
|
|
|
OCR1B = pwm; |
|
|
|
OCR1B = pwm; // multiplies by 2
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case CH_3: |
|
|
|
case CH_3: |
|
|
|
_timer_out = pwm % 512; |
|
|
|
_timer_out = pwm % 512; |
|
|
|
_timer_ovf_a = pwm / 512; |
|
|
|
_timer_ovf_a = pwm / 512; |
|
|
|
_timer_out >>= 1; |
|
|
|
_timer_out >>= 1; // divides by 2
|
|
|
|
OCR2A = _timer_out; |
|
|
|
//OCR2A = _timer_out;
|
|
|
|
|
|
|
|
if(OCR2A != _timer_out) |
|
|
|
|
|
|
|
OCR2A = _timer_out; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case CH_4: |
|
|
|
case CH_4: |
|
|
|
_timer_out = pwm % 512; |
|
|
|
_timer_out = pwm % 512; |
|
|
|
_timer_ovf_b = pwm / 512; |
|
|
|
_timer_ovf_b = pwm / 512; |
|
|
|
_timer_out >>= 1; |
|
|
|
_timer_out >>= 1; // divides by 2
|
|
|
|
OCR2B = _timer_out; |
|
|
|
//OCR2B = _timer_out;
|
|
|
|
|
|
|
|
if(OCR2B != _timer_out) |
|
|
|
|
|
|
|
OCR2B = _timer_out; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -211,10 +217,10 @@ ISR(PCINT0_vect) |
|
|
|
ISR(TIMER1_CAPT_vect) // Timer/Counter1 Capture Event
|
|
|
|
ISR(TIMER1_CAPT_vect) // Timer/Counter1 Capture Event
|
|
|
|
{ |
|
|
|
{ |
|
|
|
//This is a timer 1 interrupts, executed every 20us
|
|
|
|
//This is a timer 1 interrupts, executed every 20us
|
|
|
|
PORTB |= B00000001; //Putting the pin high!
|
|
|
|
PORTB |= B00000001; //Putting the pin high!
|
|
|
|
PORTC |= B00010000; //Putting the pin high!
|
|
|
|
PORTC |= B00010000; //Putting the pin high!
|
|
|
|
TCNT2 = 0; //restarting the counter of timer 2
|
|
|
|
TCNT2 = 0; //restarting the counter of timer 2
|
|
|
|
_timer_ovf = 0; |
|
|
|
_timer_ovf = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ISR(TIMER2_OVF_vect) |
|
|
|
ISR(TIMER2_OVF_vect) |
|
|
|