Rev 520 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 520 | Rev 522 | ||
---|---|---|---|
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 | #if defined (__AVR_ATmega644P__) |
|
- | 15 | #define SYSCLK 20000000L //Quarz Frequenz in Hz |
|
- | 16 | //#define SYSCLK 16000000L //Quarz Frequenz in Hz |
|
- | 17 | #endif |
|
13 | 18 | ||
14 | // neue Hardware |
19 | // neue Hardware |
15 | #define ROT_OFF {if(PlatinenVersion == 10) PORTB &=~0x01; else PORTB |= 0x01;} |
20 | #define ROT_OFF {if(PlatinenVersion == 10) PORTB &=~0x01; else PORTB |= 0x01;} |
16 | #define ROT_ON {if(PlatinenVersion == 10) PORTB |= 0x01; else PORTB &=~0x01;} |
21 | #define ROT_ON {if(PlatinenVersion == 10) PORTB |= 0x01; else PORTB &=~0x01;} |
17 | #define ROT_FLASH PORTB ^= 0x01 |
22 | #define ROT_FLASH PORTB ^= 0x01 |
18 | #define GRN_OFF PORTB &=~0x02 |
23 | #define GRN_OFF PORTB &=~0x02 |
19 | #define GRN_ON PORTB |= 0x02 |
24 | #define GRN_ON PORTB |= 0x02 |
20 | #define GRN_FLASH PORTB ^= 0x02 |
25 | #define GRN_FLASH PORTB ^= 0x02 |
21 | #define LED1_OFF PORTC &=~0x04 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
26 | #define LED1_OFF PORTC &=~0x04 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
22 | #define LED1_ON PORTC |= 0x04 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
27 | #define LED1_ON PORTC |= 0x04 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
23 | #define LED1_FLASH PORTC ^= 0x04 //Erweiterung by 4ndreas aus mikrosvn branches // (280807Kr) |
28 | #define LED1_FLASH PORTC ^= 0x04 //Erweiterung by 4ndreas aus mikrosvn branches // (280807Kr) |
24 | #define LED2_OFF PORTC &=~0x08 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
29 | #define LED2_OFF PORTC &=~0x08 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
25 | #define LED2_ON PORTC |= 0x08 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
30 | #define LED2_ON PORTC |= 0x08 //Erweiterung von Smartie aus dem MK-Forum vom 14.06.07. Dadurch können die Transistorausgänge J16 und J17 geschaltet werden. // (160607Kr) |
26 | #define LED2_FLASH PORTC ^= 0x08 //Erweiterung by 4ndreas aus mikrosvn branches // (280807Kr) |
31 | #define LED2_FLASH PORTC ^= 0x08 //Erweiterung by 4ndreas aus mikrosvn branches // (280807Kr) |
27 | 32 | ||
28 | #define F_CPU SYSCLK |
33 | #define F_CPU SYSCLK |
29 | //#ifndef F_CPU |
34 | //#ifndef F_CPU |
30 | //#error ################## F_CPU nicht definiert oder ungültig ############# |
35 | //#error ################## F_CPU nicht definiert oder ungültig ############# |
31 | //#endif |
36 | //#endif |
32 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
37 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | 38 | ||
34 | #define EEPROM_ADR_VALID 1 |
39 | #define EEPROM_ADR_VALID 1 |
35 | #define EEPROM_ADR_ACTIVE_SET 2 |
40 | #define EEPROM_ADR_ACTIVE_SET 2 |
36 | #define EEPROM_ADR_LAST_OFFSET 3 |
41 | #define EEPROM_ADR_LAST_OFFSET 3 |
37 | 42 | ||
38 | #define EEPROM_ADR_ACC_NICK 4 |
43 | #define EEPROM_ADR_ACC_NICK 4 |
39 | #define EEPROM_ADR_ACC_ROLL 6 |
44 | #define EEPROM_ADR_ACC_ROLL 6 |
40 | #define EEPROM_ADR_ACC_Z 8 |
45 | #define EEPROM_ADR_ACC_Z 8 |
41 | 46 | ||
42 | #define EEPROM_ADR_PARAM_BEGIN 100 |
47 | #define EEPROM_ADR_PARAM_BEGIN 100 |
43 | 48 | ||
44 | #define CFG_HOEHENREGELUNG 0x01 |
49 | #define CFG_HOEHENREGELUNG 0x01 |
45 | #define CFG_HOEHEN_SCHALTER 0x02 |
50 | #define CFG_HOEHEN_SCHALTER 0x02 |
46 | #define CFG_HEADING_HOLD 0x04 |
51 | #define CFG_HEADING_HOLD 0x04 |
47 | #define CFG_KOMPASS_AKTIV 0x08 |
52 | #define CFG_KOMPASS_AKTIV 0x08 |
48 | #define CFG_KOMPASS_FIX 0x10 |
53 | #define CFG_KOMPASS_FIX 0x10 |
49 | #define CFG_GPS_AKTIV 0x20 |
54 | #define CFG_GPS_AKTIV 0x20 |
50 | #define CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
55 | #define CFG_ACHSENKOPPLUNG_AKTIV 0x40 |
51 | #define CFG_DREHRATEN_BEGRENZER 0x80 |
56 | #define CFG_DREHRATEN_BEGRENZER 0x80 |
52 | 57 | ||
53 | #define CFG_LOOP_OBEN 0x01 |
58 | #define CFG_LOOP_OBEN 0x01 |
54 | #define CFG_LOOP_UNTEN 0x02 |
59 | #define CFG_LOOP_UNTEN 0x02 |
55 | #define CFG_LOOP_LINKS 0x04 |
60 | #define CFG_LOOP_LINKS 0x04 |
56 | #define CFG_LOOP_RECHTS 0x08 |
61 | #define CFG_LOOP_RECHTS 0x08 |
57 | 62 | ||
58 | //#define SYSCLK |
63 | //#define SYSCLK |
59 | //extern unsigned long SYSCLK; |
64 | //extern unsigned long SYSCLK; |
60 | extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll; |
65 | extern volatile int i_Nick[20],i_Roll[20],DiffNick,DiffRoll; |
61 | extern volatile unsigned char SenderOkay; |
66 | extern volatile unsigned char SenderOkay; |
62 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
67 | extern unsigned char CosinusNickWinkel, CosinusRollWinkel; |
63 | extern unsigned char PlatinenVersion; |
68 | extern unsigned char PlatinenVersion; |
64 | 69 | ||
65 | void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length); |
70 | void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length); |
66 | void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length); |
71 | void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length); |
67 | extern unsigned char GetActiveParamSetNumber(void); |
72 | extern unsigned char GetActiveParamSetNumber(void); |
68 | extern unsigned char EEPromArray[]; |
73 | extern unsigned char EEPromArray[]; |
69 | 74 | ||
70 | volatile int P_GPS_Verstaerkung; //P-Anteil (80-120) |
75 | volatile int P_GPS_Verstaerkung; //P-Anteil (80-120) |
71 | volatile int D_GPS_Verstaerkung; //D-Anteil (90) |
76 | volatile int D_GPS_Verstaerkung; //D-Anteil (90) |
72 | 77 | ||
73 | #include <stdlib.h> |
78 | #include <stdlib.h> |
74 | #include <string.h> |
79 | #include <string.h> |
75 | #include <avr/io.h> |
80 | #include <avr/io.h> |
76 | #include <avr/pgmspace.h> |
81 | #include <avr/pgmspace.h> |
77 | #include <avr/interrupt.h> |
82 | #include <avr/interrupt.h> |
78 | #include <avr/eeprom.h> |
83 | #include <avr/eeprom.h> |
79 | #include <avr/boot.h> |
84 | #include <avr/boot.h> |
80 | #include <avr/wdt.h> |
85 | #include <avr/wdt.h> |
81 | 86 | ||
82 | #include "old_macros.h" |
87 | #include "old_macros.h" |
83 | 88 | ||
84 | #include "_Settings.h" |
89 | #include "_Settings.h" |
85 | #include "printf_P.h" |
90 | #include "printf_P.h" |
86 | #include "timer0.h" |
91 | #include "timer0.h" |
87 | #include "uart.h" |
92 | #include "uart.h" |
88 | #include "analog.h" |
93 | #include "analog.h" |
89 | #include "twimaster.h" |
94 | #include "twimaster.h" |
90 | #include "menu.h" |
95 | #include "menu.h" |
91 | #include "rc.h" |
96 | #include "rc.h" |
92 | #include "fc.h" |
97 | #include "fc.h" |
93 | #include "gps.h" |
98 | #include "gps.h" |
94 | #include "spi.h" |
99 | #include "spi.h" |
95 | 100 | ||
96 | 101 | ||
97 | #ifndef EEMEM |
102 | #ifndef EEMEM |
98 | #define EEMEM __attribute__ ((section (".eeprom"))) |
103 | #define EEMEM __attribute__ ((section (".eeprom"))) |
99 | #endif |
104 | #endif |
100 | 105 | ||
101 | #define DEBUG_DISPLAY_INTERVALL 123 // in ms |
106 | #define DEBUG_DISPLAY_INTERVALL 123 // in ms |
102 | 107 | ||
103 | 108 | ||
104 | #define DELAY_US(x) ((unsigned int)( (x) * 1e-6 * F_CPU )) |
109 | #define DELAY_US(x) ((unsigned int)( (x) * 1e-6 * F_CPU )) |
105 | 110 | ||
106 | #endif //_MAIN_H |
111 | #endif //_MAIN_H |
107 | 112 | ||
108 | 113 | ||
109 | 114 | ||
110 | 115 | ||
111 | 116 | ||
112 | 117 | ||
113 | 118 |