FreeCalypso > hg > fc-magnetite
comparison src/cs/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c @ 131:384fbd61c252
src/cs/drivers/drv_app/r2d/lcds/c139: import from tcs211-c139
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 07 Oct 2016 22:04:02 +0000 |
parents | |
children | e56e74e8b730 |
comparison
equal
deleted
inserted
replaced
130:a0c5d28798fe | 131:384fbd61c252 |
---|---|
1 #include "r2d/lcds/c139/colors.h" | |
2 | |
3 void c139_uwire_xmit(UINT16 cmd) | |
4 { | |
5 * (volatile UINT16 *) TDR = cmd << 7; | |
6 * (volatile UINT16 *) CSR |= NB_BITS_WR_9 + CS_CMD + START ; // transmit command data | |
7 while (((* (volatile UINT16 *) CSR) & CSRB) != 0 ); // wait for end of WRITE | |
8 * (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select | |
9 } | |
10 | |
11 void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param) | |
12 { | |
13 c139_uwire_xmit(cmd); | |
14 c139_uwire_xmit(param | 0x100); | |
15 } | |
16 | |
17 void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend, | |
18 UINT8 ystart, UINT8 yend) | |
19 { | |
20 c139_lcd_ctrl_cmd(0x10, xstart); | |
21 c139_lcd_ctrl_cmd(0x11, ystart); | |
22 c139_lcd_ctrl_cmd(0x12, xend); | |
23 c139_lcd_ctrl_cmd(0x13, yend); | |
24 c139_lcd_ctrl_cmd(0x14, xstart); | |
25 c139_lcd_ctrl_cmd(0x15, ystart); | |
26 } | |
27 | |
28 void c139_lcd_send_pix(UINT16 pixval) | |
29 { | |
30 c139_uwire_xmit((pixval >> 8) | 0x100); | |
31 c139_uwire_xmit((pixval & 0xFF) | 0x100); | |
32 } | |
33 | |
34 void r2d_lcd_power_on(void) | |
35 { | |
36 } | |
37 | |
38 void r2d_lcd_power_off(void) | |
39 { | |
40 } | |
41 | |
42 static int get_pix_from_sw_fb(UINT32 *fb, UINT16 x, UINT16 y) | |
43 { | |
44 UINT32 *p, mask; | |
45 UINT16 yword, ybit; | |
46 | |
47 /* mirroring */ | |
48 x = R2D_WIDTH - x; | |
49 y = R2D_HEIGHT - y; | |
50 yword = y >> 5; | |
51 ybit = y & 31; | |
52 p = fb + x * R2D_MWHEIGHT + yword; | |
53 mask = 1 << ybit; | |
54 if (*p & mask) | |
55 return(1); | |
56 else | |
57 return(0); | |
58 } | |
59 | |
60 void r2d_refresh(void) | |
61 { | |
62 UINT16 x, y; | |
63 UINT32 *fb; | |
64 | |
65 fb = r2d_g_framebuffer->p_memory_words; | |
66 | |
67 /* set the LCD up to refresh the 84x48 area */ | |
68 c139_set_lcd_addr_region(6, 89, 8, 55); | |
69 /* send the pixels */ | |
70 for (y = 0; y < R2D_HEIGHT; y++) { | |
71 for (x = 0; x < R2D_WIDTH; x++) { | |
72 if (get_pix_from_sw_fb(fb, x, y)) | |
73 c139_lcd_send_pix(LCD16_COLOR_BLACK); | |
74 else | |
75 c139_lcd_send_pix(LCD16_COLOR_WHITE); | |
76 } | |
77 } | |
78 | |
79 r2d_reinit_update_region(); | |
80 } |