Subversion Repositories FlightCtrl

Rev

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

Rev 685 Rev 687
Line 47... Line 47...
47
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47
// +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48
// +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49
// +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50
// +  POSSIBILITY OF SUCH DAMAGE.
50
// +  POSSIBILITY OF SUCH DAMAGE.
51
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
52
#include <avr/boot.h>
-
 
53
 
-
 
54
#include <avr/io.h>
-
 
55
#include <avr/interrupt.h>
-
 
56
 
52
#include "main.h"
57
#include "main.h"
53
#include "timer0.h"
58
#include "timer0.h"
54
#include "timer2.h"
59
#include "timer2.h"
55
#include "uart.h"
60
#include "uart.h"
56
#include "uart1.h"
61
#include "uart1.h"
Line 63... Line 68...
63
#include "twimaster.h"
68
#include "twimaster.h"
64
#include "eeprom.h"
69
#include "eeprom.h"
65
#include "_Settings.h"
70
#include "_Settings.h"
Line 66... Line -...
66
 
-
 
67
 
-
 
Line 68... Line -...
68
uint8_t EEPromArray[E2END+1] EEMEM;
-
 
69
uint8_t BoardRelease = 10;
-
 
70
 
-
 
71
// -- Parametersatz aus EEPROM lesen ---
-
 
72
// number [0..5]
71
 
73
void ReadParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
-
 
74
{
-
 
Line 75... Line -...
75
   if (number > 5) number = 5;
-
 
76
   eeprom_read_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
-
 
77
}
-
 
78
 
-
 
79
 
-
 
80
// -- Parametersatz ins EEPROM schreiben ---
-
 
81
// number [0..5]
-
 
82
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length)
-
 
83
{
-
 
84
   if(number > 5) number = 5;
-
 
85
   eeprom_write_block(buffer, &EEPromArray[EEPROM_ADR_PARAM_BEGIN + length * number], length);
-
 
86
   eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], number);                              // diesen Parametersatz als aktuell merken
-
 
87
}
-
 
88
 
-
 
89
/***************************************************/
-
 
90
/*       Get number of active parameter set        */
-
 
91
/***************************************************/
-
 
92
uint8_t GetActiveParamSetNumber(void)
-
 
93
{
-
 
94
        uint8_t set;
-
 
95
        set = eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET]);
-
 
96
        if(set > 5)
-
 
97
        {
-
 
98
        set = 2;
-
 
99
        eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], set);                            // diesen Parametersatz als aktuell merken
72
 
100
        }
73
 
101
        return(set);
74
uint8_t BoardRelease = 10;
102
}
75
 
103
 
76
 
Line 160... Line 133...
160
 
133
 
161
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",BoardRelease/10,BoardRelease%10, VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX + 'a');
134
        printf("\n\rFlightControl\n\rHardware:%d.%d\n\rSoftware:V%d.%d%c ",BoardRelease/10,BoardRelease%10, VERSION_HAUPTVERSION, VERSION_NEBENVERSION,VERSION_INDEX + 'a');
162
        printf("\n\r==============================");
135
        printf("\n\r==============================");
Line 163... Line -...
163
        GRN_ON;
-
 
164
 
-
 
165
#define EE_DATENREVISION 69 // wird angepasst, wenn sich die EEPROM-Daten geƤndert haben
-
 
166
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_VALID]) != EE_DATENREVISION)
-
 
167
        {
136
        GRN_ON;
168
          printf("\n\rInit. EEPROM: Generiere Default-Parameter...");
137
 
169
          DefaultKonstanten1();
-
 
170
          for (unsigned char i=0;i<6;i++)
-
 
171
      {
-
 
172
       if(i==2) DefaultKonstanten2(); // Kamera
-
 
173
       if(i==3) DefaultKonstanten3(); // Beginner
-
 
174
       if(i>3)  DefaultKonstanten2(); // Kamera
-
 
175
       WriteParameterSet(i, (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
-
 
176
      }
-
 
177
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], 3); // default-Setting
-
 
Line 178... Line 138...
178
          eeprom_write_byte(&EEPromArray[EEPROM_ADR_VALID], EE_DATENREVISION);
138
        // Parameter set handling
179
        }
139
        ParamSet_Init();
180
 
140
 
181
    if(eeprom_read_byte(&EEPromArray[EEPROM_ADR_ACC_NICK]) > 4)
141
    if(GetParamByte(PID_ACC_NICK) > 4)
Line 182... Line -...
182
     {
-
 
183
       printf("\n\rACC nicht abgeglichen!");
-
 
184
     }
-
 
Line 185... Line 142...
185
 
142
     {
186
        ReadParameterSet(GetActiveParamSetNumber(), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE);
143
       printf("\n\rACC nicht abgeglichen!");
187
    printf("\n\rBenutze Parametersatz %d", GetActiveParamSetNumber());
144
     }
188
 
145
 
189
 
146
 
190
        if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG)
147
        if(ParamSet.GlobalConfig & CFG_HOEHENREGELUNG)
Line 203... Line 160...
203
    BeepTime = 2000;
160
    BeepTime = 2000;
204
    ExternControl.Digital[0] = 0x55;
161
    ExternControl.Digital[0] = 0x55;
Line 205... Line 162...
205
 
162
 
206
 
163
 
207
        printf("\n\rSteuerung: ");
164
        printf("\n\rSteuerung: ");
Line 208... Line 165...
208
        if (EE_Parameter.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
165
        if (ParamSet.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold");
Line 209... Line 166...
209
        else printf("Neutral");
166
        else printf("Neutral");
Line 256... Line 213...
256
               BearbeiteRxDaten();
213
               BearbeiteRxDaten();
257
              }
214
              }
258
              else BearbeiteRxDaten();
215
              else BearbeiteRxDaten();
259
         if(CheckDelay(timer))
216
         if(CheckDelay(timer))
260
            {
217
            {
261
            if(UBat < EE_Parameter.UnterspannungsWarnung)
218
            if(UBat < ParamSet.UnterspannungsWarnung)
262
                {
219
                {
263
                  if(BeepModulation == 0xFFFF)
220
                  if(BeepModulation == 0xFFFF)
264
                   {
221
                   {
265
                    BeepTime = 6000; // 0.6 seconds
222
                    BeepTime = 6000; // 0.6 seconds
266
                    BeepModulation = 0x0300;
223
                    BeepModulation = 0x0300;