Subversion Repositories FlightCtrl

Rev

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

Rev 624 Rev 683
Line 1... Line 1...
1
#include "main.h"
1
#include "main.h"
Line 105... Line 123...
105
   
123
        }
Line 106... Line -...
106
}
-
 
Line -... Line 124...
-
 
124
}
-
 
125
 
107
 
126
 
108
// -----------------------------------------------------------------------
127
 
109
 
128
// -----------------------------------------------------------------------
110
unsigned int SetDelay (unsigned int t)
129
uint16_t SetDelay (uint16_t t)
111
{
130
{
112
//  TIMSK0 &= ~_BV(TOIE0);
131
//  TIMSK0 &= ~(1<<TOIE0);
Line 113... Line 132...
113
  return(CountMilliseconds + t + 1);                                            
132
  return(CountMilliseconds + t + 1);
114
//  TIMSK0 |= _BV(TOIE0);
133
//  TIMSK0 |= (1<<TOIE0);
115
}
134
}
116
 
135
 
117
// -----------------------------------------------------------------------
136
// -----------------------------------------------------------------------
118
char CheckDelay(unsigned int t)
137
int8_t CheckDelay(uint16_t t)
-
 
138
{
-
 
139
//  TIMSK0 &= ~(1<<TOIE0);
-
 
140
  return(((t - CountMilliseconds) & 0x8000) >> 9);
-
 
141
//  TIMSK0 |= (1<<TOIE0);
-
 
142
}
-
 
143
 
-
 
144
// -----------------------------------------------------------------------
-
 
145
void Delay_ms(uint16_t w)
119
{
146
{
Line 120... Line 147...
120
//  TIMSK0 &= ~_BV(TOIE0);
147
 unsigned int t_stop;
121
  return(((t - CountMilliseconds) & 0x8000) >> 9);
148
 t_stop = SetDelay(w);
122
//  TIMSK0 |= _BV(TOIE0);
149
 while (!CheckDelay(t_stop));
123
}
150
}
124
 
151
 
125
// -----------------------------------------------------------------------
-
 
126
void Delay_ms(unsigned int w)
-
 
127
{
-
 
128
 unsigned int akt;
-
 
129
 akt = SetDelay(w);
-
 
130
 while (!CheckDelay(akt));
-
 
131
}
-
 
132
 
152
// -----------------------------------------------------------------------
133
void Delay_ms_Mess(unsigned int w)
-
 
134
{
-
 
135
 unsigned int akt;
-
 
136
 akt = SetDelay(w);
-
 
137
 while (!CheckDelay(akt)) ANALOG_ON;
-
 
138
}
-
 
139
 
-
 
140
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
141
//  Servo ansteuern
-
 
142
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                
-
 
143
SIGNAL(SIG_OUTPUT_COMPARE2A)
-
 
144
{
-
 
145
  static unsigned char timer = 10;
-
 
146
 
-
 
147
  if(!timer--)  
-
 
148
    {
-
 
149
     TCCR2A=(1<<COM2A1)|(0<<COM2A0)|3;  
-
 
150
     ServoValue =  Parameter_ServoNickControl;
-
 
151
     if(EE_Parameter.ServoNickCompInvert & 0x01) ServoValue += ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512;
-
 
152
     else ServoValue -= ((long) EE_Parameter.ServoNickComp * (IntegralNick / 128)) / 512;
-
 
153
     
-
 
154
     if(ServoValue < EE_Parameter.ServoNickMin) ServoValue = EE_Parameter.ServoNickMin;
-
 
155
     else if(ServoValue > EE_Parameter.ServoNickMax) ServoValue = EE_Parameter.ServoNickMax;
-
 
156
 
-
 
157
     OCR2A = ServoValue;// + 75;
-
 
158
     timer = EE_Parameter.ServoNickRefresh;
-
 
159
    }
-
 
160
    else
153
void Delay_ms_Mess(uint16_t w)
-
 
154
{