summaryrefslogtreecommitdiff
path: root/firmware/lcd.h
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-04-18 17:42:42 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-04-18 17:42:42 +0000
commit965401aa6b1b496cf792cb13f682bb0aafa34752 (patch)
treec0937d6c61f2e3d75fd0ccadd1b9d62b8e15a04b /firmware/lcd.h
parent82bca1bc8959b6178903b00c95a85a5e5c5bbcc5 (diff)
downloadrockbox-965401aa6b1b496cf792cb13f682bb0aafa34752.tar.gz
rockbox-965401aa6b1b496cf792cb13f682bb0aafa34752.zip
Moved all code to .c file and indented according to rules
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@134 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/lcd.h')
-rw-r--r--firmware/lcd.h165
1 files changed, 4 insertions, 161 deletions
diff --git a/firmware/lcd.h b/firmware/lcd.h
index cd65925e61..6b0d861f76 100644
--- a/firmware/lcd.h
+++ b/firmware/lcd.h
@@ -21,8 +21,8 @@
21#define __LCD_H__ 21#define __LCD_H__
22 22
23#include "sh7034.h" 23#include "sh7034.h"
24#include "system.h"
25#include "types.h" 24#include "types.h"
25#include "config.h"
26 26
27#define LCDR (PBDR+1) 27#define LCDR (PBDR+1)
28 28
@@ -137,149 +137,6 @@ void lcd_invertrect (int x, int y, int nx, int ny);
137 137
138 138
139#ifndef SIMULATOR 139#ifndef SIMULATOR
140/*
141 * About /CS,DS,SC,SD
142 * ------------------
143 *
144 * LCD on JBP and JBR uses a SPI protocol to receive orders (SDA and SCK lines)
145 *
146 * - /CS -> Chip Selection line :
147 * 0 : LCD chipset is activated.
148 * - DS -> Data Selection line, latched at the rising edge
149 * of the 8th serial clock (*) :
150 * 0 : instruction register,
151 * 1 : data register;
152 * - SC -> Serial Clock line (SDA).
153 * - SD -> Serial Data line (SCK), latched at the rising edge
154 * of each serial clock (*).
155 *
156 * _ _
157 * /CS \ /
158 * \______________________________________________________/
159 * _____ ____ ____ ____ ____ ____ ____ ____ ____ _____
160 * SD \/ D7 \/ D6 \/ D5 \/ D4 \/ D3 \/ D2 \/ D1 \/ D0 \/
161 * _____/\____/\____/\____/\____/\____/\____/\____/\____/\_____
162 *
163 * _____ _ _ _ _ _ _ _ ________
164 * SC \ * \ * \ * \ * \ * \ * \ * \ *
165 * \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
166 * _ _________________________________________________________
167 * DS \/
168 * _/\_________________________________________________________
169 *
170 */
171
172/*
173 * The only way to do logical operations in an atomic way
174 * on SH1 is using :
175 *
176 * or.b/and.b/tst.b/xor.b #imm,@(r0,gbr)
177 *
178 * but GCC doesn't generate them at all so some assembly
179 * codes are needed here.
180 *
181 * The Global Base Register gbr is expected to be zero
182 * and r0 is the address of one register in the on-chip
183 * peripheral module.
184 *
185 */
186
187static inline void lcd_start (void)
188 /*
189 * Enter a LCD session :
190 *
191 * QI(LCDR) &= ~(LCD_CS|LCD_DS|LCD_SD|LCD_SC);
192 */
193 {
194 asm
195 ("and.b\t%0,@(r0,gbr)"
196 :
197 : /* %0 */ "I"(~(LCD_CS|LCD_DS|LCD_SD|LCD_SC)),
198 /* %1 */ "z"(LCDR));
199 }
200
201static inline void lcd_stop (void)
202 /*
203 * Leave a LCD session :
204 *
205 * QI(LCDR) |= LCD_CS|LCD_RS|LCD_SD|LCD_SC;
206 */
207 {
208 asm
209 ("or.b\t%0,@(r0,gbr)"
210 :
211 : /* %0 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC),
212 /* %1 */ "z"(LCDR));
213 }
214
215static inline void lcd_byte (int byte,int rs)
216 /*
217 * char j = 0x80;
218 * if (rs)
219 * do
220 * {
221 * QI(LCDR) &= ~(LCD_SC|LCD_SD);
222 * if (j & byte)
223 * QI(LCDR) |= LCD_SD;
224 * QI(LCDR) |= LCD_SC|LCD_DS;
225 * }
226 * while ((unsigned char)j >>= 1);
227 * else
228 * do
229 * {
230 * QI(LCDR) &= ~(LCD_SC|LCD_SD|LCD_DS);
231 * if (j & byte)
232 * QI(LCDR) |= LCD_SD;
233 * QI(LCDR) |= LCD_SC;
234 * }
235 * while ((unsigned char)j >>= 1);
236 */
237 {
238 if (rs > 0)
239 asm
240 ("shll8\t%0\n"
241 "0:\n\t"
242 "and.b\t%2,@(r0,gbr)\n\t"
243 "shll\t%0\n\t"
244 "bf\t1f\n\t"
245 "or.b\t%3,@(r0,gbr)\n"
246 "1:\n\t"
247 "or.b\t%4,@(r0,gbr)\n"
248 "add\t#-1,%1\n\t"
249 "cmp/pl\t%1\n\t"
250 "bt\t0b"
251 :
252 : /* %0 */ "r"(((unsigned)byte)<<16),
253 /* %1 */ "r"(8),
254 /* %2 */ "I"(~(LCD_SC|LCD_SD)),
255 /* %3 */ "I"(LCD_SD),
256 /* %4 */ "I"(LCD_SC|LCD_DS),
257 /* %5 */ "z"(LCDR));
258 else
259 asm
260 ("shll8\t%0\n"
261 "0:\n\t"
262 "and.b\t%2,@(r0,gbr)\n\t"
263 "shll\t%0\n\t"
264 "bf\t1f\n\t"
265 "or.b\t%3,@(r0,gbr)\n"
266 "1:\n\t"
267 "or.b\t%4,@(r0,gbr)\n"
268 "add\t#-1,%1\n\t"
269 "cmp/pl\t%1\n\t"
270 "bt\t0b"
271 :
272 : /* %0 */ "r"(((unsigned)byte)<<16),
273 /* %1 */ "r"(8),
274 /* %2 */ "I"(~(LCD_SC|LCD_DS|LCD_SD)),
275 /* %3 */ "I"(LCD_SD),
276 /* %4 */ "I"(LCD_SC),
277 /* %5 */ "z"(LCDR));
278 }
279#else
280/* make a faked lcd_byte() function when simulating */
281#define lcd_byte(x,y)
282#endif /* SIMULATOR */
283 140
284extern void lcd_data (int data); 141extern void lcd_data (int data);
285extern void lcd_instruction (int instruction); 142extern void lcd_instruction (int instruction);
@@ -296,22 +153,8 @@ extern void lcd_puthex (unsigned int value,int digits);
296 153
297extern void lcd_pattern (int which,char const *pattern,int count); 154extern void lcd_pattern (int which,char const *pattern,int count);
298 155
299static inline void lcd_goto (int x,int y) 156#endif /* HAVE_LCD_CHARCELLS */
300 { lcd_instruction (LCD_CURSOR(x,y)); }
301
302/*** BACKLIGHT ***/
303
304static inline void lcd_toggle_backlight (void)
305 { toggle_bit (LCD_BL,PAIOR); }
306 157
307static inline void lcd_turn_on_backlight (void) 158#endif /* SIMULATOR */
308 { set_bit (LCD_BL,PAIOR); }
309
310static inline void lcd_turn_off_backlight (void)
311 { clear_bit (LCD_BL,PAIOR); }
312
313/*** ICONS ***/
314
315#endif /* HAVE_LCD_CHARCELLS */
316 159
317#endif 160#endif /* __LCD_H__ */