Subversion Repositories FlightCtrl

Rev

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

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