-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.h
executable file
·85 lines (73 loc) · 2.97 KB
/
defines.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
79
80
81
82
83
84
85
/********************************************************************
Copyright 2010-2017 K.C. Wang, <kwang@eecs.wsu.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/
// defines.h file
// timer register offsets from base address
/**** byte offsets *******
#define TLOAD 0x00
#define TVALUE 0x04
#define TCNTL 0x08
#define TINTCLR 0x0C
#define TRIS 0x10
#define TMIS 0x14
#define TBGLOAD 0x18
*************************/
/** u32 * offsets *****/
#define TLOAD 0x0
#define TVALUE 0x1
#define TCNTL 0x2
#define TINTCLR 0x3
#define TRIS 0x4
#define TMIS 0x5
#define TBGLOAD 0x6
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#define UART0_BASE_ADDR 0x101f1000
#define UART0_DR (*((volatile u32 *)(UART0_BASE_ADDR + 0x000)))
#define UART0_FR (*((volatile u32 *)(UART0_BASE_ADDR + 0x018)))
#define UART0_IMSC (*((volatile u32 *)(UART0_BASE_ADDR + 0x038)))
#define UART1_BASE_ADDR 0x101f2000
#define UART1_DR (*((volatile u32 *)(UART1_BASE_ADDR + 0x000)))
#define UART1_FR (*((volatile u32 *)(UART1_BASE_ADDR + 0x018)))
#define UART1_IMSC (*((volatile u32 *)(UART1_BASE_ADDR + 0x038)))
#define KBD_BASE_ADDR 0x10006000
#define KBD_CR (*((volatile u32 *)(KBD_BASE_ADDR + 0x000)))
#define KBD_DR (*((volatile u32 *)(KBD_BASE_ADDR + 0x008)))
#define TIMER0_BASE_ADDR 0x101E2000
#define TIMER0_LR (*((volatile u32 *)(UART0_BASE_ADDR + 0x000)))
#define TIMER0_BR (*((volatile u32 *)(UART0_BASE_ADDR + 0x032)))
#define VIC_BASE_ADDR 0x10140000
#define VIC_STATUS (*((volatile u32 *)(VIC_BASE_ADDR + 0x000)))
#define VIC_INTENABLE (*((volatile u32 *)(VIC_BASE_ADDR + 0x010)))
#define VIC_VADDR (*((volatile u32 *)(VIC_BASE_ADDR + 0x030)))
#define SIC_BASE_ADDR 0x10003000
#define SIC_STATUS (*((volatile u32 *)(SIC_BASE_ADDR + 0x000)))
#define SIC_INTENABLE (*((volatile u32 *)(SIC_BASE_ADDR + 0x008)))
#define SIC_ENSET (*((volatile u32 *)(SIC_BASE_ADDR + 0x008)))
#define SIC_PICENSET (*((volatile u32 *)(SIC_BASE_ADDR + 0x020)))
#define LINES 4
#define N_SCAN 64
#define BLUE 0
#define GREEN 1
#define RED 2
#define WHITE 3
#define CYAN 4
#define YELLOW 5
typedef volatile struct timer{
u32 *base; // timer's base address; as u32 pointer
int tick, hh, mm, ss; // per timer data area
char clock[16];
}TIMER;
extern volatile TIMER timer[4]; // 4 timers; 2 timers per unit; at 0x00 and 0x20
extern TIMER *tp[4];