diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c | 452 | ||||
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/lcd-fuzev1.c | 88 |
2 files changed, 88 insertions, 452 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c deleted file mode 100644 index 54d4d73183..0000000000 --- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c +++ /dev/null | |||
@@ -1,452 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Dave Chapman | ||
11 | * | ||
12 | * LCD driver for the Sansa Fuze - controller unknown | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | #include "config.h" | ||
24 | |||
25 | #include "cpu.h" | ||
26 | #include "lcd.h" | ||
27 | #include "file.h" | ||
28 | #include "debug.h" | ||
29 | #include "system.h" | ||
30 | #include "clock-target.h" | ||
31 | #include "dbop-as3525.h" | ||
32 | |||
33 | /* The controller is unknown, but some registers appear to be the same as the | ||
34 | HD66789R */ | ||
35 | static bool display_on = false; /* is the display turned on? */ | ||
36 | |||
37 | /* register defines */ | ||
38 | #define R_START_OSC 0x00 | ||
39 | #define R_DRV_OUTPUT_CONTROL 0x01 | ||
40 | #define R_DRV_WAVEFORM_CONTROL 0x02 | ||
41 | #define R_ENTRY_MODE 0x03 | ||
42 | #define R_COMPARE_REG1 0x04 | ||
43 | #define R_COMPARE_REG2 0x05 | ||
44 | |||
45 | #define R_DISP_CONTROL1 0x07 | ||
46 | #define R_DISP_CONTROL2 0x08 | ||
47 | #define R_DISP_CONTROL3 0x09 | ||
48 | |||
49 | #define R_FRAME_CYCLE_CONTROL 0x0b | ||
50 | #define R_EXT_DISP_IF_CONTROL 0x0c | ||
51 | |||
52 | #define R_POWER_CONTROL1 0x10 | ||
53 | #define R_POWER_CONTROL2 0x11 | ||
54 | #define R_POWER_CONTROL3 0x12 | ||
55 | #define R_POWER_CONTROL4 0x13 | ||
56 | |||
57 | #define R_RAM_ADDR_SET 0x21 | ||
58 | #define R_WRITE_DATA_2_GRAM 0x22 | ||
59 | |||
60 | #define R_GAMMA_FINE_ADJ_POS1 0x30 | ||
61 | #define R_GAMMA_FINE_ADJ_POS2 0x31 | ||
62 | #define R_GAMMA_FINE_ADJ_POS3 0x32 | ||
63 | #define R_GAMMA_GRAD_ADJ_POS 0x33 | ||
64 | |||
65 | #define R_GAMMA_FINE_ADJ_NEG1 0x34 | ||
66 | #define R_GAMMA_FINE_ADJ_NEG2 0x35 | ||
67 | #define R_GAMMA_FINE_ADJ_NEG3 0x36 | ||
68 | #define R_GAMMA_GRAD_ADJ_NEG 0x37 | ||
69 | |||
70 | #define R_GAMMA_AMP_ADJ_RES_POS 0x38 | ||
71 | #define R_GAMMA_AMP_AVG_ADJ_RES_NEG 0x39 | ||
72 | |||
73 | #define R_GATE_SCAN_POS 0x40 | ||
74 | #define R_VERT_SCROLL_CONTROL 0x41 | ||
75 | #define R_1ST_SCR_DRV_POS 0x42 | ||
76 | #define R_2ND_SCR_DRV_POS 0x43 | ||
77 | #define R_HORIZ_RAM_ADDR_POS 0x44 | ||
78 | #define R_VERT_RAM_ADDR_POS 0x45 | ||
79 | |||
80 | /* Flip Flag */ | ||
81 | #define R_ENTRY_MODE_HORZ_NORMAL 0x7030 | ||
82 | #define R_ENTRY_MODE_HORZ_FLIPPED 0x7000 | ||
83 | static unsigned short r_entry_mode = R_ENTRY_MODE_HORZ_NORMAL; | ||
84 | #define R_ENTRY_MODE_VERT 0x7038 | ||
85 | #define R_ENTRY_MODE_SOLID_VERT 0x1038 | ||
86 | /* FIXME */ | ||
87 | #define R_ENTRY_MODE_VIDEO_NORMAL 0x7038 | ||
88 | #define R_ENTRY_MODE_VIDEO_FLIPPED 0x7018 | ||
89 | |||
90 | /* Reverse Flag */ | ||
91 | #define R_DISP_CONTROL_NORMAL 0x0004 | ||
92 | #define R_DISP_CONTROL_REV 0x0000 | ||
93 | static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL; | ||
94 | |||
95 | static const int xoffset = 20; | ||
96 | |||
97 | static inline void lcd_delay(int x) | ||
98 | { | ||
99 | do { | ||
100 | asm volatile ("nop\n"); | ||
101 | } while (x--); | ||
102 | } | ||
103 | |||
104 | static void as3525_dbop_init(void) | ||
105 | { | ||
106 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | ||
107 | |||
108 | DBOP_TIMPOL_01 = 0xe167e167; | ||
109 | DBOP_TIMPOL_23 = 0xe167006e; | ||
110 | |||
111 | /* short count: 16 | output data width: 16 | readstrobe line */ | ||
112 | DBOP_CTRL = (1<<18|1<<12|1<<3); | ||
113 | |||
114 | GPIOB_AFSEL = 0xfc; | ||
115 | GPIOC_AFSEL = 0xff; | ||
116 | |||
117 | DBOP_TIMPOL_23 = 0x6000e; | ||
118 | |||
119 | /* short count: 16|enable write|output data width: 16|read strobe line */ | ||
120 | DBOP_CTRL = (1<<18|1<<16|1<<12|1<<3); | ||
121 | DBOP_TIMPOL_01 = 0x6e167; | ||
122 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
123 | |||
124 | /* TODO: The OF calls some other functions here, but maybe not important */ | ||
125 | } | ||
126 | |||
127 | static void lcd_write_cmd(short cmd) | ||
128 | { | ||
129 | /* Write register */ | ||
130 | DBOP_TIMPOL_23 = 0xa167006e; | ||
131 | dbop_write_data(&cmd, 1); | ||
132 | |||
133 | lcd_delay(4); | ||
134 | |||
135 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
136 | } | ||
137 | |||
138 | static void lcd_write_reg(int reg, int value) | ||
139 | { | ||
140 | int16_t data = value; | ||
141 | |||
142 | lcd_write_cmd(reg); | ||
143 | dbop_write_data(&data, 1); | ||
144 | } | ||
145 | |||
146 | /*** hardware configuration ***/ | ||
147 | |||
148 | void lcd_set_contrast(int val) | ||
149 | { | ||
150 | (void)val; | ||
151 | } | ||
152 | |||
153 | void lcd_set_invert_display(bool yesno) | ||
154 | { | ||
155 | r_disp_control_rev = yesno ? R_DISP_CONTROL_REV : | ||
156 | R_DISP_CONTROL_NORMAL; | ||
157 | |||
158 | if (display_on) | ||
159 | { | ||
160 | lcd_write_reg(R_DISP_CONTROL1, 0x0013 | r_disp_control_rev); | ||
161 | } | ||
162 | |||
163 | } | ||
164 | |||
165 | #ifdef HAVE_LCD_FLIP | ||
166 | static bool display_flipped = false; | ||
167 | |||
168 | /* turn the display upside down */ | ||
169 | void lcd_set_flip(bool yesno) | ||
170 | { | ||
171 | display_flipped = yesno; | ||
172 | |||
173 | r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED : | ||
174 | R_ENTRY_MODE_HORZ_NORMAL; | ||
175 | } | ||
176 | #endif | ||
177 | |||
178 | static void _display_on(void) | ||
179 | { | ||
180 | /* Initialise in the same way as the original firmare */ | ||
181 | |||
182 | lcd_write_reg(R_DISP_CONTROL1, 0); | ||
183 | lcd_write_reg(R_POWER_CONTROL4, 0); | ||
184 | |||
185 | lcd_write_reg(R_POWER_CONTROL2, 0x3704); | ||
186 | lcd_write_reg(0x14, 0x1a1b); | ||
187 | lcd_write_reg(R_POWER_CONTROL1, 0x3860); | ||
188 | lcd_write_reg(R_POWER_CONTROL4, 0x40); | ||
189 | |||
190 | lcd_write_reg(R_POWER_CONTROL4, 0x60); | ||
191 | |||
192 | lcd_write_reg(R_POWER_CONTROL4, 0x70); | ||
193 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, 277); | ||
194 | lcd_write_reg(R_DRV_WAVEFORM_CONTROL, (7<<8)); | ||
195 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
196 | lcd_write_reg(R_DISP_CONTROL2, 0x01); | ||
197 | lcd_write_reg(R_FRAME_CYCLE_CONTROL, (1<<10)); | ||
198 | lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0); | ||
199 | |||
200 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x40); | ||
201 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0687); | ||
202 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0306); | ||
203 | lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x104); | ||
204 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0585); | ||
205 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 255+66); | ||
206 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0687+128); | ||
207 | lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 259); | ||
208 | lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0); | ||
209 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0); | ||
210 | |||
211 | lcd_write_reg(R_1ST_SCR_DRV_POS, (LCD_WIDTH - 1)); | ||
212 | lcd_write_reg(R_2ND_SCR_DRV_POS, 0); | ||
213 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH - 1)); | ||
214 | lcd_write_reg(R_VERT_RAM_ADDR_POS, 0); | ||
215 | lcd_write_reg(0x46, (((LCD_WIDTH - 1) + xoffset) << 8) | xoffset); | ||
216 | lcd_write_reg(0x47, (LCD_HEIGHT - 1)); | ||
217 | lcd_write_reg(0x48, 0x0); | ||
218 | |||
219 | lcd_write_reg(R_DISP_CONTROL1, 0x11); | ||
220 | lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev); | ||
221 | |||
222 | display_on = true; /* must be done before calling lcd_update() */ | ||
223 | lcd_update(); | ||
224 | } | ||
225 | |||
226 | void lcd_init_device(void) | ||
227 | { | ||
228 | as3525_dbop_init(); | ||
229 | |||
230 | GPIOA_DIR |= (1<<5|1<<4|1<<3); | ||
231 | GPIOA_PIN(5) = 0; | ||
232 | GPIOA_PIN(3) = (1<<3); | ||
233 | GPIOA_PIN(4) = 0; | ||
234 | GPIOA_PIN(5) = (1<<5); | ||
235 | |||
236 | _display_on(); | ||
237 | } | ||
238 | |||
239 | #if defined(HAVE_LCD_ENABLE) | ||
240 | void lcd_enable(bool on) | ||
241 | { | ||
242 | if (display_on == on) | ||
243 | return; | ||
244 | |||
245 | if(on) | ||
246 | { | ||
247 | lcd_write_reg(R_START_OSC, 1); | ||
248 | lcd_write_reg(R_POWER_CONTROL1, 0); | ||
249 | lcd_write_reg(R_POWER_CONTROL2, 0x3704); | ||
250 | lcd_write_reg(0x14, 0x1a1b); | ||
251 | lcd_write_reg(R_POWER_CONTROL1, 0x3860); | ||
252 | lcd_write_reg(R_POWER_CONTROL4, 0x40); | ||
253 | lcd_write_reg(R_POWER_CONTROL4, 0x60); | ||
254 | lcd_write_reg(R_POWER_CONTROL4, 112); | ||
255 | lcd_write_reg(R_DISP_CONTROL1, 0x11); | ||
256 | lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev); | ||
257 | display_on = true; | ||
258 | lcd_update(); /* Resync display */ | ||
259 | send_event(LCD_EVENT_ACTIVATION, NULL); | ||
260 | sleep(0); | ||
261 | |||
262 | } | ||
263 | else | ||
264 | { | ||
265 | lcd_write_reg(R_DISP_CONTROL1, 0x22); | ||
266 | lcd_write_reg(R_DISP_CONTROL1, 0); | ||
267 | lcd_write_reg(R_POWER_CONTROL1, 1); | ||
268 | display_on = false; | ||
269 | } | ||
270 | } | ||
271 | #endif | ||
272 | |||
273 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
274 | bool lcd_active(void) | ||
275 | { | ||
276 | return display_on; | ||
277 | } | ||
278 | #endif | ||
279 | |||
280 | /*** update functions ***/ | ||
281 | |||
282 | /* FIXME : find the datasheet for this RENESAS controller so we identify the | ||
283 | * registers used in windowing code (not present in HD66789R) */ | ||
284 | |||
285 | /* Set horizontal window addresses */ | ||
286 | static void lcd_window_x(int xmin, int xmax) | ||
287 | { | ||
288 | xmin += xoffset; | ||
289 | xmax += xoffset; | ||
290 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS + 2, (xmax << 8) | xmin); | ||
291 | lcd_write_reg(R_RAM_ADDR_SET - 1, xmin); | ||
292 | } | ||
293 | |||
294 | /* Set vertical window addresses */ | ||
295 | static void lcd_window_y(int ymin, int ymax) | ||
296 | { | ||
297 | lcd_write_reg(R_VERT_RAM_ADDR_POS + 2, ymax); | ||
298 | lcd_write_reg(R_VERT_RAM_ADDR_POS + 3, ymin); | ||
299 | lcd_write_reg(R_RAM_ADDR_SET, ymin); | ||
300 | } | ||
301 | |||
302 | static unsigned lcd_yuv_options = 0; | ||
303 | |||
304 | void lcd_yuv_set_options(unsigned options) | ||
305 | { | ||
306 | lcd_yuv_options = options; | ||
307 | } | ||
308 | |||
309 | |||
310 | #ifndef BOOTLOADER | ||
311 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
312 | extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
313 | int width, | ||
314 | int stride); | ||
315 | extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
316 | int width, | ||
317 | int stride, | ||
318 | int x_screen, /* To align dither pattern */ | ||
319 | int y_screen); | ||
320 | |||
321 | /* Performance function to blit a YUV bitmap directly to the LCD | ||
322 | * src_x, src_y, width and height should be even | ||
323 | * x, y, width and height have to be within LCD bounds | ||
324 | */ | ||
325 | void lcd_blit_yuv(unsigned char * const src[3], | ||
326 | int src_x, int src_y, int stride, | ||
327 | int x, int y, int width, int height) | ||
328 | { | ||
329 | unsigned char const * yuv_src[3]; | ||
330 | off_t z; | ||
331 | |||
332 | /* Sorry, but width and height must be >= 2 or else */ | ||
333 | width &= ~1; | ||
334 | height >>= 1; | ||
335 | |||
336 | z = stride*src_y; | ||
337 | yuv_src[0] = src[0] + z + src_x; | ||
338 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
339 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
340 | |||
341 | #ifdef HAVE_LCD_FLIP | ||
342 | lcd_write_reg(R_ENTRY_MODE, | ||
343 | display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL | ||
344 | ); | ||
345 | #else | ||
346 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VIDEO_NORMAL); | ||
347 | #endif | ||
348 | |||
349 | lcd_window_x(x, x + width - 1); | ||
350 | |||
351 | if (lcd_yuv_options & LCD_YUV_DITHER) | ||
352 | { | ||
353 | do | ||
354 | { | ||
355 | lcd_window_y(y, y + 1); | ||
356 | |||
357 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
358 | |||
359 | lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y); | ||
360 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
361 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
362 | yuv_src[2] += stride >> 1; | ||
363 | y += 2; | ||
364 | } | ||
365 | while (--height > 0); | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | do | ||
370 | { | ||
371 | lcd_window_y(y, y + 1); | ||
372 | |||
373 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
374 | |||
375 | lcd_write_yuv420_lines(yuv_src, width, stride); | ||
376 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
377 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
378 | yuv_src[2] += stride >> 1; | ||
379 | y += 2; | ||
380 | } | ||
381 | while (--height > 0); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | #endif | ||
386 | |||
387 | |||
388 | /* Update the display. | ||
389 | This must be called after all other LCD functions that change the display. */ | ||
390 | void lcd_update(void) | ||
391 | { | ||
392 | if (!display_on) | ||
393 | return; | ||
394 | |||
395 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
396 | |||
397 | lcd_window_x(0, LCD_WIDTH - 1); | ||
398 | lcd_window_y(0, LCD_HEIGHT - 1); | ||
399 | |||
400 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
401 | |||
402 | dbop_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | ||
403 | } | ||
404 | |||
405 | /* Update a fraction of the display. */ | ||
406 | void lcd_update_rect(int x, int y, int width, int height) | ||
407 | { | ||
408 | const fb_data *ptr; | ||
409 | |||
410 | if (!display_on) | ||
411 | return; | ||
412 | |||
413 | /* nothing to draw? */ | ||
414 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || | ||
415 | (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) | ||
416 | return; | ||
417 | |||
418 | if (x < 0) | ||
419 | { /* clip left */ | ||
420 | width += x; | ||
421 | x = 0; | ||
422 | } | ||
423 | if (y < 0) | ||
424 | { /* clip top */ | ||
425 | height += y; | ||
426 | y = 0; | ||
427 | } | ||
428 | if (x + width > LCD_WIDTH) | ||
429 | width = LCD_WIDTH - x; /* clip right */ | ||
430 | if (y + height > LCD_HEIGHT) | ||
431 | height = LCD_HEIGHT - y; /* clip bottom */ | ||
432 | |||
433 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | ||
434 | |||
435 | /* we need to make x and width even to enable 32bit transfers */ | ||
436 | width = (width + (x & 1) + 1) & ~1; | ||
437 | x &= ~1; | ||
438 | |||
439 | lcd_window_x(x, x + width - 1); | ||
440 | lcd_window_y(y, y + height -1); | ||
441 | |||
442 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
443 | |||
444 | ptr = &lcd_framebuffer[y][x]; | ||
445 | |||
446 | do | ||
447 | { | ||
448 | dbop_write_data(ptr, width); | ||
449 | ptr += LCD_WIDTH; | ||
450 | } | ||
451 | while (--height > 0); | ||
452 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuzev1.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuzev1.c new file mode 100644 index 0000000000..0c56ee3070 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuzev1.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Dave Chapman | ||
11 | * | ||
12 | * LCD driver for the Sansa Fuze - controller unknown | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | #include "config.h" | ||
24 | |||
25 | #include "cpu.h" | ||
26 | #include "lcd.h" | ||
27 | #include "system.h" | ||
28 | #include "clock-target.h" | ||
29 | #include "dbop-as3525.h" | ||
30 | #include "lcd-fuze.h" | ||
31 | |||
32 | void lcd_write_cmd(int16_t cmd) | ||
33 | { | ||
34 | /* Write register */ | ||
35 | DBOP_TIMPOL_23 = 0xa167006e; | ||
36 | dbop_write_data(&cmd, 1); | ||
37 | |||
38 | int delay = 4; | ||
39 | do { | ||
40 | nop; | ||
41 | } while(delay--); | ||
42 | |||
43 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
44 | } | ||
45 | |||
46 | void lcd_write_reg(int reg, int value) | ||
47 | { | ||
48 | int16_t data = value; | ||
49 | |||
50 | lcd_write_cmd(reg); | ||
51 | dbop_write_data(&data, 1); | ||
52 | } | ||
53 | |||
54 | |||
55 | static void as3525_dbop_init(void) | ||
56 | { | ||
57 | CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; | ||
58 | |||
59 | DBOP_TIMPOL_01 = 0xe167e167; | ||
60 | DBOP_TIMPOL_23 = 0xe167006e; | ||
61 | |||
62 | /* short count: 16 | output data width: 16 | readstrobe line */ | ||
63 | DBOP_CTRL = (1<<18|1<<12|1<<3); | ||
64 | |||
65 | GPIOB_AFSEL = 0xfc; | ||
66 | GPIOC_AFSEL = 0xff; | ||
67 | |||
68 | DBOP_TIMPOL_23 = 0x6000e; | ||
69 | |||
70 | /* short count: 16|enable write|output data width: 16|read strobe line */ | ||
71 | DBOP_CTRL = (1<<18|1<<16|1<<12|1<<3); | ||
72 | DBOP_TIMPOL_01 = 0x6e167; | ||
73 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
74 | } | ||
75 | |||
76 | |||
77 | void lcd_init_device(void) | ||
78 | { | ||
79 | as3525_dbop_init(); | ||
80 | |||
81 | GPIOA_DIR |= (1<<5|1<<4|1<<3); | ||
82 | GPIOA_PIN(5) = 0; | ||
83 | GPIOA_PIN(3) = (1<<3); | ||
84 | GPIOA_PIN(4) = 0; | ||
85 | GPIOA_PIN(5) = (1<<5); | ||
86 | |||
87 | fuze_display_on(); | ||
88 | } | ||