comparison chipsetsw/drivers/drv_app/r2d/lcds/Simple/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 void r2d_refresh(void)
77 {
78 UINT16 i,j;
79
80 UINT32 v;
81
82 UINT32 *buffer_end,*buffer_write;
83 UINT32 *p,*writing;
84 INT32 *buffer_read;
85 UINT16 byte;
86
87 #if (R2D_BENCHMARKING == R2D_ON)
88
89 UINT32 time,k;
90
91 if (!r2d_g_tick)
92 {
93 time=rvf_get_tick_count();
94
95 }
96
97
98 for(k=0;k<R2D_REFRESH_LOOP;k++)
99 {
100 #endif
101 #ifndef _WINDOWS
102 r2d_int_lcd_transmit_cmd(x_position[0]);// set X to 0
103 r2d_int_lcd_transmit_cmd(y_position[0]);// set Y to 0
104 #else
105 lcd_transmit_cmd(x_position[0]);// set X to 0
106 lcd_transmit_cmd(y_position[0]);// set Y to 0
107 #endif
108 //rvf_send_trace("R2D REFRESH",strlen("R2D REFRESH"), NULL_PARAM,
109 // RV_TRACE_LEVEL_DEBUG_HIGH, TRACE_XXX );
110
111 p=r2d_g_framebuffer->p_memory_words;
112
113 // First word out of refresh buffer
114 buffer_end=r2d_p_refresh_buffer+(R2D_HEIGHT>>3)*R2D_WIDTH;
115 buffer_read=(INT32*)r2d_p_refresh_buffer;
116 buffer_write=r2d_p_refresh_buffer;
117 writing=buffer_write-R2D_WIDTH;
118
119
120 i=0;
121 while(i<R2D_WIDTH)
122 {
123 j=0;
124 while(j<R2D_MWHEIGHT)
125 {
126 // If can read a new word from framebuffer
127 // and write it to refresh buffer
128 //if (r2d_p_refresh_state[i]+4<=R2D_MWHEIGHT*4)
129 {
130 //r2d_p_refresh_state[i]+=4;
131 v=*p++;
132 j++;
133
134 writing+=R2D_WIDTH;
135 *writing = (v & 0xFF) | 0x80000000;
136
137 v=v>>8;
138 writing+=R2D_WIDTH;
139 *writing = (v & 0xFF) | 0x80000000;
140
141 v=v>>8;
142 writing+=R2D_WIDTH;
143 *writing = (v & 0xFF) | 0x80000000;
144
145 v=v>>8;
146 writing+=R2D_WIDTH;
147 *writing = (v & 0xFF) | 0x80000000;
148
149
150
151
152 }
153
154 #ifndef _WINDOWS
155 if ((r2d_int_lcd_polling()) && (buffer_read != (INT32*)buffer_end))
156 #else
157 // If polling finished
158 if ((lcd_polling()) && (buffer_read != (INT32*)buffer_end))
159 #endif
160 {
161 // If new data is available
162 // to be sent to LCD
163 if (*buffer_read<0)
164 {
165 #ifndef _WINDOWS
166 * (volatile UINT16 *) GPIO_OUT |= 0x02; //gpio(1) ->1
167 * (volatile UINT16 *) TDR = *buffer_read <<8;
168 * (volatile UINT16 *) CSR |= NB_BITS_WR_8 + CS_CMD + START ; // transmit data
169 #else
170 lcd_transmit_data(*buffer_read);
171 #endif
172
173 *buffer_read++=0;
174
175 }
176 }
177
178
179
180 }
181 i++;
182 writing=(++buffer_write) - R2D_WIDTH;;
183 }
184 // Finish sending datas to LCD
185 while(buffer_read!=(INT32*)buffer_end)
186 {
187 #ifndef _WINDOWS
188 if (r2d_int_lcd_polling())
189 #else
190 if (lcd_polling())
191 #endif
192 {
193 // If new data is available
194 // to be sent to LCD
195 if (*buffer_read<0)
196 {
197
198 #ifndef _WINDOWS
199 * (volatile UINT16 *) GPIO_OUT |= 0x02; //gpio(1) ->1
200 * (volatile UINT16 *) TDR = *buffer_read <<8;
201 * (volatile UINT16 *) CSR |= NB_BITS_WR_8 + CS_CMD + START ; // transmit data
202 #else
203 lcd_transmit_data(*buffer_read);
204 #endif
205 *buffer_read++=0;
206
207
208 }
209 }
210 }
211
212 #if (R2D_BENCHMARKING == R2D_ON)
213 } // End benchmarking
214 #endif
215
216 r2d_reinit_update_region();
217
218 #ifdef _WINDOWS
219 lcd_refresh();
220 #endif
221
222 #if (R2D_BENCHMARKING == R2D_ON)
223 if (r2d_g_tick==0)
224 {
225 time=rvf_get_tick_count()-time;
226 r2d_g_tick=1;
227 rvf_send_trace("R2D : Nb refreshs",17,R2D_REFRESH_LOOP,
228 RV_TRACE_LEVEL_ERROR, TRACE_R2D );
229 rvf_send_trace("R2D : Ms=",9,time*10,
230 RV_TRACE_LEVEL_ERROR, TRACE_R2D );
231 }
232 #endif
233 }
234
235
236