-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElevatorInit.h
78 lines (65 loc) · 1.72 KB
/
ElevatorInit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "CommonHeader.h"
#include "Speaker.h"
#include "lcd.h"
#include "SevenSegment.h"
#include "DotMatrix.h"
#include "LED.h"
#include "SteppingMotor.h"
typedef enum {false, true} bool;
//////////////////////////////////////////// interface //////////////////////////////////////////////
// private function
static void port_init(void);
static void init_devices(void);
// public function
extern void Init(void);
//////////////////////////////////////////// --------- //////////////////////////////////////////////
static void port_init(void) {
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00; // Dependency: KeySwitch
PORTC = 0x00;
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0xFF;
PORTE = 0x00;
DDRE = 0x00;
PORTF = 0x00;
DDRF= 0x00;
PORTG = 0x00;
DDRG = 0x10; // Dependency: Speaker
}
static void init_devices(void){
cli();
XDIV = 0x00;
XMCRA = 0x00;
port_init();
timer1_init(); // Dependency: Speaker
// TCCR0 = 0x07; // TIMER0 Prescaler 1024
// TCNT0 = 0x00; // TIMER0
// TCCR2 = 0x07; // TIMER2 Prescaler 1024
// TCNT2 = 0x00; // TIMER2
MCUCR = 0x80; // Dependency: DotMatrix, SevenSegment
EICRA = 0x00;
EICRB = 0x00;
EIMSK = 0x00;
TIMSK = 0x14; // Dependency: Speaker // TOIE2(TIMER2)
// TIMSK = 0x15; // Dependency: Speaker // TOIE0(TIMER0) // TOIE2(TIMER2)
ETIMSK = 0X00;
sei();
}
static void init_training_kit(void){ // zeroing whatever that lights
EX_SS_DATA = 0; // Dependency: SevenSegment
EX_SS_SEL = 0; // Dependency: SevenSegment
EX_DM_DATA = 0; // Dependency: DotMatrix
EX_DM_SEL = 0; // Dependency: DotMatrix
EX_LED = 0; // Dependency: LED
}
extern void Init(void){
init_devices();
init_training_kit();
lcdInit(); // Dependency: LCD
_delay_ms(1000);
lcdClear(); // Dependency: LCD
_delay_ms(1000);
}