preparing for DIP switch functions

git-svn-id: https://arducopter.googlecode.com/svn/trunk@686 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jphelirc 2010-10-18 08:26:08 +00:00
parent 84697f4111
commit 669bde1e45
3 changed files with 50 additions and 1 deletions

View File

@ -205,6 +205,12 @@ int control_pitch;
int control_yaw;
//float K_aux;
boolean SW_DIP1; // closest to SW2 slider switch
boolean SW_DIP2;
boolean SW_DIP3;
boolean SW_DIP4; // closest to header pins
// Attitude PID controls
float roll_I=0;
float roll_D;

View File

@ -111,4 +111,24 @@ int channel_filter(int ch, int ch_old)
}
return((ch + ch_old) >> 1); // Small filtering
//return(ch);
}
}
// Special APM PinMode settings and others
void APMPinMode(volatile unsigned char &Port, byte Pin, boolean Set)
{
if (Set) {
Port |= (1 << Pin);
} else {
Port &= ~(1 << Pin);
}
}
boolean APMPinRead(volatile unsigned char &Port, byte Pin)
{
if(Port & (1 << Pin))
return 1;
else
return 0;
}

View File

@ -41,6 +41,13 @@ void APM_Init() {
pinMode(LED_Green,OUTPUT); //Green LED C (PC0)
pinMode(SW1_pin,INPUT); //Switch SW1 (pin PG0)
pinMode(RELE_pin,OUTPUT); // Rele output
APMPinMode(DDRE,7,INPUT); //DIP1
APMPinMode(DDRE,6,INPUT); //DIP2
APMPinMode(DDRL,6,INPUT); //DIP3
APMPinMode(DDRL,7,INPUT); //DIP4
digitalWrite(RELE_pin,LOW);
APM_RC.Init(); // APM Radio initialization
@ -122,6 +129,22 @@ void APM_Init() {
delay(1000);
// Read DIP Switches and other important values. DIP switches needs special functions to
// read due they are not defined as normal pins like other GPIO's are.
SW_DIP1 = APMPinRead(PINE, 7);
SW_DIP2 = APMPinRead(PINE, 6);
SW_DIP3 = APMPinRead(PINL, 6);
SW_DIP4 = APMPinRead(PINL, 7);
/* Works, tested 18-10-10 JP
if(SW_DIP1) {
SerPrln("+ mode");
} else {
SerPrln("x mode");
}
*/
DataFlash.StartWrite(1); // Start a write session on page 1
//timer = millis();
//tlmTimer = millis();