From a65098f055768fb5d05676df907e2c653a226e6a Mon Sep 17 00:00:00 2001 From: jasonshort Date: Mon, 23 Aug 2010 21:41:08 +0000 Subject: [PATCH] git-svn-id: https://arducopter.googlecode.com/svn/trunk@281 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/APM_RC/APM_RC.cpp | 187 ---------------------------------- libraries/APM_RC/APM_RC.h | 24 ----- libraries/APM_RC/keywords.txt | 8 -- 3 files changed, 219 deletions(-) delete mode 100644 libraries/APM_RC/APM_RC.cpp delete mode 100644 libraries/APM_RC/APM_RC.h delete mode 100644 libraries/APM_RC/keywords.txt diff --git a/libraries/APM_RC/APM_RC.cpp b/libraries/APM_RC/APM_RC.cpp deleted file mode 100644 index 9a85b33425..0000000000 --- a/libraries/APM_RC/APM_RC.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - APM_RC.cpp - Radio Control Library for Ardupilot Mega. Arduino - Code by Jordi Muņoz and Jose Julio. DIYDrones.com - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - RC Input : PPM signal on IC4 pin - RC Output : 11 Servo outputs (standard 20ms frame) - - Methods: - Init() : Initialization of interrupts an Timers - OutpuCh(ch,pwm) : Output value to servos (range : 900-2100us) ch=0..10 - InputCh(ch) : Read a channel input value. ch=0..7 - GetState() : Returns the state of the input. 1 => New radio frame to process - Automatically resets when we call InputCh to read channels - -*/ -#include "APM_RC.h" - -#include -#include "WProgram.h" - -// 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 unsigned char radio_status=0; - -/**************************************************** - Input Capture Interrupt ICP4 => PPM signal read - ****************************************************/ -ISR(TIMER4_CAPT_vect) -{ - unsigned int Pulse; - unsigned int Pulse_Width; - - Pulse=ICR4; - if (Pulse8000) // SYNC pulse? - PPM_Counter=0; - else - { - PPM_Counter &= 0x07; // For safety only (limit PPM_Counter to 7) - PWM_RAW[PPM_Counter++]=Pulse_Width; //Saving pulse. - if (PPM_Counter >= NUM_CHANNELS) - radio_status = 1; - } - ICR4_old = Pulse; -} - - -// Constructors //////////////////////////////////////////////////////////////// - -APM_RC_Class::APM_RC_Class() -{ -} - -// Public Methods ////////////////////////////////////////////////////////////// -void APM_RC_Class::Init(void) -{ - // Init PWM Timer 1 - pinMode(11,OUTPUT); // (PB5/OC1A) - pinMode(12,OUTPUT); //OUT2 (PB6/OC1B) - pinMode(13,OUTPUT); //OUT3 (PB7/OC1C) - - //Remember the registers not declared here remains zero by default... - TCCR1A =((1<>1; // Because timer runs at 0.5us we need to do value/2 - result2 = PWM_RAW[ch]>>1; - if (result != result2) - result = PWM_RAW[ch]>>1; // if the results are different we make a third reading (this should be fine) - - // Limit values to a valid range - result = constrain(result,MIN_PULSEWIDTH,MAX_PULSEWIDTH); - radio_status=0; // Radio channel read - return(result); -} - -unsigned char APM_RC_Class::GetState(void) -{ - return(radio_status); -} - -// InstantPWM implementation -// This function forces the PWM output (reset PWM) on Out0 and Out1 (Timer5). For quadcopters use -void APM_RC_Class::Force_Out0_Out1(void) -{ - if (TCNT5>5000) // We take care that there are not a pulse in the output - TCNT5=39990; // This forces the PWM output to reset in 5us (10 counts of 0.5us). The counter resets at 40000 -} -// This function forces the PWM output (reset PWM) on Out2 and Out3 (Timer1). For quadcopters use -void APM_RC_Class::Force_Out2_Out3(void) -{ - if (TCNT1>5000) - TCNT1=39990; -} -// This function forces the PWM output (reset PWM) on Out6 and Out7 (Timer3). For quadcopters use -void APM_RC_Class::Force_Out6_Out7(void) -{ - if (TCNT3>5000) - TCNT3=39990; -} - -// make one instance for the user to use -APM_RC_Class APM_RC; \ No newline at end of file diff --git a/libraries/APM_RC/APM_RC.h b/libraries/APM_RC/APM_RC.h deleted file mode 100644 index b3fa06da44..0000000000 --- a/libraries/APM_RC/APM_RC.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef APM_RC_h -#define APM_RC_h - -#define NUM_CHANNELS 8 -#define MIN_PULSEWIDTH 900 -#define MAX_PULSEWIDTH 2100 - -class APM_RC_Class -{ - private: - public: - APM_RC_Class(); - void Init(); - void OutputCh(unsigned char ch, int pwm); - int InputCh(unsigned char ch); - unsigned char GetState(); - void Force_Out0_Out1(void); - void Force_Out2_Out3(void); - void Force_Out6_Out7(void); -}; - -extern APM_RC_Class APM_RC; - -#endif \ No newline at end of file diff --git a/libraries/APM_RC/keywords.txt b/libraries/APM_RC/keywords.txt deleted file mode 100644 index 3efcc0fa52..0000000000 --- a/libraries/APM_RC/keywords.txt +++ /dev/null @@ -1,8 +0,0 @@ -APM_RC KEYWORD1 -begin KEYWORD2 -InputCh KEYWORD2 -OutputCh KEYWORD2 -GetState KEYWORD2 -Force_Out0_Out1 KEYWORD2 -Force_Out2_Out3 KEYWORD2 -Force_Out6_Out7 KEYWORD2