Rev 1171 | Rev 1175 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1171 | Rev 1174 | ||
---|---|---|---|
1 | #ifndef _MAIN_H |
1 | #ifndef _MAIN_H |
2 | #define _MAIN_H |
2 | #define _MAIN_H |
3 | 3 | ||
4 | #define QUADRO |
4 | #define QUADRO |
- | 5 | //#define OCTO // 2 Arms in Front |
|
- | 6 | //#define OCTO2 // 1 Arm in front |
|
- | 7 | //#define OCTO3 // 1 Arm with two Motors in front or Coax |
|
- | 8 | ||
- | 9 | //+++++++++++ |
|
- | 10 | // Quadro: |
|
- | 11 | // 1 |
|
- | 12 | // 4 3 |
|
- | 13 | // 2 |
|
- | 14 | //+++++++++++ |
|
- | 15 | // Reverse Props on 1 2 |
|
- | 16 | ||
- | 17 | //+++++++++++ |
|
- | 18 | // Octo: |
|
- | 19 | // 1 2 |
|
- | 20 | // 8 3 |
|
- | 21 | // 7 4 |
|
- | 22 | // 6 5 |
|
- | 23 | //+++++++++++ |
|
- | 24 | ||
- | 25 | //+++++++++++ |
|
- | 26 | // Octo2: |
|
- | 27 | // 1 |
|
- | 28 | // 8 2 |
|
5 | //#define OCTO |
29 | // 7 3 |
- | 30 | // 6 4 |
|
- | 31 | // 5 |
|
- | 32 | //+++++++++++ |
|
- | 33 | ||
- | 34 | //+++++++++++ |
|
- | 35 | // Octo3: |
|
- | 36 | // 1 |
|
- | 37 | // 2 |
|
6 | //#define OCTO2 |
38 | // 8 7 3 4 |
- | 39 | // 5 |
|
- | 40 | // 6 |
|
- | 41 | //+++++++++++ |
|
- | 42 | // Reverse Props on octo: 1 3 5 7 |
|
7 | 43 | ||
8 | 44 | ||
9 | //Hier die Quarz Frequenz einstellen |
45 | //Hier die Quarz Frequenz einstellen |
10 | #if defined (__AVR_ATmega32__) |
46 | #if defined (__AVR_ATmega32__) |
11 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
47 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
12 | #endif |
48 | #endif |
13 | 49 | ||
14 | #if defined (__AVR_ATmega644__) |
50 | #if defined (__AVR_ATmega644__) |
15 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
51 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
16 | #endif |
52 | #endif |
17 | 53 | ||
18 | #if defined (__AVR_ATmega644P__) |
54 | #if defined (__AVR_ATmega644P__) |
19 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
55 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
20 | #endif |
56 | #endif |
21 | 57 | ||
22 | // neue Hardware |
58 | // neue Hardware |
23 | #define ROT_OFF {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB &=~0x01; else PORTB |= 0x01;} |
59 | #define ROT_OFF {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB &=~0x01; else PORTB |= 0x01;} |
24 | #define ROT_ON {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB |= 0x01; else PORTB &=~0x01;} |
60 | #define ROT_ON {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB |= 0x01; else PORTB &=~0x01;} |
25 | #define ROT_FLASH PORTB ^= 0x01 |
61 | #define ROT_FLASH PORTB ^= 0x01 |
26 | #define GRN_OFF {if((PlatinenVersion < 12)) PORTB &=~0x02; else PORTB |= 0x02;} |
62 | #define GRN_OFF {if((PlatinenVersion < 12)) PORTB &=~0x02; else PORTB |= 0x02;} |
27 | #define GRN_ON {if((PlatinenVersion < 12)) PORTB |= 0x02; else PORTB &=~0x02;} |
63 | #define GRN_ON {if((PlatinenVersion < 12)) PORTB |= 0x02; else PORTB &=~0x02;} |
28 | #define GRN_FLASH PORTB ^= 0x02 |
64 | #define GRN_FLASH PORTB ^= 0x02 |
29 | 65 | ||
30 | #define F_CPU SYSCLK |
66 | #define F_CPU SYSCLK |
31 | //#ifndef F_CPU |
67 | //#ifndef F_CPU |
32 | //#error ################## F_CPU nicht definiert oder ungültig ############# |
68 | //#error ################## F_CPU nicht definiert oder ungültig ############# |
33 | //#endif |
69 | //#endif |
34 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
70 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
35 | #define EE_DATENREVISION 74 // wird angepasst, wenn sich die EEPROM-Daten geändert haben |
71 | #define EE_DATENREVISION 74 // wird angepasst, wenn sich die EEPROM-Daten geändert haben |
36 | 72 | ||
37 | #define EEPROM_ADR_VALID 1 |
73 | #define EEPROM_ADR_VALID 1 |
38 | #define EEPROM_ADR_ACTIVE_SET 2 |
74 | #define EEPROM_ADR_ACTIVE_SET 2 |
39 | #define EEPROM_ADR_LAST_OFFSET 3 |
75 | #define EEPROM_ADR_LAST_OFFSET 3 |
40 | 76 | ||
41 | #define EEPROM_ADR_ACC_NICK 4 |
77 | #define EEPROM_ADR_ACC_NICK 4 |
42 | #define EEPROM_ADR_ACC_ROLL 6 |
78 | #define EEPROM_ADR_ACC_ROLL 6 |
43 | #define EEPROM_ADR_ACC_Z 8 |
79 | #define EEPROM_ADR_ACC_Z 8 |
44 | 80 | ||
45 | #define EEPROM_ADR_CHANNELS 80 |
81 | #define EEPROM_ADR_CHANNELS 80 |
46 | 82 | ||
47 | #define EEPROM_ADR_PARAM_LENGTH 98 |
83 | #define EEPROM_ADR_PARAM_LENGTH 98 |
48 | #define EEPROM_ADR_PARAM_BEGIN 100 |
84 | #define EEPROM_ADR_PARAM_BEGIN 100 |
49 | 85 | ||
50 | #define CFG_HOEHENREGELUNG 0x01 |
86 | #define CFG_HOEHENREGELUNG 0x01 |
51 | #define CFG_HOEHEN_SCHALTER 0x02 |
87 | #define CFG_HOEHEN_SCHALTER 0x02 |
52 | #define CFG_HEADING_HOLD 0x04 |
88 | #define CFG_HEADING_HOLD 0x04 |
53 | #define CFG_KOMPASS_AKTIV 0x08 |
89 | #define CFG_KOMPASS_AKTIV 0x08 |
54 | #define CFG_KOMPASS_FIX 0x10 |
90 | #define CFG_KOMPASS_FIX 0x10 |
55 | #define CFG_GPS_AKTIV 0x20 |
91 | #define CFG_GPS_AKTIV 0x20 |
56 | #define CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
92 | #define CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
57 | #define CFG_DREHRATEN_BEGRENZER 0x80 |
93 | #define CFG_DREHRATEN_BEGRENZER 0x80 |
58 | 94 | ||
59 | #define CFG_LOOP_OBEN 0x01 |
95 | #define CFG_LOOP_OBEN 0x01 |
60 | #define CFG_LOOP_UNTEN 0x02 |
96 | #define CFG_LOOP_UNTEN 0x02 |
61 | #define CFG_LOOP_LINKS 0x04 |
97 | #define CFG_LOOP_LINKS 0x04 |
62 | #define CFG_LOOP_RECHTS 0x08 |
98 | #define CFG_LOOP_RECHTS 0x08 |
63 | #define CFG_HIGHT_3SWITCH 0x10 |
99 | #define CFG_HIGHT_3SWITCH 0x10 |
64 | 100 | ||
65 | #define J3High PORTD |= 0x20 |
101 | #define J3High PORTD |= 0x20 |
66 | #define J3Low PORTD &= ~0x20 |
102 | #define J3Low PORTD &= ~0x20 |
67 | #define J4High PORTD |= 0x10 |
103 | #define J4High PORTD |= 0x10 |
68 | #define J4Low PORTD &= ~0x10 |
104 | #define J4Low PORTD &= ~0x10 |
69 | #define J5High PORTD |= 0x08 |
105 | #define J5High PORTD |= 0x08 |
70 | #define J5Low PORTD &= ~0x08 |
106 | #define J5Low PORTD &= ~0x08 |
71 | 107 | ||
72 | 108 | ||
73 | //#define SYSCLK |
109 | //#define SYSCLK |
74 | //extern unsigned long SYSCLK; |
110 | //extern unsigned long SYSCLK; |
75 | extern volatile unsigned char SenderOkay; |
111 | extern volatile unsigned char SenderOkay; |
76 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
112 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
77 | extern unsigned char PlatinenVersion; |
113 | extern unsigned char PlatinenVersion; |
78 | extern unsigned char SendVersionToNavi; |
114 | extern unsigned char SendVersionToNavi; |
79 | void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length); |
115 | void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length); |
80 | void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length); |
116 | void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length); |
81 | extern unsigned char GetActiveParamSetNumber(void); |
117 | extern unsigned char GetActiveParamSetNumber(void); |
82 | void SetActiveParamSetNumber(unsigned char number); |
118 | void SetActiveParamSetNumber(unsigned char number); |
83 | extern unsigned char EEPromArray[]; |
119 | extern unsigned char EEPromArray[]; |
84 | 120 | ||
85 | #include <stdlib.h> |
121 | #include <stdlib.h> |
86 | #include <string.h> |
122 | #include <string.h> |
87 | #include <avr/io.h> |
123 | #include <avr/io.h> |
88 | #include <avr/pgmspace.h> |
124 | #include <avr/pgmspace.h> |
89 | #include <avr/interrupt.h> |
125 | #include <avr/interrupt.h> |
90 | #include <avr/eeprom.h> |
126 | #include <avr/eeprom.h> |
91 | #include <avr/boot.h> |
127 | #include <avr/boot.h> |
92 | #include <avr/wdt.h> |
128 | #include <avr/wdt.h> |
93 | 129 | ||
94 | #include "old_macros.h" |
130 | #include "old_macros.h" |
95 | 131 | ||
96 | #include "_Settings.h" |
132 | #include "_Settings.h" |
97 | #include "printf_P.h" |
133 | #include "printf_P.h" |
98 | #include "timer0.h" |
134 | #include "timer0.h" |
99 | #include "uart.h" |
135 | #include "uart.h" |
100 | #include "analog.h" |
136 | #include "analog.h" |
101 | #include "twimaster.h" |
137 | #include "twimaster.h" |
102 | #include "menu.h" |
138 | #include "menu.h" |
103 | #include "rc.h" |
139 | #include "rc.h" |
104 | #include "fc.h" |
140 | #include "fc.h" |
105 | #include "gps.h" |
141 | #include "gps.h" |
106 | #include "spi.h" |
142 | #include "spi.h" |
107 | #include "led.h" |
143 | #include "led.h" |
108 | 144 | ||
109 | #ifndef EEMEM |
145 | #ifndef EEMEM |
110 | #define EEMEM __attribute__ ((section (".eeprom"))) |
146 | #define EEMEM __attribute__ ((section (".eeprom"))) |
111 | #endif |
147 | #endif |
112 | 148 | ||
113 | #define DEBUG_DISPLAY_INTERVALL 123 // in ms |
149 | #define DEBUG_DISPLAY_INTERVALL 123 // in ms |
114 | 150 | ||
115 | 151 | ||
116 | #define DELAY_US(x) ((unsigned int)( (x) * 1e-6 * F_CPU )) |
152 | #define DELAY_US(x) ((unsigned int)( (x) * 1e-6 * F_CPU )) |
117 | 153 | ||
118 | #endif //_MAIN_H |
154 | #endif //_MAIN_H |
119 | 155 | ||
120 | 156 | ||
121 | 157 | ||
122 | 158 | ||
123 | 159 | ||
124 | 160 | ||
125 | 161 |