/trunk/Spectrum.c |
---|
64,7 → 64,6 |
} |
//############################################################################ |
// zum Decodieren des Spektrum Satelliten wird USART1 benutzt. |
// USART1 initialisation from killagreg |
void Uart1Init(void) |
//############################################################################ |
186,17 → 185,21 |
#define MIN_FRAMEGAP 68 // 7ms |
#define MAX_BYTEGAP 3 // 310us |
//############################################################################ |
//Diese Routine startet und inizialisiert den USART1 für seriellen Spektrum satellite reciever |
SIGNAL(USART1_RX_vect) |
//SIGNAL(USART1_RX_vect) |
//############################################################################ |
void SpektrumParser(unsigned char c) |
{ |
static unsigned char Sync=0, FrameCnt=0, ByteHigh=0, ReSync=1, Frame2=0; |
unsigned int Channel, index; |
signed int signal, tmp; |
int bCheckDelay; |
uint8_t c; |
c = UDR1; // get data byte |
// c = UDR1; // get data byte |
if(ReSync == 1) |
{ |
// wait for beginning of new frame |
/trunk/Spectrum.h |
---|
7,4 → 7,6 |
void Uart1Init(void); |
void SpektrumBinding(void); |
extern unsigned char SpektrumTimer; |
extern void SpektrumParser(unsigned char c); |
#endif //_RC_H |
/trunk/flight.pnproj |
---|
1,0 → 0,0 |
<Project name="Flight-Ctrl"><File path="uart.h"></File><File path="main.c"></File><File path="main.h"></File><File path="makefile"></File><File path="uart.c"></File><File path="printf_P.h"></File><File path="printf_P.c"></File><File path="timer0.c"></File><File path="timer0.h"></File><File path="old_macros.h"></File><File path="twimaster.c"></File><File path="version.txt"></File><File path="twimaster.h"></File><File path="rc.c"></File><File path="rc.h"></File><File path="fc.h"></File><File path="menu.h"></File><File path="menu.c"></File><File path="_Settings.h"></File><File path="analog.c"></File><File path="analog.h"></File><File path="GPS.c"></File><File path="gps.h"></File><File path="License.txt"></File><File path="eeprom.c"></File><File path="spi.h"></File><File path="spi.c"></File><File path="led.h"></File><File path="led.c"></File><File path="fc.c"></File><File path="Spectrum.c"></File><File path="Spectrum.h"></File><File path="mymath.c"></File><File path="mymath.h"></File><File path="isqrt.S"></File></Project> |
<Project name="Flight-Ctrl"><File path="uart.h"></File><File path="jeti.h"></File><File path="main.c"></File><File path="main.h"></File><File path="makefile"></File><File path="uart.c"></File><File path="printf_P.h"></File><File path="printf_P.c"></File><File path="timer0.c"></File><File path="timer0.h"></File><File path="old_macros.h"></File><File path="twimaster.c"></File><File path="version.txt"></File><File path="twimaster.h"></File><File path="rc.c"></File><File path="rc.h"></File><File path="fc.h"></File><File path="menu.h"></File><File path="menu.c"></File><File path="_Settings.h"></File><File path="analog.c"></File><File path="analog.h"></File><File path="GPS.c"></File><File path="gps.h"></File><File path="License.txt"></File><File path="eeprom.c"></File><File path="spi.h"></File><File path="spi.c"></File><File path="led.h"></File><File path="led.c"></File><File path="fc.c"></File><File path="Spectrum.c"></File><File path="Spectrum.h"></File><File path="mymath.c"></File><File path="mymath.h"></File><File path="isqrt.S"></File></Project> |
/trunk/jeti.h |
---|
0,0 → 1,8 |
#ifndef _JETI_H |
#define _JETI_H |
extern void JetiBoxUartInit(void); |
extern void JetiBoxPolling(void); |
extern void JetiParser(unsigned char c); |
#endif //_JETI_H |
/trunk/jeti.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/main.c |
---|
154,7 → 154,7 |
int main (void) |
//############################################################################ |
{ |
unsigned int timer,i,timer2 = 0; |
unsigned int timer,i,timer2 = 0, timerJeti; |
DDRB = 0x00; |
PORTB = 0x00; |
for(timer = 0; timer < 1000; timer++); // verzögern |
194,6 → 194,12 |
i2c_init(); |
SPI_MasterInit(); |
if(UCSR1A == 0x20 && UCSR1C == 0x06) // initial Values for 644P |
{ |
//Uart1Init(); |
JetiBoxUartInit(); |
} |
sei(); |
printf("\n\r==================================="); |
printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR,VERSION_PATCH + 'a'); |
201,10 → 207,6 |
printf("\n\rwww.MikroKopter.de (c) HiSystems GmbH"); |
printf("\n\r==================================="); |
if(UCSR1A == 0x20 && UCSR1C == 0x06) // initial Values for 644P |
{ |
Uart1Init(); |
} |
GRN_ON; |
ReadParameterSet(3, (unsigned char *) &EE_Parameter.Kanalbelegung[0], 13); // read only the first bytes |
if((eeprom_read_byte(&EEPromArray[EEPROM_ADR_MIXER_TABLE]) == MIXER_REVISION) && // Check Revision in the first Byte |
236,6 → 238,8 |
printf("\n\rFound BL-Ctrl: "); |
motorread = 0; UpdateMotor = 0; SendMotorData(); while(!UpdateMotor); motorread = 0; // read the first I2C-Data |
timer = SetDelay(2000); |
for(i=0; i < MAX_MOTORS; i++) |
{ |
UpdateMotor = 0; |
360,9 → 364,17 |
printf("\n\r===================================\n\r"); |
//SpektrumBinding(); |
timer = SetDelay(2000); |
timerJeti = SetDelay(250); |
while (1) |
{ |
if(UpdateMotor && AdReady) // ReglerIntervall |
if(CheckDelay(timerJeti)) |
{ |
timerJeti = SetDelay(100); |
JetiBoxPolling(); |
} |
if(UpdateMotor && AdReady) // ReglerIntervall |
{ |
UpdateMotor=0; |
if(WinkelOut.CalcState) CalMk3Mag(); |
383,6 → 395,7 |
GPS_Roll = 0; |
} |
} |
if(!--I2CTimeout || MissingMotor) |
{ |
if(!I2CTimeout) |
401,6 → 414,7 |
{ |
ROT_OFF; |
} |
if(SIO_DEBUG && (!UpdateMotor || !MotorenEin)) |
{ |
DatenUebertragung(); |
407,9 → 421,15 |
BearbeiteRxDaten(); |
} |
else BearbeiteRxDaten(); |
if(CheckDelay(timer)) |
{ |
timer += 20; |
timer += 20; |
if(PcZugriff) PcZugriff--; |
else |
{ |
433,9 → 453,12 |
} |
} |
else MikroKopterFlags &= ~FLAG_LOWBAT; |
SPI_StartTransmitPacket(); |
SendSPI = 4; |
if(!MotorenEin) timer2 = 1450; // 0,5 Minuten aufrunden |
if(++timer2 == 2930) // eine Minute |
{ |
timer2 = 0; |
/trunk/main.h |
---|
117,7 → 117,9 |
#include "gps.h" |
#include "spi.h" |
#include "led.h" |
#include "jeti.h" |
#ifndef EEMEM |
#define EEMEM __attribute__ ((section (".eeprom"))) |
#endif |
/trunk/makefile |
---|
12,6 → 12,9 |
NC_SPI_COMPATIBLE = 11 # Navi-Kompatibilität |
#------------------------------------------------------------------- |
# get SVN revision |
REV := $(shell sh -c "cat .svn/entries | sed -n '4p'") |
ifeq ($(MCU), atmega32) |
# FUSE_SETTINGS= -u -U lfuse:w:0xff:m -U hfuse:w:0xcf:m |
45,57 → 48,58 |
# Target file name (without extension). |
ifeq ($(VERSION_PATCH), 0) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 1) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 2) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 3) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 4) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 5) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 6) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 7) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 8) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 9) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 10) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 11) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)L |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)L_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 12) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 13) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 14) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 15) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 16) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV) |
endif |
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
OPT = 2 |
102,9 → 106,9 |
########################################################################################################## |
# List C source files here. (C dependencies are automatically generated.) |
SRC = main.c uart.c printf_P.c timer0.c analog.c menu.c |
SRC = main.c uart.c printf_P.c timer0.c analog.c menu.c |
SRC += twimaster.c rc.c fc.c GPS.c spi.c led.c Spectrum.c |
SRC += mymath.c |
SRC += mymath.c |
########################################################################################################## |
269,7 → 273,7 |
# Define all object files. |
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) jeti.o |
# Define all listing files. |
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
419,10 → 423,11 |
$(REMOVE) $(TARGET).sym |
$(REMOVE) $(TARGET).lnk |
$(REMOVE) $(TARGET).lss |
$(REMOVE) $(OBJ) |
# $(REMOVE) $(OBJ) |
$(REMOVE) $(LST) |
$(REMOVE) $(SRC:.c=.s) |
$(REMOVE) $(SRC:.c=.d) |
$(REMOVE) $(SRC:.c=.o) |
# Automatically generate C source code dependencies. |
/trunk/menu.c |
---|
57,23 → 57,25 |
case 1: |
if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
{ |
LCD_printfxy(0,0,"Hoehe: %5i",(int)(HoehenWert/5)); |
LCD_printfxy(0,1,"SollHoehe: %5i",(int)(SollHoehe/5)); |
LCD_printfxy(0,2,"Luftdruck: %5i",MessLuftdruck); |
LCD_printfxy(0,3,"Off : %5i",OCR0A); |
LCD_printfxy(0,0,"Height: %5i",(int)(HoehenWert/5)); |
LCD_printfxy(0,1,"Setpoint:%5i",(int)(SollHoehe/5)); |
LCD_printfxy(0,2,"Pressure:%5i",MessLuftdruck); |
LCD_printfxy(0,3,"Offset: %5i",OCR0A); |
} |
else |
{ |
LCD_printfxy(0,1,"Keine "); |
LCD_printfxy(0,2,"Höhenregelung"); |
LCD_printfxy(0,0,"Height control"); |
LCD_printfxy(0,1,"DISABLED"); |
LCD_printfxy(0,2,"Height control"); |
LCD_printfxy(0,3,"DISABLED"); |
} |
break; |
case 2: |
LCD_printfxy(0,0,"akt. Lage"); |
LCD_printfxy(0,0,"act. bearing"); |
LCD_printfxy(0,1,"Nick: %5i",IntegralNick/1024); |
LCD_printfxy(0,2,"Roll: %5i",IntegralRoll/1024); |
LCD_printfxy(0,3,"Kompass: %5i",KompassValue); |
LCD_printfxy(0,3,"Compass: %5i",KompassValue); |
break; |
case 3: |
LCD_printfxy(0,0,"K1:%4i K2:%4i ",PPM_in[1],PPM_in[2]); |
91,9 → 93,9 |
LCD_printfxy(0,0,"Gyro - Sensor"); |
if(PlatinenVersion == 10) |
{ |
LCD_printfxy(0,1,"Nick %4i (%3i.%i)",AdWertNick - AdNeutralNick/8, AdNeutralNick/8, AdNeutralNick%8); |
LCD_printfxy(0,2,"Roll %4i (%3i.%i)",AdWertRoll - AdNeutralRoll/8, AdNeutralRoll/8, AdNeutralRoll%8); |
LCD_printfxy(0,3,"Gier %4i (%3i)",AdNeutralGier - AdWertGier, AdNeutralGier); |
LCD_printfxy(0,1,"Nick%4i (%3i.%i)",AdWertNick - AdNeutralNick/8, AdNeutralNick/8, AdNeutralNick%8); |
LCD_printfxy(0,2,"Roll%4i (%3i.%i)",AdWertRoll - AdNeutralRoll/8, AdNeutralRoll/8, AdNeutralRoll%8); |
LCD_printfxy(0,3,"Gier%4i (%3i)",AdNeutralGier - AdWertGier, AdNeutralGier); |
} |
else |
if((PlatinenVersion == 11) || (PlatinenVersion == 20)) |
100,7 → 102,7 |
{ |
LCD_printfxy(0,1,"Nick %4i (%3i.%x)",AdWertNick - AdNeutralNick/8, AdNeutralNick/16, (AdNeutralNick%16)/2); |
LCD_printfxy(0,2,"Roll %4i (%3i.%x)",AdWertRoll - AdNeutralRoll/8, AdNeutralRoll/16, (AdNeutralRoll%16)/2); |
LCD_printfxy(0,3,"Gier %4i (%3i)",AdNeutralGier - AdWertGier, AdNeutralGier/2); |
LCD_printfxy(0,3,"Yaw %4i (%3i)",AdNeutralGier - AdWertGier, AdNeutralGier/2); |
} |
else |
if(PlatinenVersion == 13) |
107,7 → 109,7 |
{ |
LCD_printfxy(0,1,"Nick %4i (%3i)(%3i)",AdWertNick - AdNeutralNick/8, AdNeutralNick/16,AnalogOffsetNick); |
LCD_printfxy(0,2,"Roll %4i (%3i)(%3i)",AdWertRoll - AdNeutralRoll/8, AdNeutralRoll/16,AnalogOffsetRoll); |
LCD_printfxy(0,3,"Gier %4i (%3i)(%3i)",AdNeutralGier - AdWertGier, AdNeutralGier/2,AnalogOffsetGier); |
LCD_printfxy(0,3,"Yaw %4i (%3i)(%3i)",AdNeutralGier - AdWertGier, AdNeutralGier/2,AnalogOffsetGier); |
} |
break; |
case 6: |
114,18 → 116,19 |
LCD_printfxy(0,0,"ACC - Sensor"); |
LCD_printfxy(0,1,"Nick %4i (%3i)",AdWertAccNick,NeutralAccX); |
LCD_printfxy(0,2,"Roll %4i (%3i)",AdWertAccRoll,NeutralAccY); |
LCD_printfxy(0,3,"Hoch %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ); |
LCD_printfxy(0,3,"Z %4i (%3i)",Mittelwert_AccHoch/*accumulate_AccHoch / messanzahl_AccHoch*/,(int)NeutralAccZ); |
break; |
case 7: |
LCD_printfxy(0,1,"Voltage: %5i",UBat); |
LCD_printfxy(0,0,"Volt. & receiver"); |
LCD_printfxy(0,1,"UBat: %5i.%1iV",UBat/10, UBat%10); |
LCD_printfxy(0,2,"RC-Level: %5i",SenderOkay); |
LCD_printfxy(0,3,"RC-Channels:%4i",Channels-1); |
break; |
case 8: |
LCD_printfxy(0,0,"Kompass "); |
LCD_printfxy(0,1,"Richtung: %5i",KompassRichtung); |
LCD_printfxy(0,2,"Messwert: %5i",KompassValue); |
LCD_printfxy(0,3,"Start: %5i",KompassStartwert); |
LCD_printfxy(0,0,"Compass"); |
LCD_printfxy(0,1,"Heading: %5i",KompassRichtung); |
LCD_printfxy(0,2,"Value: %5i",KompassValue); |
LCD_printfxy(0,3,"Start: %5i",KompassStartwert); |
break; |
case 9: |
LCD_printfxy(0,0,"Poti1: %3i",Poti[0]); |
142,7 → 145,7 |
case 11: |
LCD_printfxy(0,0,"Servo " ); |
LCD_printfxy(0,1,"Setpoint %3i",Parameter_ServoNickControl); |
LCD_printfxy(0,2,"Stellung: %3i",ServoNickValue); |
LCD_printfxy(0,2,"Position: %3i",ServoNickValue); |
LCD_printfxy(0,3,"Range:%3i-%3i",EE_Parameter.ServoNickMin,EE_Parameter.ServoNickMax); |
break; |
case 12: |
153,9 → 156,9 |
break; |
case 13: |
LCD_printfxy(0,0,"BL-Ctrl Errors " ); |
LCD_printfxy(0,1," %3d %3d %3d %3d ",MotorError[0],MotorError[1],MotorError[2],MotorError[3]); |
LCD_printfxy(0,2," %3d %3d %3d %3d ",MotorError[4],MotorError[5],MotorError[6],MotorError[7]); |
LCD_printfxy(0,3," %3d %3d %3d %3d ",MotorError[8],MotorError[9],MotorError[10],MotorError[11]); |
LCD_printfxy(0,1,"%3d %3d %3d %3d ",MotorError[0],MotorError[1],MotorError[2],MotorError[3]); |
LCD_printfxy(0,2,"%3d %3d %3d %3d ",MotorError[4],MotorError[5],MotorError[6],MotorError[7]); |
LCD_printfxy(0,3,"%3d %3d %3d %3d ",MotorError[8],MotorError[9],MotorError[10],MotorError[11]); |
break; |
case 14: |
LCD_printfxy(0,0,"BL-Ctrl found " ); |
168,8 → 171,8 |
break; |
case 15: |
LCD_printfxy(0,0,"Flight-Time " ); |
LCD_printfxy(0,1," %5umin",FlugMinuten); |
LCD_printfxy(0,2,"Total:%5umin",FlugMinutenGesamt); |
LCD_printfxy(0,1,"Total:%5umin",FlugMinutenGesamt); |
LCD_printfxy(0,2,"Act: %5umin",FlugMinuten); |
LCD_printfxy(13,3,"(reset)"); |
if(RemoteKeys & KEY4) |
{ |
/trunk/uart.c |
---|
135,8 → 135,10 |
RxdBuffer[buf_ptr] = '\r'; |
if(RxdBuffer[2] == 'R') |
{ |
LcdClear(); |
wdt_enable(WDTO_250MS); // Reset-Commando |
ServoActive = 0; |
} |
} |
} |
537,7 → 539,7 |
{ |
if(DisplayLine > 3)// new format |
{ |
Menu(); |
//Menu(); |
SendOutData('H', FC_ADDRESS, 1, (uint8_t *)DisplayBuff, 80); |
} |
else // old format |