FreeCalypso > hg > tcs211-l1-reconst
comparison chipsetsw/drivers/drv_app/r2d/lcds/Customer/r2d_task_i.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 | |
2 #ifndef _WINDOWS | |
3 #include "r2d/uwire.h" | |
4 #endif | |
5 | |
6 | |
7 | |
8 //value to transmit in order to set the x position on the lcd | |
9 static const char x_position[DISP_PIXELWIDTH] ={0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | |
10 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, | |
11 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf, | |
12 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, | |
13 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf, | |
14 0xd0,0xd1,0xd2,0xd3}; | |
15 | |
16 //value to transmit in order to set the y position on the lcd | |
17 static const char y_position[DISP_PAGEHEIGHT] ={0x40,0x41,0x42,0x43,0x44,0x45}; | |
18 | |
19 | |
20 UINT32 r2d_p_refresh_buffer[4*R2D_WIDTH*R2D_MWHEIGHT]; | |
21 | |
22 | |
23 #if (R2D_BENCHMARKING == R2D_ON) | |
24 UINT32 r2d_g_tick=0; | |
25 #endif | |
26 | |
27 | |
28 #ifndef _WINDOWS | |
29 void r2d_int_set_DC_low(void) | |
30 { | |
31 * (volatile UINT16 *) GPIO_OUT &= ~(0x02); //gpio(1) ->0 | |
32 } | |
33 | |
34 /********************************************************************/ | |
35 /* set the DC input to high for data transmission */ | |
36 /* */ | |
37 /********************************************************************/ | |
38 void r2d_int_set_DC_high(void) | |
39 { | |
40 * (volatile UINT16 *) GPIO_OUT |= 0x02; //gpio(1) ->1 | |
41 } | |
42 | |
43 | |
44 static void r2d_int_lcd_transmit_cmd(UINT8 cmd) | |
45 { | |
46 r2d_int_set_DC_low(); | |
47 * (volatile UINT16 *) TDR = cmd <<8; | |
48 * (volatile UINT16 *) CSR |= NB_BITS_WR_8 + CS_CMD + START ; // transmit command data | |
49 while (((* (volatile UINT16 *) CSR) & CSRB) != 0 ); // wait for end of WRITE | |
50 * (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select | |
51 } | |
52 | |
53 static BOOLEAN r2d_int_lcd_polling(void) | |
54 { | |
55 if (((* (volatile UINT16 *) CSR) & CSRB) == 0 ) | |
56 { | |
57 * (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select | |
58 return(TRUE); | |
59 } | |
60 else | |
61 return(FALSE); | |
62 } | |
63 | |
64 | |
65 | |
66 #endif | |
67 | |
68 void r2d_lcd_power_on(void) | |
69 { | |
70 } | |
71 | |
72 void r2d_lcd_power_off(void) | |
73 { | |
74 } | |
75 | |
76 | |
77 void r2d_refresh(void) | |
78 { | |
79 UINT16 i,j; | |
80 | |
81 UINT32 v; | |
82 | |
83 UINT32 *buffer_end,*buffer_write; | |
84 UINT32 *p,*writing; | |
85 INT32 *buffer_read; | |
86 UINT16 byte; | |
87 | |
88 #if (R2D_BENCHMARKING == R2D_ON) | |
89 | |
90 UINT32 time,k; | |
91 | |
92 if (!r2d_g_tick) | |
93 { | |
94 time=rvf_get_tick_count(); | |
95 | |
96 } | |
97 | |
98 | |
99 for(k=0;k<R2D_REFRESH_LOOP;k++) | |
100 { | |
101 #endif | |
102 #ifndef _WINDOWS | |
103 r2d_int_lcd_transmit_cmd(x_position[0]);// set X to 0 | |
104 r2d_int_lcd_transmit_cmd(y_position[0]);// set Y to 0 | |
105 #else | |
106 lcd_transmit_cmd(x_position[0]);// set X to 0 | |
107 lcd_transmit_cmd(y_position[0]);// set Y to 0 | |
108 #endif | |
109 //rvf_send_trace("R2D REFRESH",strlen("R2D REFRESH"), NULL_PARAM, | |
110 // RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX ); | |
111 | |
112 p=r2d_g_framebuffer->p_memory_words; | |
113 | |
114 // First word out of refresh buffer | |
115 buffer_end=r2d_p_refresh_buffer+(R2D_HEIGHT>>3)*R2D_WIDTH; | |
116 buffer_read=(INT32*)r2d_p_refresh_buffer; | |
117 buffer_write=r2d_p_refresh_buffer; | |
118 writing=buffer_write-R2D_WIDTH; | |
119 | |
120 | |
121 i=0; | |
122 while(i<R2D_WIDTH) | |
123 { | |
124 j=0; | |
125 while(j<R2D_MWHEIGHT) | |
126 { | |
127 // If can read a new word from framebuffer | |
128 // and write it to refresh buffer | |
129 //if (r2d_p_refresh_state[i]+4<=R2D_MWHEIGHT*4) | |
130 { | |
131 //r2d_p_refresh_state[i]+=4; | |
132 v=*p++; | |
133 j++; | |
134 | |
135 writing+=R2D_WIDTH; | |
136 *writing = (v & 0xFF) | 0x80000000; | |
137 | |
138 v=v>>8; | |
139 writing+=R2D_WIDTH; | |
140 *writing = (v & 0xFF) | 0x80000000; | |
141 | |
142 v=v>>8; | |
143 writing+=R2D_WIDTH; | |
144 *writing = (v & 0xFF) | 0x80000000; | |
145 | |
146 v=v>>8; | |
147 writing+=R2D_WIDTH; | |
148 *writing = (v & 0xFF) | 0x80000000; | |
149 | |
150 | |
151 | |
152 | |
153 } | |
154 | |
155 #ifndef _WINDOWS | |
156 if ((r2d_int_lcd_polling()) && (buffer_read != (INT32*)buffer_end)) | |
157 #else | |
158 // If polling finished | |
159 if ((lcd_polling()) && (buffer_read != (INT32*)buffer_end)) | |
160 #endif | |
161 { | |
162 // If new data is available | |
163 // to be sent to LCD | |
164 if (*buffer_read<0) | |
165 { | |
166 #ifndef _WINDOWS | |
167 * (volatile UINT16 *) GPIO_OUT |= 0x02; //gpio(1) ->1 | |
168 * (volatile UINT16 *) TDR = *buffer_read <<8; | |
169 * (volatile UINT16 *) CSR |= NB_BITS_WR_8 + CS_CMD + START ; // transmit data | |
170 #else | |
171 lcd_transmit_data(*buffer_read); | |
172 #endif | |
173 | |
174 *buffer_read++=0; | |
175 | |
176 } | |
177 } | |
178 | |
179 | |
180 | |
181 } | |
182 i++; | |
183 writing=(++buffer_write) - R2D_WIDTH;; | |
184 } | |
185 // Finish sending datas to LCD | |
186 while(buffer_read!=(INT32*)buffer_end) | |
187 { | |
188 #ifndef _WINDOWS | |
189 if (r2d_int_lcd_polling()) | |
190 #else | |
191 if (lcd_polling()) | |
192 #endif | |
193 { | |
194 // If new data is available | |
195 // to be sent to LCD | |
196 if (*buffer_read<0) | |
197 { | |
198 | |
199 #ifndef _WINDOWS | |
200 * (volatile UINT16 *) GPIO_OUT |= 0x02; //gpio(1) ->1 | |
201 * (volatile UINT16 *) TDR = *buffer_read <<8; | |
202 * (volatile UINT16 *) CSR |= NB_BITS_WR_8 + CS_CMD + START ; // transmit data | |
203 #else | |
204 lcd_transmit_data(*buffer_read); | |
205 #endif | |
206 *buffer_read++=0; | |
207 | |
208 | |
209 } | |
210 } | |
211 } | |
212 | |
213 #if (R2D_BENCHMARKING == R2D_ON) | |
214 } // End benchmarking | |
215 #endif | |
216 | |
217 r2d_reinit_update_region(); | |
218 | |
219 #ifdef _WINDOWS | |
220 lcd_refresh(); | |
221 #endif | |
222 | |
223 #if (R2D_BENCHMARKING == R2D_ON) | |
224 if (r2d_g_tick==0) | |
225 { | |
226 time=rvf_get_tick_count()-time; | |
227 r2d_g_tick=1; | |
228 rvf_send_trace("R2D : Nb refreshs",17,R2D_REFRESH_LOOP, | |
229 RV_TRACE_LEVEL_ERROR, TRACE_R2D ); | |
230 rvf_send_trace("R2D : Ms=",9,time*10, | |
231 RV_TRACE_LEVEL_ERROR, TRACE_R2D ); | |
232 } | |
233 #endif | |
234 } | |
235 | |
236 | |
237 |