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