Subversion Repositories FlightCtrl

Rev

Rev 885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 885 Rev 886
Line -... Line 1...
-
 
1
#include <inttypes.h>
-
 
2
#include <avr/io.h>
-
 
3
#include <avr/interrupt.h>
-
 
4
#include "eeprom.h"
-
 
5
#include "analog.h"
1
#include "main.h"
6
#include "main.h"
109
}
161
}
Line -... Line 162...
-
 
162
 
-
 
163
 
110
 
164
 
-
 
165
// -----------------------------------------------------------------------
-
 
166
uint16_t SetDelay (uint16_t t)
-
 
167
{
-
 
168
  return(CountMilliseconds + t + 1);
Line -... Line 169...
-
 
169
}
111
// -----------------------------------------------------------------------
170
 
112
 
171
// -----------------------------------------------------------------------
113
unsigned int SetDelay (unsigned int t)
-
 
114
{
172
int8_t CheckDelay(uint16_t t)
115
//  TIMSK0 &= ~_BV(TOIE0);
-
 
116
  return(CountMilliseconds + t + 1);                                            
173
{
Line 117... Line 174...
117
//  TIMSK0 |= _BV(TOIE0);
174
  return(((t - CountMilliseconds) & 0x8000) >> 9); // check sign bit
118
}
175
}
119
 
176
 
120
// -----------------------------------------------------------------------
177
// -----------------------------------------------------------------------
121
char CheckDelay(unsigned int t)
178
void Delay_ms(uint16_t w)
122
{
179
{
123
//  TIMSK0 &= ~_BV(TOIE0);
180
 unsigned int t_stop;
Line 124... Line 181...
124
  return(((t - CountMilliseconds) & 0x8000) >> 9);
181
 t_stop = SetDelay(w);
125
//  TIMSK0 |= _BV(TOIE0);
182
 while (!CheckDelay(t_stop));
126
}
183
}
127
 
184
 
128
// -----------------------------------------------------------------------
185
// -----------------------------------------------------------------------
129
void Delay_ms(unsigned int w)
-
 
130
{
-
 
131
 unsigned int akt;
-
 
132
 akt = SetDelay(w);
-
 
133
 while (!CheckDelay(akt));
-
 
134
}
-
 
135
 
-
 
136
void Delay_ms_Mess(unsigned int w)
186
void Delay_ms_Mess(uint16_t w)
137
{
-
 
138
 unsigned int akt;
-
 
139
 akt = SetDelay(w);
-
 
140
 while (!CheckDelay(akt)) ANALOG_ON;
-
 
141
}
-
 
142
 
-
 
143
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
144
//  Servo ansteuern
-
 
145
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
146
SIGNAL(SIG_OUTPUT_COMPARE2A)
-
 
147
{
-
 
148
  static unsigned char timer = 10;
-
 
149
 
-
 
150
  if(!timer--)  
-
 
151
    {
-
 
152
     TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3;  
-
 
153
     ServoValue =  Parameter_ServoNickControl;
-
 
154
     if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512;
-
 
155
     else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512;
-
 
156
     
-
 
157
     if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin;
-
 
158
     else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax;
-
 
159
 
-
 
160
     OCR2A = ServoValue;// + 75;
-
 
161
     timer = EE_Parameter.ServoNickRefresh;
-
 
162
    }
-
 
163
    else
-
 
164
    {
187
{
-
 
188
 uint16_t t_stop;