Switched APM_RC to uint16_t from int16_t for radio channels to fix servo bug in APM trunk.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@853 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
0e32cb34c5
commit
71076dad27
@ -30,7 +30,7 @@
|
||||
// Variable definition for Input Capture interrupt
|
||||
volatile unsigned int ICR4_old;
|
||||
volatile unsigned char PPM_Counter=0;
|
||||
volatile unsigned int PWM_RAW[8] = {2400,2400,2400,2400,2400,2400,2400,2400};
|
||||
volatile uint16_t PWM_RAW[8] = {2400,2400,2400,2400,2400,2400,2400,2400};
|
||||
volatile unsigned char radio_status=0;
|
||||
|
||||
/****************************************************
|
||||
@ -123,7 +123,7 @@ void APM_RC_Class::Init(void)
|
||||
TIMSK4 |= (1<<ICIE4); // Enable Input Capture interrupt. Timer interrupt mask
|
||||
}
|
||||
|
||||
void APM_RC_Class::OutputCh(unsigned char ch, int pwm)
|
||||
void APM_RC_Class::OutputCh(unsigned char ch, uint16_t pwm)
|
||||
{
|
||||
pwm=constrain(pwm,MIN_PULSEWIDTH,MAX_PULSEWIDTH);
|
||||
pwm<<=1; // pwm*2;
|
||||
@ -144,10 +144,10 @@ void APM_RC_Class::OutputCh(unsigned char ch, int pwm)
|
||||
}
|
||||
}
|
||||
|
||||
int APM_RC_Class::InputCh(unsigned char ch)
|
||||
uint16_t APM_RC_Class::InputCh(unsigned char ch)
|
||||
{
|
||||
int result;
|
||||
int result2;
|
||||
uint16_t result;
|
||||
uint16_t result2;
|
||||
|
||||
// Because servo pulse variables are 16 bits and the interrupts are running values could be corrupted.
|
||||
// We dont want to stop interrupts to read radio channels so we have to do two readings to be sure that the value is correct...
|
||||
|
@ -5,14 +5,16 @@
|
||||
#define MIN_PULSEWIDTH 900
|
||||
#define MAX_PULSEWIDTH 2100
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
class APM_RC_Class
|
||||
{
|
||||
private:
|
||||
public:
|
||||
APM_RC_Class();
|
||||
void Init();
|
||||
void OutputCh(unsigned char ch, int pwm);
|
||||
int InputCh(unsigned char ch);
|
||||
void OutputCh(unsigned char ch, uint16_t pwm);
|
||||
uint16_t InputCh(unsigned char ch);
|
||||
unsigned char GetState();
|
||||
void Force_Out0_Out1(void);
|
||||
void Force_Out2_Out3(void);
|
||||
@ -21,4 +23,4 @@ class APM_RC_Class
|
||||
|
||||
extern APM_RC_Class APM_RC;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user