|
|
@ -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;
|
|
|
|
|
|
|
|
if(OCR2A != _timer_out) |
|
|
|
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;
|
|
|
|
|
|
|
|
if(OCR2B != _timer_out) |
|
|
|
OCR2B = _timer_out; |
|
|
|
OCR2B = _timer_out; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|