Subversion Repositories FlightCtrl

Rev

Rev 592 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 592 Rev 593
1
#ifndef _MAIN_H
1
#ifndef _MAIN_H
2
 #define _MAIN_H
2
 #define _MAIN_H
3
 
3
 
4
//Hier die Quarz Frequenz einstellen
4
//Hier die Quarz Frequenz einstellen
5
#if defined (__AVR_ATmega32__)
5
#if defined (__AVR_ATmega32__)
6
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
6
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
7
#endif
7
#endif
8
 
8
 
9
#if defined (__AVR_ATmega644__)
9
#if defined (__AVR_ATmega644__)
10
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
10
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
11
//#define SYSCLK        16000000L       //Quarz Frequenz in Hz
11
//#define SYSCLK        16000000L       //Quarz Frequenz in Hz
12
#endif
12
#endif
13
 
13
 
14
// neue Hardware
14
// neue Hardware
15
#define ROT_OFF   {if(PlatinenVersion == 10) PORTB &=~0x01; else  PORTB |= 0x01;}
15
#define ROT_OFF   {if(PlatinenVersion == 10) PORTB &=~0x01; else  PORTB |= 0x01;}
16
#define ROT_ON    {if(PlatinenVersion == 10) PORTB |= 0x01; else  PORTB &=~0x01;}
16
#define ROT_ON    {if(PlatinenVersion == 10) PORTB |= 0x01; else  PORTB &=~0x01;}
17
#define ROT_FLASH PORTB ^= 0x01
17
#define ROT_FLASH PORTB ^= 0x01
18
#define GRN_OFF   PORTB &=~0x02 
18
#define GRN_OFF   PORTB &=~0x02 
19
#define GRN_ON    PORTB |= 0x02 
19
#define GRN_ON    PORTB |= 0x02 
20
#define GRN_FLASH PORTB ^= 0x02
20
#define GRN_FLASH PORTB ^= 0x02
-
 
21
//-------------H.F.------------
-
 
22
#define LED1_ON   PORTC |= 0x04
-
 
23
#define LED1_OFF  PORTC &=~0x04
-
 
24
#define LED2_ON   PORTC |= 0x08
-
 
25
#define LED2_OFF  PORTC &=~0x08
-
 
26
//-------------H.F.------------
21
 
27
 
22
#define F_CPU SYSCLK
28
#define F_CPU SYSCLK
23
//#ifndef F_CPU
29
//#ifndef F_CPU
24
//#error ################## F_CPU nicht definiert oder ungültig #############
30
//#error ################## F_CPU nicht definiert oder ungültig #############
25
//#endif
31
//#endif
26
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27
 
33
 
28
#define EEPROM_ADR_VALID            1
34
#define EEPROM_ADR_VALID            1
29
#define EEPROM_ADR_ACTIVE_SET       2
35
#define EEPROM_ADR_ACTIVE_SET       2
30
#define EEPROM_ADR_LAST_OFFSET      3
36
#define EEPROM_ADR_LAST_OFFSET      3
31
 
37
 
32
#define EEPROM_ADR_ACC_NICK         4
38
#define EEPROM_ADR_ACC_NICK         4
33
#define EEPROM_ADR_ACC_ROLL         6
39
#define EEPROM_ADR_ACC_ROLL         6
34
#define EEPROM_ADR_ACC_Z            8
40
#define EEPROM_ADR_ACC_Z            8
35
 
41
 
36
#define EEPROM_ADR_PARAM_BEGIN      100
42
#define EEPROM_ADR_PARAM_BEGIN      100
37
 
43
 
38
#define CFG_HOEHENREGELUNG       0x01
44
#define CFG_HOEHENREGELUNG       0x01
39
#define CFG_HOEHEN_SCHALTER      0x02
45
#define CFG_HOEHEN_SCHALTER      0x02
40
#define CFG_HEADING_HOLD         0x04
46
#define CFG_HEADING_HOLD         0x04
41
#define CFG_KOMPASS_AKTIV        0x08
47
#define CFG_KOMPASS_AKTIV        0x08
42
#define CFG_KOMPASS_FIX          0x10
48
#define CFG_KOMPASS_FIX          0x10
43
#define CFG_GPS_AKTIV            0x20
49
#define CFG_GPS_AKTIV            0x20
44
#define CFG_ACHSENKOPPLUNG_AKTIV 0x40
50
#define CFG_ACHSENKOPPLUNG_AKTIV 0x40
45
#define CFG_DREHRATEN_BEGRENZER  0x80
51
#define CFG_DREHRATEN_BEGRENZER  0x80
46
 
52
 
47
#define CFG_LOOP_OBEN       0x01
53
#define CFG_LOOP_OBEN       0x01
48
#define CFG_LOOP_UNTEN      0x02
54
#define CFG_LOOP_UNTEN      0x02
49
#define CFG_LOOP_LINKS      0x04
55
#define CFG_LOOP_LINKS      0x04
50
#define CFG_LOOP_RECHTS     0x08
56
#define CFG_LOOP_RECHTS     0x08
51
 
57
 
52
//#define  SYSCLK  
58
//#define  SYSCLK  
53
//extern unsigned long SYSCLK;
59
//extern unsigned long SYSCLK;
54
extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll;
60
extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll;
55
extern volatile unsigned char SenderOkay;
61
extern volatile unsigned char SenderOkay;
56
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
62
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
57
extern unsigned char PlatinenVersion;
63
extern unsigned char PlatinenVersion;
58
 
64
 
59
void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length);
65
void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length);
60
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length);
66
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length);
61
extern unsigned char GetActiveParamSetNumber(void);
67
extern unsigned char GetActiveParamSetNumber(void);
62
extern unsigned char EEPromArray[];
68
extern unsigned char EEPromArray[];
63
 
69
 
64
#include <stdlib.h>
70
#include <stdlib.h>
65
#include <string.h>
71
#include <string.h>
66
#include <avr/io.h>
72
#include <avr/io.h>
67
#include <avr/pgmspace.h>
73
#include <avr/pgmspace.h>
68
#include <avr/interrupt.h>
74
#include <avr/interrupt.h>
69
#include <avr/eeprom.h>
75
#include <avr/eeprom.h>
70
#include <avr/boot.h>
76
#include <avr/boot.h>
71
#include <avr/wdt.h>
77
#include <avr/wdt.h>
72
 
78
 
73
#include "old_macros.h"
79
#include "old_macros.h"
74
 
80
 
75
#include "_Settings.h"
81
#include "_Settings.h"
76
#include "printf_P.h"
82
#include "printf_P.h"
77
#include "timer0.h"
83
#include "timer0.h"
78
#include "uart.h"
84
#include "uart.h"
79
#include "analog.h"
85
#include "analog.h"
80
#include "twimaster.h"
86
#include "twimaster.h"
81
#include "menu.h"
87
#include "menu.h"
82
#include "rc.h"
88
#include "rc.h"
83
#include "fc.h"
89
#include "fc.h"
84
#include "gps.h"
90
#include "gps.h"
85
#include "spi.h"
91
#include "spi.h"
86
 
92
 
87
 
93
 
88
#ifndef EEMEM
94
#ifndef EEMEM
89
#define EEMEM __attribute__ ((section (".eeprom")))
95
#define EEMEM __attribute__ ((section (".eeprom")))
90
#endif
96
#endif
91
 
97
 
92
#define DEBUG_DISPLAY_INTERVALL  123 // in ms
98
#define DEBUG_DISPLAY_INTERVALL  123 // in ms
93
 
99
 
94
 
100
 
95
#define DELAY_US(x)     ((unsigned int)( (x) * 1e-6 * F_CPU ))
101
#define DELAY_US(x)     ((unsigned int)( (x) * 1e-6 * F_CPU ))
96
       
102
       
97
#endif //_MAIN_H
103
#endif //_MAIN_H
98
 
104
 
99
 
105
 
100
 
106
 
101
 
107
 
102
 
108
 
103
 
109
 
104
 
110