Rev 17 | Rev 37 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 17 | Rev 32 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _MAIN_H |
1 | #ifndef _MAIN_H_ |
2 | #define _MAIN_H |
2 | #define _MAIN_H_ |
Line 3... | Line -... | ||
3 | - | ||
4 | - | ||
5 | #include <stdio.h> |
- | |
6 | #include <math.h> |
- | |
7 | #include <stdlib.h> |
- | |
8 | #include <string.h> |
- | |
9 | #include <avr/io.h> |
- | |
10 | #include <avr/pgmspace.h> |
- | |
11 | #include <avr/interrupt.h> |
- | |
12 | #include <avr/eeprom.h> |
- | |
13 | #include <avr/boot.h> |
3 | |
- | 4 | ||
- | 5 | #include <avr/eeprom.h> |
|
- | 6 | #include <inttypes.h> |
|
- | 7 | ||
- | 8 | ||
- | 9 | typedef enum |
|
- | 10 | { |
|
- | 11 | ATTITUDE_SOURCE_I2C, |
|
- | 12 | ATTITUDE_SOURCE_UART, |
|
- | 13 | ATTITUDE_SOURCE_ACC |
|
- | 14 | } AttitudeSource_t; |
|
- | 15 | ||
- | 16 | ||
- | 17 | typedef enum |
|
- | 18 | { |
|
- | 19 | ORIENTATION_NC = 0, |
|
- | 20 | ORIENTATION_FC = 1 |
|
- | 21 | } Orientation_t; |
|
- | 22 | ||
- | 23 | ||
- | 24 | extern int16_t Heading; |
|
- | 25 | ||
- | 26 | extern AttitudeSource_t AttitudeSource; |
|
- | 27 | extern Orientation_t Orientation; |
|
Line 14... | Line -... | ||
14 | #include <avr/wdt.h> |
- | |
15 | #include <avr/eeprom.h> |
- | |
16 | - | ||
17 | #include "twislave.h" |
- | |
18 | #include "old_macros.h" |
- | |
19 | #include "analog.h" |
- | |
20 | #include "uart.h" |
- | |
21 | #include "timer0.h" |
- | |
22 | - | ||
23 | - | ||
24 | #if defined(__AVR_ATmega8__) |
- | |
25 | # define OC1 PB1 |
- | |
26 | # define DDROC DDRB |
- | |
27 | # define OCR OCR1A |
- | |
28 | # define PWM10 WGM10 |
- | |
29 | # define PWM11 WGM11 |
- | |
30 | #endif |
- | |
31 | - | ||
32 | #define SYSCLK 8000000L //Quarz Frequenz in Hz |
- | |
33 | - | ||
34 | #define INT0_ENABLE GIMSK |= 0x40 |
- | |
35 | #define INT0_DISABLE GIMSK &= ~0x40 |
- | |
36 | #define TIM0_START TIMSK0 |= _BV(TOIE0) |
- | |
37 | #define TIM0_STOPP TIMSK0 &= ~_BV(TOIE0) |
- | |
38 | - | ||
39 | #define ICP_INT_ENABLE TIMSK0 |= 0x20 |
- | |
40 | #define ICP_INT_DISABLE TIMSK0 &= ~0x20 |
- | |
41 | #define TIMER1_INT_ENABLE TIMSK0 |= 0x04 |
- | |
42 | #define TIMER1_INT_DISABLE TIMSK0 &= ~0x04 |
- | |
43 | #define TIMER2_INT_ENABLE TIMSK0 |= 0x40 |
- | |
44 | #define TIMER2_INT_DISABLE TIMSK0 &= ~0x40 |
- | |
45 | #define INT0_POS_FLANKE MCUCR |= 0x01 |
- | |
46 | #define INT0_ANY_FLANKE MCUCR |= 0x01 |
- | |
47 | #define INT0_NEG_FLANKE MCUCR &= ~0x01 |
- | |
48 | #define CLR_INT0_FLAG GIFR &= ~0x40 |
- | |
49 | #define INIT_INT0_FLANKE MCUCR &= ~0x03; MCUCR |= 0x02; |
- | |
50 | #define TIMER0_PRESCALER TCCR0 |
- | |
51 | #define ICP_POS_FLANKE TCCR1B |= (1<<ICES1) |
- | |
52 | #define ICP_NEG_FLANKE TCCR1B &= ~(1<<ICES1) |
- | |
53 | - | ||
54 | #define LED_ON PORTD |= 0x80 |
- | |
55 | #define LED_OFF PORTD &= ~0x80 |
- | |
56 | #define FLIP_HIGH PORTD |= 0x60 |
- | |
57 | #define FLIP_LOW PORTD &= ~0x60 |
- | |
58 | #define PIN_J3 (PIND & 0x08) |
- | |
59 | - | ||
60 | extern unsigned int PwmHeading; |
- | |
61 | extern unsigned int PC_Connected; |
- | |
62 | extern unsigned int Heading; |
- | |
63 | extern signed int MagnetN,MagnetR,MagnetZ; |
- | |
64 | extern signed int RawAccN, RawAccR, RawAccZ; |
- | |
65 | extern signed int AccN, AccR, AccZ; |
- | |
66 | extern signed int OffsetAccN, OffsetAccR, OffsetAccZ; |
- | |
67 | extern unsigned char AngleSource; |
- | |
68 | extern uint16_t eeXmin EEMEM; |
- | |
69 | extern uint16_t eeXmax EEMEM; |
- | |
70 | extern uint16_t eeYmin EEMEM; |
- | |
71 | extern uint16_t eeYmax EEMEM; |
28 | |
Line 72... | Line 29... | ||
72 | extern uint16_t eeZmin EEMEM; |
29 | extern int16_t MagX, MagY, MagZ; |