Subversion Repositories FlightCtrl

Rev

Rev 690 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 690 Rev 694
Line 3... Line 3...
3
#include <avr/interrupt.h>
3
#include <avr/interrupt.h>
4
#include "eeprom.h"
4
#include "eeprom.h"
5
#include "analog.h"
5
#include "analog.h"
6
#include "main.h"
6
#include "main.h"
7
#include "fc.h"
7
#include "fc.h"
-
 
8
#include "mm3.h"
Line 8... Line 9...
8
 
9
 
9
volatile uint16_t CountMilliseconds = 0;
10
volatile uint16_t CountMilliseconds = 0;
10
volatile uint8_t UpdateMotor = 0;
11
volatile uint8_t UpdateMotor = 0;
11
volatile uint16_t cntKompass = 0;
12
volatile uint16_t cntKompass = 0;
Line 28... Line 29...
28
 
29
 
29
        // set PB3 and PB4 as output for the PWM
30
        // set PB3 and PB4 as output for the PWM
30
        DDRB |= (1<<DDB4)|(1<<DDB3);
31
        DDRB |= (1<<DDB4)|(1<<DDB3);
Line -... Line 32...
-
 
32
        PORTB &= ~((1<<PORTB4)|(1<<PORTB3));
-
 
33
 
-
 
34
        if(BoardRelease == 10)
-
 
35
        {
-
 
36
                DDRD |= (1<<DDD2);
-
 
37
                PORTD &= ~(1<<PORTD2);
-
 
38
 
-
 
39
        }
-
 
40
        else
-
 
41
        {
-
 
42
                DDRC |= (1<<DDC7);
-
 
43
                PORTC &= ~(1<<PORTC7);
31
        PORTB &= ~((1<<PORTB4)|(1<<PORTB3));
44
        }
Line 32... Line 45...
32
 
45
 
33
        // Timer/Counter 0 Control Register A
46
        // Timer/Counter 0 Control Register A
34
 
47
 
Line 104... Line 117...
104
                else                      PORTC |= (1<<7); // Speaker at PC7
117
                else                      PORTC |= (1<<7); // Speaker at PC7
105
        }
118
        }
106
        else // beeper is off
119
        else // beeper is off
107
        {
120
        {
108
                // set speaker port to low
121
                // set speaker port to low
109
                if(BoardRelease == 10) PORTD &= ~(1<<2);// Speaker at PD2
122
                if(BoardRelease == 10) PORTD &= ~(1<<PORTD2);// Speaker at PD2
110
                else                      PORTC &= ~(1<<7);// Speaker at PC7
123
                else                      PORTC &= ~(1<<PORTC7);// Speaker at PC7
111
        }
124
        }
Line 112... Line 125...
112
 
125
 
113
        // update compass value if this option is enabled in the settings
126
        // update compass value if this option is enabled in the settings
114
        if(ParamSet.GlobalConfig & CFG_COMPASS_ACTIVE)
127
        if(ParamSet.GlobalConfig & CFG_COMPASS_ACTIVE)
115
        {
-
 
116
                if(PINC & 0x10)
-
 
117
                {
128
        {
118
                        cntKompass++;
-
 
119
                }
-
 
120
        else
-
 
121
        {
-
 
122
                if((cntKompass) && (cntKompass < 4000))
-
 
123
                {
-
 
124
                        KompassValue = cntKompass;
-
 
125
                }
-
 
126
                KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180;
-
 
127
                cntKompass = 0;
-
 
128
                }
129
                MM3_timer0();
129
        }
130
        }
Line 130... Line 131...
130
}
131
}
131
 
132
 
132
 
133
 
133
 
-
 
134
// -----------------------------------------------------------------------
134
 
135
uint16_t SetDelay (uint16_t t)
-
 
136
{
135
// -----------------------------------------------------------------------
Line 137... Line 136...
137
//  TIMSK0 &= ~(1<<TOIE0);
136
uint16_t SetDelay (uint16_t t)
138
  return(CountMilliseconds + t + 1);
137
{
139
//  TIMSK0 |= (1<<TOIE0);
138
  return(CountMilliseconds + t + 1);
140
}
-
 
141
 
139
}
142
// -----------------------------------------------------------------------
-
 
143
int8_t CheckDelay(uint16_t t)
140
 
Line 144... Line 141...
144
{
141
// -----------------------------------------------------------------------
145
//  TIMSK0 &= ~(1<<TOIE0);
142
int8_t CheckDelay(uint16_t t)
146
  return(((t - CountMilliseconds) & 0x8000) >> 9);
143
{