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