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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
ChibiOS/RT - Copyright (C) 2012
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX 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.
ChibiOS/GFX 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/>.
*/
#ifndef ILI9320_H
#define ILI9320_H
#if defined(GDISP_USE_GPIO)
#error "ILI9320: GPIO interface not implemented yet"
#elif defined(GDISP_USE_SPI)
#error "ILI9320: GDISP_USE_SPI not implemented yet"
#elif defined(GDISP_USE_FSMC)
#define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */
#define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* RS = 1 */
static __inline void lld_lcdWriteIndex(uint16_t index) {
GDISP_REG = index;
}
static __inline void lld_lcdWriteData(uint16_t data) {
GDISP_RAM = data;
}
static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) {
GDISP_REG = lcdReg;
GDISP_RAM = lcdRegValue;
}
static __inline uint16_t lld_lcdReadData(void) {
return (GDISP_RAM);
}
static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) {
volatile uint16_t dummy;
GDISP_REG = lcdReg;
dummy = GDISP_RAM;
(void)dummy;
return (GDISP_RAM);
}
static __inline void lld_lcdWriteStreamStart(void) {
GDISP_REG = 0x0022;
}
static __inline void lld_lcdWriteStreamStop(void) {
}
static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
uint16_t i;
for(i = 0; i < size; i++)
GDISP_RAM = buffer[i];
}
static __inline void lld_lcdReadStreamStart(void) {
GDISP_REG = 0x0022;
}
static __inline void lld_lcdReadStreamStop(void) {
}
static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
uint16_t i;
volatile uint16_t dummy;
dummy = GDISP_RAM; /* throw away first value read */
(void)dummy;
for(i = 0; i < size; i++)
buffer[i] = GDISP_RAM;
}
#endif
static __inline void lld_lcdDelay(uint16_t us) {
chThdSleepMicroseconds(us);
}
static void lld_lcdSetCursor(uint16_t x, uint16_t y) {
uint32_t addr;
addr = y * 0x100 + x;
switch(GDISP.Orientation) {
case GDISP_ROTATE_0:
lld_lcdWriteReg(0x0020, addr & 0xff); /* low addr */
lld_lcdWriteReg(0x0021, (addr >> 8) & 0x1ff); /* high addr */
//GDISP_REG = 0x0022; /* data reg in IR */
case GDISP_ROTATE_90:
break;
case GDISP_ROTATE_180:
break;
case GDISP_ROTATE_270:
break;
}
}
static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) {
switch(GDISP.Orientation) {
case GDISP_ROTATE_0:
lld_lcdWriteReg(0x0050, x - 1);
lld_lcdWriteReg(0x0051, x + cx - 2);
lld_lcdWriteReg(0x0052, y - 1);
lld_lcdWriteReg(0x0053, y + cy - 2);
break;
case GDISP_ROTATE_90:
break;
case GDISP_ROTATE_180:
break;
case GDISP_ROTATE_270:
break;
}
lld_lcdSetCursor(x, y);
}
static __inline void lld_lcdResetViewPort(void) {
/* ToDo */
}
#endif /* ILI9320_H */
|