Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2011 → Rev 2012

/trunk/eeprom.c
221,6 → 221,8
EE_Parameter.AchsKopplung1 = 90;
EE_Parameter.AchsKopplung2 = 55;
EE_Parameter.FailsafeChannel = 0;
EE_Parameter.ServoFilterNick = 0;
EE_Parameter.ServoFilterRoll = 0;
}
/*
void ParamSet_DefaultSet1(void) // sport
/trunk/eeprom.h
4,7 → 4,7
#include <inttypes.h>
#include "twimaster.h"
 
#define EEPARAM_REVISION 89 // is count up, if paramater stucture has changed (compatibility)
#define EEPARAM_REVISION 90 // is count up, if paramater stucture has changed (compatibility)
#define EEMIXER_REVISION 1 // is count up, if mixer stucture has changed (compatibility)
 
#define EEPROM_ADR_PARAM_BEGIN 0
226,6 → 226,8
unsigned char FailSafeTime;
unsigned char MaxAltitude;
unsigned char FailsafeChannel; // if the value of this channel is > 100, the MK reports "RC-Lost"
unsigned char ServoFilterNick;
unsigned char ServoFilterRoll;
//------------------------------------------------
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt
unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen
/trunk/fc.c
588,9 → 588,15
CHK_POTI_MM(Parameter_Gyro_P,EE_Parameter.Gyro_P,10,255);
CHK_POTI_MM(Parameter_J16Timing,EE_Parameter.J16Timing,5,255);
CHK_POTI_MM(Parameter_J17Timing,EE_Parameter.J17Timing,5,255);
CHK_POTI(Parameter_Servo3,EE_Parameter.Servo3);
CHK_POTI(Parameter_Servo4,EE_Parameter.Servo4);
CHK_POTI(Parameter_Servo5,EE_Parameter.Servo5);
 
if(EE_Parameter.Servo3 == 247) { if(PORTC & (1<<PORTC2)) Parameter_Servo3 = 130; else Parameter_Servo3 = 80;}
else if(EE_Parameter.Servo3 == 246) { if(PORTC & (1<<PORTC3)) Parameter_Servo3 = 130; else Parameter_Servo3 = 80;}
else CHK_POTI(Parameter_Servo3,EE_Parameter.Servo3);
 
if(EE_Parameter.Servo4 == 247) { if(PORTC & (1<<PORTC2)) Parameter_Servo4 = 130; else Parameter_Servo4 = 80;}
else if(EE_Parameter.Servo4 == 246) { if(PORTC & (1<<PORTC3)) Parameter_Servo4 = 130; else Parameter_Servo4 = 80;}
else CHK_POTI(Parameter_Servo4,EE_Parameter.Servo4);
 
CHK_POTI(Parameter_HoehenSchalter,EE_Parameter.MaxHoehe);
CHK_POTI(Parameter_Hoehe_ACC_Wirkung,EE_Parameter.Hoehe_ACC_Wirkung);
CHK_POTI(Parameter_Hoehe_GPS_Z,EE_Parameter.Hoehe_GPS_Z);
/trunk/libfc1284.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/libfc644.a
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/main.c
297,6 → 297,11
LIBFC_Polling();
 
if(!UpdateMotor)
{
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
if(NewSBusData) ProcessSBus();
else
#endif
{
if(CalculateServoSignals) CalculateServo();
DatenUebertragung();
408,7 → 413,8
Capacity_Update();
} //else DebugOut.Analog[26]++;
}
if(!SendSPI) { SPI_TransmitByte(); }
}
if(!SendSPI) { SPI_TransmitByte(); }
}
return (1);
}
/trunk/main.h
69,8 → 69,8
#include "libfc.h"
#include "hottmenu.h"
#include "debug.h"
#include "sbus.h"
 
 
#endif //_MAIN_H
 
 
/trunk/makefile
6,7 → 6,7
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 87
VERSION_PATCH = 2
VERSION_PATCH = 3
VERSION_SERIAL_MAJOR = 11 # Serial Protocol
VERSION_SERIAL_MINOR = 0 # Serial Protocol
NC_SPI_COMPATIBLE = 29 # Navi-Kompatibilität
/trunk/sbus.c
0,0 → 1,147
/*#######################################################################################
Decodes the sbus protocol
#######################################################################################*/
 
#include "sbus.h"
#include "main.h"
 
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
unsigned char NewSBusData = 0, sBusBuffer[25];
 
//############################################################################
// USART1 initialisation from killagreg
void SbusUartInit(void)
//############################################################################
{
// -- Start of USART1 initialisation for Spekturm seriell-mode
// USART1 Control and Status Register A, B, C and baud rate register
uint8_t sreg = SREG;
uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * 100000) - 1);
// disable all interrupts before reconfiguration
cli();
// disable RX-Interrupt
UCSR1B &= ~(1 << RXCIE1);
// disable TX-Interrupt
UCSR1B &= ~(1 << TXCIE1);
// disable DRE-Interrupt
UCSR1B &= ~(1 << UDRIE1);
// set direction of RXD1 and TXD1 pins
// set RXD1 (PD2) as an input pin
PORTD |= (1 << PORTD2);
DDRD &= ~(1 << DDD2);
 
// set TXD1 (PD3) as an output pin
PORTD |= (1 << PORTD3);
DDRD |= (1 << DDD3);
// USART0 Baud Rate Register
// set clock divider
UBRR1H = (uint8_t)(ubrr>>8);
UBRR1L = (uint8_t)ubrr;
// enable double speed operation
UCSR1A |= (1 << U2X1);
// enable receiver and transmitter
//UCSR1B = (1<<RXEN1)|(1<<TXEN1);
 
UCSR1B = (1<<RXEN1);
// set asynchronous mode
UCSR1C &= ~(1 << UMSEL11);
UCSR1C &= ~(1 << UMSEL10);
// parity
UCSR1C <= (1 << UPM11); // even
UCSR1C &= ~(1 << UPM10);
// stop bit
UCSR1C |= (1 << USBS1); // two
// 8-bit
UCSR1B &= ~(1 << UCSZ12);
UCSR1C |= (1 << UCSZ11);
UCSR1C |= (1 << UCSZ10);
// flush receive buffer explicit
while(UCSR1A & (1<<RXC1)) UDR1;
// enable RX-interrupts at the end
UCSR1B |= (1 << RXCIE1);
// -- End of USART1 initialisation
// restore global interrupt flags
SREG = sreg;
return;
}
 
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define MIN_FRAMEGAP 68 // 7ms
#define MAX_BYTEGAP 3 // 310us
 
//############################################################################
// Is called by the uart interrupt
//############################################################################
void SbusParser(unsigned char udr)
{
static unsigned char ptr = 0;
if(!SpektrumTimer && udr == 0x0f) // wait for the start
{
ptr = 0;
}
else
{
if(++ptr == 24) // last byte
{
NewSBusData = 1;
}
else
if(ptr > 24) ptr = 25;
else
{
sBusBuffer[ptr] = udr; // collect all bytes
}
}
SpektrumTimer = 100; // 10ms gap
}
 
void ProcessSBus(void)
{
static unsigned char load = 0;
unsigned char bitmask8 = 1, sbyte = 2, i, index = 1, process;
unsigned int bitmask11 = 256;
signed int signal = 0,tmp;
if(!(sBusBuffer[23] & 4)) // This Bit contains the 'Signal loss'
{
TIMSK1 &= ~_BV(ICIE1); // disable PPM-Input
if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe
{
if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;
}
signal = sBusBuffer[1];
if(!load--) { process = (12*11 - 8); load = 2;} else process = (4*11 - 8); // lowers the processor load
for(i = 0; i < process; i++) // collect the single bits
{
if(sBusBuffer[sbyte] & bitmask8) signal |= bitmask11;
bitmask8 *= 2;
if(!bitmask8)
{
bitmask8 = 1;
sbyte++;
}
bitmask11 *= 2;
if(bitmask11 == 2048)
{
bitmask11 = 1;
signal = (signal-1024) / 5; // the resolution is higher than required
tmp = (3 * (PPM_in[index]) + signal) / 4;
if(tmp > signal+1) tmp--; else
if(tmp < signal-1) tmp++;
if(SenderOkay >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3;
else PPM_diff[index] = 0;
PPM_in[index] = tmp;
signal = 0;
index++; // next channel
}
}
NewPpmData = 0; // Null bedeutet: Neue Daten
}
NewSBusData = 0;
}
 
#endif
/trunk/sbus.h
0,0 → 1,11
#ifndef _SBUS_H
#define _SBUS_H
 
#if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
extern unsigned char NewSBusData, sBusBuffer[25];
extern void SbusParser(unsigned char);
extern void SbusUartInit(void);
extern void ProcessSBus(void);
 
#endif
#endif
/trunk/timer0.c
212,7 → 212,7
{ // inverting movement of servo
nick = ServoNickOffset / 16 - nick;
}
if(Parameter_UserParam1) ServoNickValue = ((ServoNickValue * Parameter_UserParam1) + nick) / (Parameter_UserParam1 + 1);
if(EE_Parameter.ServoFilterNick) ServoNickValue = ((ServoNickValue * EE_Parameter.ServoFilterNick) + nick) / (EE_Parameter.ServoFilterNick + 1);
else ServoNickValue = nick;
// limit servo value to its parameter range definition
if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) )
239,7 → 239,7
{ // inverting movement of servo
roll = ServoRollOffset / 16 - roll;
}
if(Parameter_UserParam2) ServoRollValue = ((ServoRollValue * Parameter_UserParam2) + roll) / (Parameter_UserParam2 + 1);
if(EE_Parameter.ServoFilterRoll) ServoRollValue = ((ServoRollValue * EE_Parameter.ServoFilterRoll) + roll) / (EE_Parameter.ServoFilterRoll + 1);
else ServoRollValue = roll;
// limit servo value to its parameter range definition
if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER) )
/trunk/uart.c
18,8 → 18,8
#define BL_CTRL_ADDRESS 5
 
#define ABO_TIMEOUT 4000 // disable abo after 4 seconds
#define MAX_SENDE_BUFF 170
#define MAX_EMPFANGS_BUFF 170
#define MAX_SENDE_BUFF 175
#define MAX_EMPFANGS_BUFF 175
 
#define BLPARAM_REVISION 1
#define MASK_SET_PWM_SCALING 0x01
/trunk/version.txt
533,5 → 533,8
- Höhenwert auf cm kalibriert (zeigte ca. 10% zu viel an)
- Neue Error-Codes: "No SD-Card", "Flying range!" und "Error SD-Logging"
- Wenn die Motoren aus sind, den Luftduckwert langsam nachführen
- das einfache sbus-protokoll implementiert (nur FC2.1)
- das sbus-protokoll implementiert (nur FC2.1)
- Schaltkanal auf Servo-Ausgang
- Filter auf den Ausgängen der Servos