Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 711 → Rev 712

/branches/V0.68d Code Redesign killagreg/fc.c
433,7 → 433,7
/************************************************************************/
/* MotorControl */
/************************************************************************/
void MotorRegler(void)
void MotorControl(void)
{
int16_t MotorValue, pd_result, h, tmp_int;
int16_t YawMixFraction, ThrustMixFraction;
/branches/V0.68d Code Redesign killagreg/fc.h
66,7 → 66,7
extern int16_t ExternStickPitch, ExternStickRoll, ExternStickYaw;
 
 
void MotorRegler(void);
void MotorControl(void);
void SendMotorData(void);
void CalibMean(void);
void Mean(void);
/branches/V0.68d Code Redesign killagreg/main.c
85,24 → 85,18
// disable interrupts global
cli();
 
// get board release
DDRB = 0x00;
PORTB = 0x00;
for(timer = 0; timer < 1000; timer++); // make delay
 
 
if(PINB & 0x01) BoardRelease = 11;
else BoardRelease = 10;
 
DDRC = 0x81; // SCL & Speaker
PORTC = 0xff; // Pullup SDA
DDRB = 0x1B; // LEDs und Druckoffset
PORTB = 0x01; // LED_Rot
DDRD = 0x3E; // Speaker & TXD & J3 J4 J5
DDRD |=0x80; // J7
// Set LED Ports as output
DDRB |= (1<<DDB1)|(1<<DDB0);
ROT_ON;
GRN_OFF;
 
PORTD = 0xF7; // LED
 
 
MCUSR &=~(1<<WDRF);
WDTCSR |= (1<<WDCE)|(1<<WDE);
WDTCSR = 0;
116,11 → 110,12
 
ROT_OFF;
 
// initalize modules
TIMER0_Init();
TIMER2_Init();
USART0_Init();
if (BoardRelease == 11) USART1_Init();
rc_sum_init();
RC_Init();
ADC_Init();
i2c_init();
MM3_init();
185,18 → 180,18
I2CTimeout = 5000;
while (1)
{
if(UpdateMotor) // ReglerIntervall
if(UpdateMotor) // control interval
{
//SPI_TransmitByte(); //#
UpdateMotor=0;
UpdateMotor=0; // reset Flag, is enabled every 2 ms by isr of timer0
//PORTD |= 0x08;
MotorRegler();
MotorControl();
 
//PORTD &= ~0x08;
SendMotorData();
ROT_OFF;
if(PcAccess) PcAccess--;
else
else
{
DubWiseKeys[0] = 0;
DubWiseKeys[1] = 0;
/branches/V0.68d Code Redesign killagreg/main.h
18,12 → 18,12
 
 
// neue Hardware
#define ROT_OFF {if(BoardRelease == 10) PORTB &=~0x01; else PORTB |= 0x01;}
#define ROT_ON {if(BoardRelease == 10) PORTB |= 0x01; else PORTB &=~0x01;}
#define ROT_FLASH PORTB ^= 0x01
#define GRN_OFF PORTB &=~0x02
#define GRN_ON PORTB |= 0x02
#define GRN_FLASH PORTB ^= 0x02
#define ROT_OFF {if(BoardRelease == 10) PORTB &=~(1<<PORTB0); else PORTB |= (1<<PORTB0);}
#define ROT_ON {if(BoardRelease == 10) PORTB |= (1<<PORTB0); else PORTB &=~(1<<PORTB0);}
#define ROT_FLASH PORTB ^= (1<<PORTB0)
#define GRN_OFF PORTB &=~(1<<PORTB1)
#define GRN_ON PORTB |= (1<<PORTB1)
#define GRN_FLASH PORTB ^= (1<<PORTB1)
 
 
#include <inttypes.h>
/branches/V0.68d Code Redesign killagreg/rc.c
22,7 → 22,7
/***************************************************************/
/* 16bit timer 1 is used to decode the PPM-Signal */
/***************************************************************/
void rc_sum_init (void)
void RC_Init (void)
{
uint8_t sreg = SREG;
 
/branches/V0.68d Code Redesign killagreg/rc.h
3,7 → 3,7
 
#include <inttypes.h>
 
extern void rc_sum_init (void);
extern void RC_Init (void);
extern volatile int16_t PPM_in[11]; // the RC-Signal
extern volatile int16_t PPM_diff[11]; // the differentiated RC-Signal
extern volatile uint8_t NewPpmData;
/branches/V0.68d Code Redesign killagreg/timer0.c
27,7 → 27,19
// disable all interrupts before reconfiguration
cli();
 
// set PB3 and PB4 as output for the PWM
// configure speaker port as output
if(BoardRelease == 10)
{ // Speaker at PD2
DDRD |= (1<<DDD2);
PORTD &= ~(1<<PORTD2);
}
else
{ // Speaker at PC7
DDRC |= (1<<DDC7);
PORTC &= ~(1<<PORTC7);
}
 
// set PB3 and PB4 as output for the PWM used as aoffset for the pressure sensor
DDRB |= (1<<DDB4)|(1<<DDB3);
PORTB &= ~((1<<PORTB4)|(1<<PORTB3));
 
113,20 → 125,20
if(Beeper_On)
{
// set speaker port to high
if(BoardRelease == 10) PORTD |= (1<<2); // Speaker at PD2
else PORTC |= (1<<7); // Speaker at PC7
if(BoardRelease == 10) PORTD |= (1<<PORTD2); // Speaker at PD2
else PORTC |= (1<<PORTC7); // Speaker at PC7
}
else // beeper is off
{
// set speaker port to low
if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
else PORTC &= ~(1<<PORTC7);// Speaker at PC7
else PORTC &= ~(1<<PORTC7);// Speaker at PC7
}
 
// update compass value if this option is enabled in the settings
if(ParamSet.GlobalConfig & CFG_COMPASS_ACTIVE)
{
MM3_timer0();
MM3_timer0(); // read out mm3 board
}
}
 
/branches/V0.68d Code Redesign killagreg/timer2.c
10,7 → 10,7
/* Initialize Timer 2 */
/*****************************************************/
// The timer 2 is used to generate the PWM at PD7 (J7)
// to control a camera servo for nick compensation.
// to control a camera servo for pitch compensation.
void TIMER2_Init(void)
{
uint8_t sreg = SREG;
18,7 → 18,7
// disable all interrupts before reconfiguration
cli();
 
// set PD7 as output for the PWM
// set PD7 as output pf the PWM for pitch servo
DDRD |=(1<<DDD7);
PORTB |= (1<<PORTD7);
 
/branches/V0.68d Code Redesign killagreg/uart.c
72,9 → 72,9
"NeutralPitch ",
"RollOffset ",
"IntRoll*Factor ", //25
"Reading_GyroPitch ",
"ReadingGyroPitch",
"DirectCorrRoll ",
"Reading_GyroRoll ",
"ReadingGyroRoll ",
"CorrectionRoll ",
"I-AttRoll ", //30
"StickRoll "
/branches/V0.68d Code Redesign killagreg/uart.h
73,22 → 73,4
extern struct str_VersionInfo VersionInfo;
 
 
#if defined (__AVR_ATmega644__)
# define USR UCSR0A
# define UCR UCSR0B
# define UDR UDR0
# define UBRR UBRR0L
# define EICR EICR0B
# define TXEN TXEN0
# define RXEN RXEN0
# define RXCIE RXCIE0
# define TXCIE TXCIE0
# define U2X U2X0
# define UCSRB UCSR0B
# define UDRE UDRE0
# define INT_VEC_RX SIG_USART_RECV
# define INT_VEC_TX SIG_USART_TRANS
#endif
 
 
#endif //_UART_H