/beta/Code Redesign killagreg/dsl.h |
---|
File deleted |
/beta/Code Redesign killagreg/gps.c |
---|
File deleted |
/beta/Code Redesign killagreg/gps.h |
---|
File deleted |
/beta/Code Redesign killagreg/mm3.c |
---|
File deleted |
/beta/Code Redesign killagreg/mm3.h |
---|
File deleted |
/beta/Code Redesign killagreg/uart1.c |
---|
File deleted |
/beta/Code Redesign killagreg/ubx.c |
---|
File deleted |
/beta/Code Redesign killagreg/uart1.h |
---|
File deleted |
/beta/Code Redesign killagreg/ubx.h |
---|
File deleted |
/beta/Code Redesign killagreg/dsl.c |
---|
File deleted |
/beta/Code Redesign killagreg/Hex-Files/Readme.txt |
---|
File deleted |
/beta/Code Redesign killagreg/Hex-Files/Conrad LEA-4H Config-4Hz.txt |
---|
File deleted |
/beta/Code Redesign killagreg/Hex-Files/Conrad LEA-4H Config-5Hz.txt |
---|
File deleted |
/beta/Code Redesign killagreg/analog.c |
---|
62,8 → 62,6 |
#include "twimaster.h" |
#include "uart0.h" |
volatile uint16_t Test = 0; |
volatile int16_t UBat = 100; |
volatile int16_t AdValueGyroNick = 0, AdValueGyroRoll = 0, AdValueGyroYaw = 0; |
volatile int16_t FilterHiResGyroNick = 0, FilterHiResGyroRoll = 0; |
/beta/Code Redesign killagreg/eeprom.h |
---|
15,16 → 15,6 |
#define PID_FLIGHT_MINUTES_TOTAL 10 // word |
#define PID_FLIGHT_MINUTES 14 // word |
#ifdef USE_KILLAGREG |
#define PID_MM3_X_OFF 31 // byte |
#define PID_MM3_Y_OFF 32 // byte |
#define PID_MM3_Z_OFF 33 // byte |
#define PID_MM3_X_RANGE 34 // word |
#define PID_MM3_Y_RANGE 36 // word |
#define PID_MM3_Z_RANGE 38 // word |
#endif |
#define EEPROM_ADR_CHANNELS 80 // 12 bytes |
#define EEPROM_ADR_PARAMSET_LENGTH 98 // word |
79,11 → 69,11 |
#define CFG2_RES4 0x40 |
#define CFG2_RES5 0x80 |
#define RECV_PPMONLY 0 |
#define RECV_SPEKTRUM 1 |
#define RECV_JETI 2 |
#define RECV_ACT_DSL 3 |
#define RECV_ACT_S3D 4 |
#define RECEIVER_PPM 0 |
#define RECEIVER_SPEKTRUM 1 |
#define RECEIVER_JETI 2 |
#define RECEIVER_ACT_DSL 3 |
#define RECEIVER_ACT_S3D 4 |
// defines for lookup ParamSet.ChannelAssignment |
#define CH_NICK 0 |
/beta/Code Redesign killagreg/fc.c |
---|
68,19 → 68,14 |
#include "timer2.h" |
#include "mymath.h" |
#include "isqrt.h" |
#ifdef USE_KILLAGREG |
#include "mm3.h" |
#include "gps.h" |
#endif |
#ifdef USE_MK3MAG |
#include "mk3mag.h" |
#include "gps.h" |
#endif |
#include "led.h" |
#ifdef USE_NAVICTRL |
#include "spi.h" |
#endif |
//#include "libfcinit.h" |
#include "libfc.h" |
#define STICK_GAIN 4 |
622,18 → 617,6 |
CHK_POTI(FCParam.AxisCoupling2,ParamSet.AxisCoupling2); |
CHK_POTI(FCParam.AxisCouplingYawCorrection,ParamSet.AxisCouplingYawCorrection); |
CHK_POTI(FCParam.DynamicStability,ParamSet.DynamicStability); |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
CHK_POTI(FCParam.NaviGpsModeControl,ParamSet.NaviGpsModeControl); |
CHK_POTI(FCParam.NaviGpsGain,ParamSet.NaviGpsGain); |
CHK_POTI(FCParam.NaviGpsP,ParamSet.NaviGpsP); |
CHK_POTI(FCParam.NaviGpsI,ParamSet.NaviGpsI); |
CHK_POTI(FCParam.NaviGpsD,ParamSet.NaviGpsD); |
CHK_POTI(FCParam.NaviGpsACC,ParamSet.NaviGpsACC); |
CHK_POTI_MM(FCParam.NaviOperatingRadius,ParamSet.NaviOperatingRadius,10, 255); |
CHK_POTI(FCParam.NaviWindCorrection,ParamSet.NaviWindCorrection); |
CHK_POTI(FCParam.NaviSpeedCompensation,ParamSet.NaviSpeedCompensation); |
#endif |
CHK_POTI(FCParam.ExternalControl,ParamSet.ExternalControl); |
Ki = 10300 / ( FCParam.IFactor + 1 ); |
} |
811,7 → 794,7 |
if((AdAirPressure > AIR_PRESSURE_SEARCH_MAX) || (AdAirPressure < AIR_PRESSURE_SEARCH_MIN)) SearchAirPressureOffset(); |
} |
LipoDetection(0); |
//InitReceiver(); // libfcinit |
LIBFC_ReceiverInit(); |
Servo_Off(); // disable servo output |
SetNeutral(NO_ACC_CALIB); |
Servo_On(); // enable servo output |
1358,21 → 1341,9 |
if(CompassCalState && !(FCFlags & FCFLAG_MOTOR_RUN) ) |
{ |
SetCompassCalState(); |
#ifdef USE_KILLAGREG |
MM3_Calibrate(); |
#endif |
} |
else |
{ |
#ifdef USE_KILLAGREG |
static uint8_t updCompass = 0; |
if (!updCompass--) |
{ |
updCompass = 49; // update only at 2ms*50 = 100ms (10Hz) |
MM3_Heading(); |
} |
#endif |
// get maximum attitude angle |
w = abs(IntegralGyroNick / 512); |
v = abs(IntegralGyroRoll / 512); |
1425,23 → 1396,7 |
} |
} |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// GPS |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if(ParamSet.Config0 & CFG0_GPS_ACTIVE) |
{ |
GPS_Main(); |
FCFlags &= ~(FCFLAG_CALIBRATE | FCFLAG_START); |
} |
else |
{ |
GPSStickNick = 0; |
GPSStickRoll = 0; |
} |
#endif |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// DebugOutputs |
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
if(!TimerDebugOut--) |
/beta/Code Redesign killagreg/fc.h |
---|
67,17 → 67,6 |
uint8_t ExternalControl; |
uint8_t J16Timing; |
uint8_t J17Timing; |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
uint8_t NaviGpsModeControl; |
uint8_t NaviGpsGain; |
uint8_t NaviGpsP; |
uint8_t NaviGpsI; |
uint8_t NaviGpsD; |
uint8_t NaviGpsACC; |
uint8_t NaviOperatingRadius; |
uint8_t NaviWindCorrection; |
uint8_t NaviSpeedCompensation; |
#endif |
int8_t KalmanK; |
int8_t KalmanMaxDrift; |
int8_t KalmanMaxFusion; |
/beta/Code Redesign killagreg/main.c |
---|
60,7 → 60,6 |
#include "timer0.h" |
#include "timer2.h" |
#include "uart0.h" |
#include "uart1.h" |
#include "led.h" |
#include "menu.h" |
#include "fc.h" |
67,9 → 66,6 |
#include "rc.h" |
#include "analog.h" |
#include "printf_P.h" |
#ifdef USE_KILLAGREG |
#include "mm3.h" |
#endif |
#ifdef USE_NAVICTRL |
#include "spi.h" |
#endif |
78,21 → 74,12 |
#endif |
#include "twimaster.h" |
#include "eeprom.h" |
//#include "libfcinit.h" |
#include "libfc.h" |
uint8_t BoardRelease = 10; |
uint8_t CPUType = ATMEGA644; |
uint8_t LowVoltageWarning = 94; |
uint16_t FlightMinutes = 0, FlightMinutesTotal = 0; |
uint8_t GetCPUType(void) |
{ // works only after reset or power on when the registers have default values |
uint8_t CPUType = ATMEGA644; |
if( (UCSR1A == 0x20) && (UCSR1C == 0x06) ) CPUType = ATMEGA644P; // initial Values for 644P after reset |
return CPUType; |
} |
uint8_t GetBoardRelease(void) |
{ |
uint8_t BoardRelease = 10; |
163,6 → 150,7 |
if(print) printf("Low Warning level: %d.%dV", LowVoltageWarning/10, LowVoltageWarning%10); |
} |
int16_t main (void) |
{ |
uint16_t timer, flighttimer, pollingtimer; |
172,7 → 160,6 |
cli(); |
// analyze hardware environment |
CPUType = GetCPUType(); |
BoardRelease = GetBoardRelease(); |
// disable watchdog |
200,31 → 187,16 |
#ifdef USE_NAVICTRL |
SPI_MasterInit(); |
#endif |
#ifdef USE_KILLAGREG |
MM3_Init(); |
#endif |
#ifdef USE_MK3MAG |
MK3MAG_Init(); |
#endif |
if(CPUType == ATMEGA644P) USART1_Init(); |
//InitFC(); // libfcinit |
LIBFC_Init(); |
GRN_ON; |
// enable interrupts global |
sei(); |
printf("\n\r==================================="); |
printf("\n\rFlightControl"); |
printf("\n\rHardware: %d.%d", BoardRelease/10, BoardRelease%10); |
printf("\n\rthe use of this software is only permitted \n\ron original MikroKopter-Hardware"); |
printf("\n\rwww.MikroKopter.de (c) HiSystems GmbH"); |
printf("\n\r==================================="); |
if(CPUType == ATMEGA644P) |
printf("\r\n CPU: Atmega644p"); |
else |
printf("\r\n CPU: Atmega644"); |
printf("\n\rSoftware: V%d.%d%c",VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
printf("\n\r==================================="); |
GRN_ON; |
283,27 → 255,12 |
#ifdef USE_NAVICTRL |
printf("\n\rSupport for NaviCtrl"); |
#ifdef USE_RC_DSL |
printf("\r\nSupport for DSL RC at 2nd UART"); |
#endif |
#ifdef USE_RC_SPECTRUM |
printf("\r\nSupport for SPEKTRUM RC at 2nd UART"); |
#endif |
#endif |
#ifdef USE_KILLAGREG |
printf("\n\rSupport for MicroMag3 Compass"); |
#endif |
#ifdef USE_MK3MAG |
printf("\n\rSupport for MK3MAG Compass"); |
#endif |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
if(CPUType == ATMEGA644P) printf("\n\rSupport for GPS at 2nd UART"); |
else printf("\n\rSupport for GPS at 1st UART"); |
#endif |
// init variables |
SetNeutral(NO_ACC_CALIB); |
331,7 → 288,7 |
Menu_Clear(); |
I2CTimeout = 5000; |
LipoDetection(1); |
//InitReceiver(); // libfcinit |
LIBFC_ReceiverInit(); |
printf("\n\r===================================\n\r"); |
341,14 → 298,14 |
// begin of main loop |
while (1) |
{ |
/* |
if(CheckDelay(pollingtimer)) |
{ |
pollingtimer = SetDelay(100); |
Polling(); // libfcinit |
LIBFC_Polling(); |
} |
*/ |
if(UpdateMotor && ADReady) // control interval |
{ |
UpdateMotor = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
/beta/Code Redesign killagreg/main.h |
---|
3,13 → 3,6 |
#include <avr/io.h> |
#define ATMEGA644 0 |
#define ATMEGA644P 1 |
#define SYSCLK F_CPU |
// neue Hardware |
#define RED_OFF {if((BoardRelease == 10)||(BoardRelease == 20)) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);} |
#define RED_ON {if((BoardRelease == 10)||(BoardRelease == 20)) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);} |
22,7 → 15,6 |
extern uint8_t LowVoltageWarning; |
extern uint8_t BoardRelease; |
extern uint8_t CPUType; |
extern uint16_t FlightMinutes, FlightMinutesTotal; |
void LipoDetection(uint8_t print); |
/beta/Code Redesign killagreg/makefile |
---|
15,14 → 15,9 |
#OPTIONS |
# Use one of the extensions for a gps solution |
#EXT = KILLAGREG |
EXT = NAVICTRL |
#EXT = MK3MAG |
# Use optional one the RCs if EXT = NAVICTRL has been used |
RC = DSL |
#RC = SPEKTRUM |
#------------------------------------------------------------------- |
# get SVN revision |
REV := $(shell sh -c "cat .svn/entries | sed -n '4p'") |
115,23 → 110,14 |
########################################################################################################## |
# List C source files here. (C dependencies are automatically generated.) |
SRC = main.c uart0.c printf_P.c timer0.c timer2.c analog.c menu.c led.c |
SRC += twimaster.c rc.c fc.c eeprom.c uart1.c mymath.c |
SRC += twimaster.c rc.c fc.c eeprom.c mymath.c spektrum.c |
ifeq ($(EXT), KILLAGREG) |
SRC += mm3.c gps.c ubx.c |
endif |
ifeq ($(EXT), MK3MAG) |
SRC += mk3mag.c gps.c ubx.c |
SRC += mk3mag.c |
endif |
ifeq ($(EXT), NAVICTRL) |
SRC += spi.c |
ifeq ($(RC), DSL) |
SRC += dsl.c |
endif |
ifeq ($(RC), SPEKTRUM) |
SRC += spektrum.c |
endif |
endif |
########################################################################################################## |
175,21 → 161,12 |
CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) -DNC_SPI_COMPATIBLE=$(NC_SPI_COMPATIBLE) |
ifeq ($(EXT), KILLAGREG) |
CFLAGS += -DUSE_KILLAGREG |
endif |
ifeq ($(EXT), MK3MAG) |
CFLAGS += -DUSE_MK3MAG |
endif |
ifeq ($(EXT), NAVICTRL) |
CFLAGS += -DUSE_NAVICTRL |
ifeq ($(RC), DSL) |
CFLAGS += -DUSE_RC_DSL |
endif |
ifeq ($(RC), SPEKTRUM) |
CFLAGS += -DUSE_RC_SPEKTRUM |
endif |
endif |
222,7 → 199,7 |
LDFLAGS += -lm |
# extern lib |
LDFLAGS += libfcinit.a |
LDFLAGS += libfc.a |
##LDFLAGS += -T./linkerfile/avr5.x |
455,7 → 432,7 |
clean_list : |
@echo |
@echo $(MSG_CLEANING) |
$(REMOVE) $(TARGET).hex |
$(REMOVE) Flight-Ctrl_*.hex |
$(REMOVE) $(TARGET).eep |
$(REMOVE) $(TARGET).obj |
$(REMOVE) $(TARGET).cof |
/beta/Code Redesign killagreg/menu.c |
---|
62,25 → 62,7 |
#include "twimaster.h" |
#include "menu.h" |
#ifdef USE_KILLAGREG |
#include "mm3.h" |
#endif |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
#include "ubx.h" |
#endif |
#if (!defined (USE_KILLAGREG) && !defined (USE_MK3MAG)) |
uint8_t MaxMenuItem = 15; |
#else |
#ifdef USE_MK3MAG |
uint8_t MaxMenuItem = 16; |
#endif |
#ifdef USE_KILLAGREG |
uint8_t MaxMenuItem = 18; |
#endif |
#endif |
uint8_t MenuItem = 0; |
272,59 → 254,6 |
} |
break; |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
case 16://GPS Lat/Lon coords |
if (GPSInfo.status == INVALID) |
{ |
LCD_printfxy(0,0,"No GPS data!"); |
} |
else |
{ |
switch (GPSInfo.satfix) |
{ |
case SATFIX_NONE: |
LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum); |
break; |
case SATFIX_2D: |
LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum); |
break; |
case SATFIX_3D: |
LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum); |
break; |
default: |
LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum); |
break; |
} |
int16_t i1,i2,i3; |
i1 = (int16_t)(GPSInfo.longitude/10000000L); |
i2 = abs((int16_t)((GPSInfo.longitude%10000000L)/10000L)); |
i3 = abs((int16_t)(((GPSInfo.longitude%10000000L)%10000L)/10L)); |
LCD_printfxy(0,1,"Lon: %d.%03d%03d deg",i1, i2, i3); |
i1 = (int16_t)(GPSInfo.latitude/10000000L); |
i2 = abs((int16_t)((GPSInfo.latitude%10000000L)/10000L)); |
i3 = abs((int16_t)(((GPSInfo.latitude%10000000L)%10000L)/10L)); |
LCD_printfxy(0,2,"Lat: %d.%03d%03d deg",i1, i2, i3); |
i1 = (int16_t)(GPSInfo.altitude/1000L); |
i2 = abs((int16_t)(GPSInfo.altitude%1000L)); |
LCD_printfxy(0,3,"Alt: %d.%03d m",i1, i2); |
} |
break; |
#endif |
#ifdef USE_KILLAGREG |
case 17:// MM3 Kompass |
LCD_printfxy(0,0,"MM3 Offset"); |
LCD_printfxy(0,1,"X_Offset: %3i",MM3_calib.X_off); |
LCD_printfxy(0,2,"Y_Offset: %3i",MM3_calib.Y_off); |
LCD_printfxy(0,3,"Z_Offset: %3i",MM3_calib.Z_off); |
break; |
case 18://MM3 Range |
LCD_printfxy(0,0,"MM3 Range"); |
LCD_printfxy(0,1,"X_Range: %4i",MM3_calib.X_range); |
LCD_printfxy(0,2,"Y_Range: %4i",MM3_calib.Y_range); |
LCD_printfxy(0,3,"Z_Range: %4i",MM3_calib.Z_range); |
break; |
#endif |
default: |
MaxMenuItem = MenuItem - 1; |
MenuItem = 0; |
/beta/Code Redesign killagreg/rc.c |
---|
56,7 → 56,6 |
#include "eeprom.h" |
#include "main.h" |
#include "fc.h" |
#include "uart0.h" |
//#define ACT_S3D_SUMSIGNAL |
99,12 → 98,10 |
// PD3 can't be used if 2nd UART is activated |
// because TXD1 is at that port |
if(CPUType != ATMEGA644P) |
{ |
DDRD |= (1<<PORTD3); |
PORTD &= ~(1<<PORTD3); |
} |
//DDRD |= (1<<PORTD3); |
//PORTD &= ~(1<<PORTD3); |
// Timer/Counter1 Control Register A, B, C |
// Normal Mode (bits: WGM13=0, WGM12=0, WGM11=0, WGM10=0) |
258,10 → 255,7 |
// demux sum signal for channels 5 to 7 to J3, J4, J5 |
if(index == 5) J3HIGH; else J3LOW; |
if(index == 6) J4HIGH; else J4LOW; |
if(CPUType != ATMEGA644P) // not used as TXD1 |
{ |
if(index == 7) J5HIGH; else J5LOW; |
} |
//if(index == 7) J5HIGH; else J5LOW; //used as TXD1 |
index++; // next channel |
} |
else // (index >= MAX_RC_CHANNELS) |
324,10 → 318,7 |
// demux sum signal for channels 5 to 7 to J3, J4, J5 |
if(index == 5) J3HIGH; else J3LOW; |
if(index == 6) J4HIGH; else J4LOW; |
if(CPUType != ATMEGA644P) // not used as TXD1 |
{ |
if(index == 7) J5HIGH; else J5LOW; |
} |
//if(index == 7) J5HIGH; else J5LOW; //used as TXD1 |
} // eof (index < MAX_CHANNELS) |
} // eof within the PPM frame |
} // eof old more tolerant version |
/beta/Code Redesign killagreg/spektrum.c |
---|
1,9 → 1,10 |
#include <avr/io.h> |
#include <stdlib.h> |
#include <avr/interrupt.h> |
#include "spektrum.h" |
#include "rc.h" |
#include "timer0.h" |
uint8_t SpektrumTimer; |
/* |
Code derived from: |
73,10 → 74,70 |
*/ |
#define USART1_BAUD 115200 |
/****************************************************************/ |
/* Initialization of the USART1 */ |
/****************************************************************/ |
void Spektrum_Init(void) |
{ |
// USART1 Control and Status Register A, B, C and baud rate register |
uint8_t sreg = SREG; |
uint16_t ubrr = (uint16_t) ((uint32_t) F_CPU/(8 * USART1_BAUD) - 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 << TXEN1) | (1 << RXEN1); |
// set asynchronous mode |
UCSR1C &= ~(1 << UMSEL11); |
UCSR1C &= ~(1 << UMSEL10); |
// no parity |
UCSR1C &= ~(1 << UPM11); |
UCSR1C &= ~(1 << UPM10); |
// 1 stop bit |
UCSR1C &= ~(1 << USBS1); |
// 8-bit |
UCSR1B &= ~(1 << UCSZ12); |
UCSR1C |= (1 << UCSZ11); |
UCSR1C |= (1 << UCSZ10); |
// flush receive buffer explicit |
while ( UCSR1A & (1<<RXC1) ) UDR1; |
// enable interrupts at the end |
// enable RX-Interrupt |
UCSR1B |= (1 << RXCIE1); |
// enable TX-Interrupt |
//UCSR1B |= (1 << TXCIE1); |
// enable DRE interrupt |
//UCSR1B |= (1 << UDRIE1); |
// restore global interrupt flags |
SREG = sreg; |
} |
87,7 → 148,7 |
{ |
static uint8_t Sync = 0, FrameCnt = 0, ByteHigh = 0, ReSync = 1, Frame2 = 0; |
uint16_t Channel, index; |
int16_t signal; //tmp; |
int16_t signal, tmp; |
int16_t bCheckDelay; |
/beta/Code Redesign killagreg/spektrum.h |
---|
3,10 → 3,6 |
#include <inttypes.h> |
#define USART1_BAUD 115200 |
extern uint8_t SpektrumTimer; |
// initalization |
extern void Spektrum_Init(void); |
// this function should be called within the UART RX ISR |
/beta/Code Redesign killagreg/timer0.c |
---|
56,15 → 56,10 |
#include "analog.h" |
#include "main.h" |
#include "fc.h" |
#ifdef USE_KILLAGREG |
#include "mm3.h" |
#endif |
#include "spektrum.h" |
#ifdef USE_MK3MAG |
#include "mk3mag.h" |
#endif |
#ifdef USE_RC_SPEKTRUM |
#include "spektrum.h" |
#endif |
volatile uint16_t CountMilliseconds = 0; |
76,6 → 71,7 |
#ifdef USE_NAVICTRL |
volatile uint8_t SendSPI = 0; |
#endif |
volatile uint8_t SpektrumTimer; |
#define USE_BEEPER |
118,7 → 114,7 |
// Timer/Counter 0 Control Register B |
// set clock divider for timer 0 to SYSKLOCK/8 = 20MHz / 8 = 2.5MHz |
// set clock divider for timer 0 to SYSCLOCK/8 = 20MHz / 8 = 2.5MHz |
// i.e. the timer increments from 0x00 to 0xFF with an update rate of 2.5 MHz |
// hence the timer overflow interrupt frequency is 2.5 MHz / 256 = 9.765 kHz |
155,9 → 151,7 |
if(SendSPI) SendSPI--; // if SendSPI is 0, the transmit of a byte via SPI bus to and from The Navicontrol is done |
#endif |
#ifdef USE_RC_SPEKTRUM |
if(SpektrumTimer) SpektrumTimer--; |
#endif |
if(!cnt--) // every 10th run (9.765kHz/10 = 976Hz) |
{ |
202,12 → 196,9 |
// update compass value if this option is enabled in the settings |
if(ParamSet.Config0 & (CFG0_COMPASS_ACTIVE|CFG0_GPS_ACTIVE)) |
{ |
#ifdef USE_KILLAGREG |
MM3_Update(); // read out mm3 board |
#endif |
#ifdef USE_MK3MAG |
#ifdef USE_MK3MAG |
MK3MAG_Update(); // read out mk3mag pwm |
#endif |
#endif |
} |
#endif |
} |
/beta/Code Redesign killagreg/timer0.h |
---|
10,6 → 10,7 |
extern volatile uint16_t BeepTime; |
#ifdef USE_NAVICTRL |
extern volatile uint8_t SendSPI; |
extern volatile uint8_t SpektrumTimer; |
#endif |
extern void TIMER0_Init(void); |
/beta/Code Redesign killagreg/timer2.c |
---|
95,7 → 95,7 |
// Timer/Counter 2 Control Register B |
// Set clock divider for timer 2 to SYSKLOCK/32 = 20MHz / 32 = 625 kHz |
// Set clock divider for timer 2 to SYSCLOCK/32 = 20MHz / 32 = 625 kHz |
// The timer increments from 0x00 to 0xFF with an update rate of 625 kHz or 1.6 us |
// hence the timer overflow interrupt frequency is 625 kHz / 256 = 2.44 kHz or 0.4096 ms |
/beta/Code Redesign killagreg/twimaster.c |
---|
53,7 → 53,6 |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <util/twi.h> |
#include "main.h" |
#include "eeprom.h" |
#include "twimaster.h" |
#include "fc.h" |
95,7 → 94,7 |
TWSR &= ~((1<<TWPS1)|(1<<TWPS0)); |
// set TWI Bit Rate Register |
TWBR = ((SYSCLK/SCL_CLOCK)-16)/2; |
TWBR = ((F_CPU/SCL_CLOCK)-16)/2; |
twi_state = TWI_STATE_MOTOR_TX; |
motor_write = 0; |
/beta/Code Redesign killagreg/uart0.c |
---|
65,9 → 65,6 |
#include "fc.h" |
#include "rc.h" |
#include "printf_P.h" |
#if defined (USE_KILLAGREG) || defined (USE_MK3MAG) |
#include "ubx.h" |
#endif |
#ifdef USE_MK3MAG |
#include "mk3mag.h" |
#endif |
178,7 → 175,7 |
void USART0_Init (void) |
{ |
uint8_t sreg = SREG; |
uint16_t ubrr = (uint16_t) ((uint32_t) SYSCLK/(8 * USART0_BAUD) - 1); |
uint16_t ubrr = (uint16_t) ((uint32_t) F_CPU/(8 * USART0_BAUD) - 1); |
// disable all interrupts before configuration |
cli(); |
289,11 → 286,6 |
c = UDR0; // catch the received byte |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
// If the cpu is not an Atmega644P the ublox module should be conneced to rxd of the 1st uart. |
if(CPUType != ATMEGA644P) ubx_parser(c); |
#endif |
if(rxd_buffer_locked) return; // if rxd buffer is locked immediately return |
// the rxd buffer is unlocked |
/beta/Code Redesign killagreg/version.txt |
---|
358,25 → 358,16 |
- LED-Warn-Blinken nun mit festem Timing und abschaltbar |
Anpassungen bzgl. V0.77a |
G.Stobrawa 10.12.2009: |
G.Stobrawa 13.12.2009: |
- Code stärker modularisiert und restrukturiert |
- viele Kommentare zur Erklärug eingefügt |
- konsequent englische Variablennamen |
- PPM24 Support für bis zu 12 RC-Kanäle. |
- Suport for DSL Receiver at 2nd UART |
- Makefile: EXT=NAVICTRL Unterstützung der SPI Communikation zum Naviboard |
- Makefile: EXT=MK3MAG Unerstützung des MK3MAG/CMPS03 direkt an FC und Conrad UBLOX Modul |
- Makefile: EXT=KILLAGREG Unterstützung vom KillagregBoard mit MM3 und Conrad UBLOX Modul |
- Ausertung des UBX-Protocols an 1. oder 2. Uart |
- GPS-Hold-Funktion hinzugefügt |
- GPS-Home-Funktion hinzugefügt (wird beim Motorstart gelernt, und bei Motorenstop wieder gelöscht) |
- Zusätzliche Punkte im Menü des KopterTool zur Anzeige des GPS-Status und der MM3-Kalibierparameter |
Weiter Detail siehe Readme.txt im Verzeichnis Hex-Files. |