Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1734 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
5
 *   Copyright (C) 2011 Harald Bongartz                                      *
6
 *                                                                           *
7
 *   This program is free software; you can redistribute it and/or modify    *
8
 *   it under the terms of the GNU General Public License as published by    *
9
 *   the Free Software Foundation; either version 2 of the License.          *
10
 *                                                                           *
11
 *   This program is distributed in the hope that it will be useful,         *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14
 *   GNU General Public License for more details.                            *
15
 *                                                                           *
16
 *   You should have received a copy of the GNU General Public License       *
17
 *   along with this program; if not, write to the                           *
18
 *   Free Software Foundation, Inc.,                                         *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
20
 *                                                                           *
21
 *                                                                           *
22
 *   Credits to:                                                             *
23
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
24
 *                          http://www.mikrokopter.de                        *
25
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
26
 *   Thomas Kaiser "thkais" for the original project. See                    *
27
 *                          http://www.ft-fanpage.de/mikrokopter/            *
28
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
29
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
30
 *                          http://www.mylifesucks.de/oss/c-osd/             *
31
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
32
 *****************************************************************************/
33
 
34
 
35
// *Hardwareabhängige Definitionen und Prozeduren
36
// * Hardware Leiterplatte V1.2 sebseb7
37
 
38
 
39
#ifndef HAL_HW1_2_C_
40
#define HAL_HW1_2_C_
41
 
42
 
43
 
44
 
45
 
46
#include "cpu.h"
47
#include <inttypes.h>
48
#include <avr/io.h>
49
#include <avr/interrupt.h>
50
#include <avr/pgmspace.h>
51
#include <avr/eeprom.h>
52
#include <util/delay.h>
53
#include "main.h"
54
 
55
#if defined HWVERSION1_2W || defined HWVERSION1_2
56
 
57
#include "usart.h"
58
#include "uart1.h"
59
#include "lcd.h"
60
#include "display.h"
61
#include "timer.h"
62
#include "eeprom.h"
63
#include "Wi232.h"
64
#include "twimaster.h"
65
 
66
 
67
 
68
 
69
 
70
 
71
void InitHWPorts(void)  /* Initialisierung der Hardware für die jeweilige Leiterplattenversion */
72
 
73
{
74
 
75
        // enable pull ups for the 4 keys
76
        PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7);
77
 
78
        DDRC |= (1<<DDC0)|(1<<DDC1)|(1<<DDC6)|(1<<DDC5)|(1<<DDC7);
79
        DDRD |= (1<<DDD7);
80
        DDRB = 0xFF;
81
 
82
        set_LED1();
83
 
84
        set_D_LIGHT();
85
        Timer0_Init ();
86
        Timer1_Init (); // pwm
87
        Timer2_Init (); // Displaybeleuchtung
88
        LCD_Init (0);
89
        BeepTime = 500;
90
        BeepMuster = 0x0080;
91
 
92
//      _delay_ms(250);
93
 
94
        clr_LED1();
95
        Display_on = 1;
96
        USART_Init (UART_BAUD_SELECT(USART_BAUD,F_CPU));
97
 
98
//      I2C_Init(1);
99
        sei ();
100
 
101
        ReadParameter ();
102
        LCD_Init (1);
103
        OCR2A =LCD_Helligkeit*2.55;
104
#ifdef HWVERSION1_2W
105
        if (WiIsSet==false)
106
                InitWi232(); /* wenn Wi232 nicht initialisiert ist, dann jetzt tun*/
107
        else
108
        {
109
                discoverWi232();                /* Wi232 suchen*/
110
                _delay_ms(1000);
111
        }
112
#endif
113
}
114
 
115
void set_D_LIGHT(void)  /* Displaybeleuchtung ein*/
116
        {
117
                PORTC &= ~(1<<PORTC0);
118
                PORTC &= ~(1<<PORTC1);
119
                PORTD &= ~(1<<PORTD7);
120
        }
121
 
122
void clr_D_LIGHT(void)  /* Displaybeleuchtung aus*/
123
        {
124
                PORTC |= (1<<PORTC0);
125
                PORTC |= (1<<PORTC1);
126
                PORTD |= (1<<PORTD7);
127
        }
128
 
129
 
130
 
131
#endif
132
#endif /* HAL_HW3_2_C_ */