comparison src/cs/drivers/drv_app/r2d/lcds/E_Sample/r2d_task_init_i.c @ 0:b6a5e36de839

src/cs: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:39:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b6a5e36de839
1 /* Used by refresh task to extract bytes from the
2 framebuffer */
3
4 #define __STANDARD_H__ /* Avoid to define UBYTE, SYS_UWORD16 and UINT32. */
5
6 #include "r2d/lcds/e_sample/r2d_task_init_i.h"
7 #include "r2d/lcds/e_sample/r2d_tfd_lcd.h"
8 #include "r2d/r2d_i.h"
9 #include "r2d/r2d_independance_layer.h"
10 #include "r2d/r2d_env.h"
11
12 const unsigned char INIT_DISCTL[DISCTL_PARAM_NBR] = { 0xDE,0x01,0x64,0x00,0x1B,0xF4,0x00,0xDC,0x00,0x02,0x00};
13
14 const unsigned char INIT_GCP64[GCP64_PARAM_NBR] = {
15 0x15,0x00,0x29,0x00,0x3E,0x00,0x51,0x00, 0x65,0x00,0x7A,0x00,0x8D,0x00,0XA1,0x00,
16 0XB6,0x00,0XC7,0x00,0XD8,0x00,0XEB,0x00, 0XFB,0x00,0x0B,0x01,0X1B,0x01,0X27,0x01,
17 0x34,0x01,0x41,0x01,0x4C,0x01,0x55,0x01, 0x5F,0x01,0x68,0x01,0x70,0x01,0x78,0x01,
18 0x7E,0x01,0x86,0x01,0x8C,0x01,0x94,0x01, 0x9B,0x01,0XA1,0x01,0xA4,0x01,0xA9,0x01,
19 0xAD,0x01,0xB2,0x01,0xB7,0x01,0xBC,0x01, 0xC0,0x01,0xC4,0x01,0xC8,0x01,0xCB,0x01,
20 0xCF,0x01,0xD2,0x01,0xD5,0x01,0xD8,0x01, 0xDB,0x01,0xE0,0x01,0xE3,0x01,0xE6,0x01,
21 0xE8,0x01,0xEB,0x01,0xEE,0x01,0xF1,0x01, 0xF3,0x01,0xF8,0x01,0xF9,0x01,0xFC,0x01,
22 0x00,0x02,0x03,0x02,0x07,0x02,0x09,0x02, 0x0E,0x02,0x13,0x02,0x1C,0x02 };
23 const unsigned char INIT_GCP16[GCP16_PARAM_NBR] = {
24 0x1A,0x31,0x48,0x54,0x5F,0x67,0x70,0x76,0x7C,0x80,0x83,0x84,0x85,0x87,0x96 };
25
26 const unsigned char INIT_MD_PSET[MD_PSET_PARAM_NBR] = { 0x00, 0x01, 0x00, 0x01 };
27 const unsigned char INIT_MD_CSET[MD_CSET_PARAM_NBR] = { 0x00, 0x02, 0x00, 0x02 };
28
29 const unsigned char INIT_SD_PSET[SD_PSET_PARAM_NBR] = { 0, 0, 219, 0 };
30 const unsigned char INIT_SD_CSET[SD_CSET_PARAM_NBR] = { 2, 0, 177, 0 };
31
32 const unsigned char INIT_ASCSET[ASCSET_PARAM_NBR] = { 0x00, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0x01 };
33 const unsigned char INIT_SCSTART[SCSTART_PARAM_NBR] = { 0x00, 0x00 };
34
35
36 extern T_RVF_MB_ID r2d_mb_id;
37
38
39 static void r2d_nop_delay(SYS_UWORD32 ms)
40 {
41 unsigned short a;
42 while (ms-- > 0) for (a=0;a<1000;a++) asm(" nop");
43 }
44
45
46
47
48 void r2d_refresh_task_init(void)
49 {
50
51 #ifndef _WINDOWS
52
53 SYS_UWORD32 i,j,k;
54 SYS_UWORD16 command;
55 SYS_UWORD16 data;
56 SYS_UWORD16 tab_tmp[264];
57 SYS_UWORD16 *ptr;
58
59 command = LCD_DISNOR; /* LCD_activate */
60 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
61
62
63 command = LCD_DISOFF; // this command turns ON the full-screen display
64 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
65
66
67 command = LCD_SLPIN; // this command causes the LCD module to enter the sleep mode
68 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
69
70
71 command = LCD_DISNOR; // this command turns the display mode to NORMAL
72 // without rewriting the content of the display data RAM
73 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
74
75 r2d_nop_delay(10);
76
77 command = LCD_DATCTL; // data mode of the MPU interface
78 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
79 r2d_nop_delay(10);
80 data = 0x08;
81 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
82
83 r2d_nop_delay(10);
84
85 command = LCD_GSSET; // this command and the subsequent parameter make the grey scale mode
86 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
87 r2d_nop_delay(10);
88 data = INIT_GSSET; // 64 gradients
89 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
90
91
92 r2d_nop_delay(100);
93
94
95 command = LCD_DISCTL; // this command and the subsequent parameter make various display timing settings
96 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
97
98 ptr = (SYS_UWORD16 *)&INIT_DISCTL[0];
99
100 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 6, C_LCD_IF_DISPLAY);
101
102 r2d_nop_delay(100);
103
104
105 command = LCD_GCP64; // Init palette for 64 gradient palette
106 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
107
108 ptr = (SYS_UWORD16 *)&INIT_GCP64[0];
109 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 63, C_LCD_IF_DISPLAY);
110
111 r2d_nop_delay(100);
112
113 command = LCD_GCP16; // Init palette for 16 gradient palette
114 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
115
116 ptr = (SYS_UWORD16 *)&INIT_GCP16[0];
117 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 8, C_LCD_IF_DISPLAY);
118
119
120 command = LCD_MD_CSET; // set area devoted to DSP interface
121 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
122
123 ptr = (SYS_UWORD16 *)&INIT_MD_CSET[0];
124 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 2 , C_LCD_IF_DISPLAY);
125
126
127 command = LCD_MD_PSET; // set area devoted to DSP interface
128 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
129
130 ptr = (SYS_UWORD16 *)&INIT_MD_PSET[0];
131 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 2, C_LCD_IF_DISPLAY);
132
133
134 command = LCD_SD_CSET; // set area devoted to MPU interface
135 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
136
137 ptr = (SYS_UWORD16 *)&INIT_SD_CSET[0];
138
139 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 2, C_LCD_IF_DISPLAY);
140
141
142 command = LCD_SD_PSET; // set area devoted to MPU interface
143 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
144
145 ptr = (SYS_UWORD16 *)&INIT_SD_PSET[0];
146
147 f_lcd_if_poll_write(C_LCD_IF_CS0, ptr, 2, C_LCD_IF_DISPLAY);
148
149
150
151 command = LCD_OSCISEL; // internal OSG
152 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
153 data = INIT_OSCISEL; // 0x05
154 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
155
156
157 command = LCD_14MSET;
158 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
159 data = INIT_14MSET; // 0x4B
160 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
161
162
163 command = LCD_14MEND;
164 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
165
166
167 command = LCD_3500KSET;
168 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
169 data = INIT_3500KSET; // 0x45
170 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
171
172
173 command = LCD_3500KEND;
174 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
175
176
177 r2d_nop_delay(30);
178
179
180 command = LCD_SLPOUT; // this command cancels the sleep mode
181 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
182
183
184 r2d_nop_delay(20);
185
186
187 command = LCD_VOLCTL; // sets Ton timing of power IC
188 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
189 data = INIT_VOLCTL_Ton; // 152
190 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
191
192
193 r2d_nop_delay(20);
194
195
196 command = LCD_VOLCTL; // sets the electronic volume
197 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
198 data = INIT_VOLCTL;
199 f_lcd_if_poll_write(C_LCD_IF_CS0, &(data), 1, C_LCD_IF_DISPLAY);
200
201
202 r2d_nop_delay(20);
203
204
205 command = LCD_DISON;
206 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
207
208 command = LCD_DISNOR; // this command turns the display mode to NORMAL
209 // without rewriting the content of the display data RAM
210 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
211
212 command = LCD_RAMWR;
213 f_lcd_if_poll_write(C_LCD_IF_CS0, &(command), 1, C_LCD_IF_INSTRUCTION);
214
215
216 for (i=0; i<264; i++)
217 {
218 // Try filling with white color
219 tab_tmp[i] = 0xFFFF;
220 }
221
222 for(j=0; j<220; j++)
223 {
224 f_lcd_if_poll_write(C_LCD_IF_CS0, &(tab_tmp[0]), 264, C_LCD_IF_DISPLAY);
225 }
226
227 #endif
228 }
229
230 void r2d_refresh_task_kill(void)
231 {
232 }
233
234
235 void r2d_dithering_init(void)
236 {
237 R2D_MALLOC(r2d_mb_id,UINT32,sizeof(UINT32)*4,r2d_g_dithering_matrix);
238 if (r2d_g_dithering_matrix!=NULL)
239 {
240 r2d_g_dithering_matrix[0]=0;
241 r2d_g_dithering_matrix[1]=2;
242 r2d_g_dithering_matrix[2]=3;
243 r2d_g_dithering_matrix[3]=1;
244 }
245 }