eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dlcd_LS020.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h" // include of all public items (types, function etc) of D4D driver
47 #include "common_files/d4d_lldapi.h" // include non public low level driver interface header file (types, function prototypes, enums etc. )
48 #include "common_files/d4d_private.h" // include the private header file that contains perprocessor macros as D4D_MK_STR
49 
50 
51 // identification string of driver - must be same as name D4DLCD_FUNCTIONS structure + "_ID"
52 // it is used for enable the code for compilation
53 #define d4dlcd_ls020_ID 1
54 
55 
56 // copilation enable preprocessor condition
57 // the string d4dlcd_ls020_ID must be replaced by define created one line up
58 #if (D4D_MK_STR(D4D_LLD_LCD) == d4dlcd_ls020_ID)
59 
60  // include of low level driver heaser file
61  // it will be included into wole project only in case that this driver is selected in main D4D configuration file
64  /******************************************************************************
65  * Macros
66  ******************************************************************************/
67  #if D4D_COLOR_SYSTEM != D4D_COLOR_SYSTEM_RGB565
68  #error The eGUI low level driver "d4dlcd_ls020" not supported selected type of D4D_COLOR_SYSTEM. To run this driver just select D4D_COLOR_SYSTEM_RGB565.
69  #endif
70 
71  /******************************************************************************
72  * Internal function prototypes
73  ******************************************************************************/
74 
75  static unsigned char D4DLCD_Init_LS020(void);
76  static unsigned char D4DLCD_SetWindow_LS020(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2);
77  static unsigned char D4DLCD_SetOrientation_LS020(D4DLCD_ORIENTATION new_orientation);
78  static void D4DLCD_Send_PixelColor_LS020(D4D_COLOR value) ;
79  static D4D_COLOR D4DLCD_Get_PixelColor_LS020(void);
80  static void D4DLCD_Flush_LS020(D4DLCD_FLUSH_MODE mode);
81  static unsigned char D4DLCD_DeInit_LS020(void);
82 
83  static void D4DLCD_Command_Data(const unsigned short data[], unsigned int count);
84 
85  /**************************************************************/
91  // the main structure that contains low level driver api functions
92  // the name fo this structure is used for recognizing of configured low level driver of whole D4D
93  // so this name has to be used in main configuration header file of D4D driver to enable this driver
94  const D4DLCD_FUNCTIONS d4dlcd_ls020 =
95  {
96  D4DLCD_Init_LS020,
97  D4DLCD_SetWindow_LS020,
98  D4DLCD_SetOrientation_LS020,
99  D4DLCD_Send_PixelColor_LS020,
100  D4DLCD_Get_PixelColor_LS020,
101  D4DLCD_Flush_LS020,
103  D4DLCD_DeInit_LS020,
104  };
105 
106  /**************************************************************/
111  static D4DLCD_ORIENTATION d4dlcd_orientation = Portrait;
112  /**************************************************************/
118  // sends Command/Data sequence word (16 bit) or array with words - first 1 command, then 1 x data
119  static void D4DLCD_Command_Data(const unsigned short data[], unsigned int count)
120  {
121  int i;
122 
123  for (i=0; i<count; i++)
124  {
125  (void)D4D_LLD_LCD_HW.D4DLCDHW_SendCmdWord((unsigned short)data[i]);
126  }
127  }
128 
129  //-----------------------------------------------------------------------------
130  // FUNCTION: D4DLCD_Init_LS020
131  // SCOPE: Low Level Driver API function
132  // DESCRIPTION: The function is used for initialization of this low level driver
133  //
134  // PARAMETERS: none
135  //
136  // RETURNS: result: 1 - Success
137  // 0 - Failed
138  //-----------------------------------------------------------------------------
139  static unsigned char D4DLCD_Init_LS020(void)
140  {
141  static const unsigned short init_data[] =
142  {
143  0xFDFD, 0xFDFD,
144  // pause
145  0xEF00, 0xEE04, 0x1B04, 0xFEFE, 0xFEFE,
146  0xEF90, 0x4A04, 0x7F3F, 0xEE04, 0x4306,
147  // pause
148  0xEF90, 0x0983, 0x0800, 0x0BAF, 0x0A00,
149  0x0500, 0x0600, 0x0700, 0xEF00, 0xEE0C,
150  0xEF90, 0x0080, 0xEFB0, 0x4902, 0xEF00,
151  0x7F01, 0xE181, 0xE202, 0xE276, 0xE183,
152  0x8001, 0xEF90, 0x0000
153  };
154 
155  if(D4D_LLD_LCD_HW.D4DLCDHW_Init == NULL)
156  return 0;
157  if(D4D_LLD_LCD_HW.D4DLCDHW_SendDataWord == NULL)
158  return 0;
159  if(D4D_LLD_LCD_HW.D4DLCDHW_SendCmdWord == NULL)
160  return 0;
161  if(D4D_LLD_LCD_HW.D4DLCDHW_ReadDataWord == NULL)
162  return 0;
163  if(D4D_LLD_LCD_HW.D4DLCDHW_ReadCmdWord == NULL)
164  return 0;
165  if(D4D_LLD_LCD_HW.D4DLCDHW_PinCtl == NULL)
166  return 0;
167  if(D4D_LLD_LCD_HW.D4DLCDHW_FlushBuffer == NULL)
168  return 0;
169  if(D4D_LLD_LCD_HW.D4DLCDHW_DeInit == NULL)
170  return 0;
171 
172 
173  if(!D4D_LLD_LCD_HW.D4DLCDHW_Init())
174  return 0;
175 
176  (void)D4D_LLD_LCD_HW.D4DLCDHW_PinCtl(D4DLCD_BACKLIGHT_PIN, D4DHW_PIN_SET_1);
177  (void)D4D_LLD_LCD_HW.D4DLCDHW_PinCtl(D4DLCD_BACKLIGHT_PIN, D4DHW_PIN_OUT);
178 
179  (void)D4D_LLD_LCD_HW.D4DLCDHW_PinCtl(D4DLCD_RESET_PIN, D4DHW_PIN_SET_0);
180  (void)D4D_LLD_LCD_HW.D4DLCDHW_PinCtl(D4DLCD_RESET_PIN, D4DHW_PIN_OUT);
181 
185 
186  D4DLCD_Command_Data(&init_data[0], 2); D4DLCD_Delay_ms_Common(75);
187  D4DLCD_Command_Data(&init_data[2], 10); D4DLCD_Delay_ms_Common(75);
188  D4DLCD_Command_Data(&init_data[12], 23);
189 
190  return 1;
191  }
192 
193  //-----------------------------------------------------------------------------
194  // FUNCTION: D4DLCD_DeInit_LS020
195  // SCOPE: Low Level Driver API function
196  // DESCRIPTION: The function is used for deinitialization of this low level driver
197  //
198  // PARAMETERS: none
199  //
200  // RETURNS: result: 1 - Success
201  // 0 - Failed
202  //-----------------------------------------------------------------------------
203  static unsigned char D4DLCD_DeInit_LS020(void)
204  {
205  return 0;
206  }
207 
208  //-----------------------------------------------------------------------------
209  // FUNCTION: D4DLCD_SetWindow_LS020
210  // SCOPE: Low Level Driver API function
211  // DESCRIPTION: The function sets the logic window in memory of LCD driver
212  //
213  // PARAMETERS: unsigned int x1 - left cordination of logic window
214  // unsigned int y1 - top cordination of logic window
215  // unsigned int x2 - right cordination of logic window
216  // unsigned int y2 - bottom cordination of logic window
217  //
218  // RETURNS: result: 1 - Success
219  // 0 - Failed
220  //-----------------------------------------------------------------------------
221  static unsigned char D4DLCD_SetWindow_LS020(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
222  {
223  unsigned char data[] =
224  {
225  0xEF, 0x08,
226  0x18, 0x00,
227  0x12,0,
228  0x15,0,
229  0x13,0,
230  0x16,0
231  };
232 
233 
234  switch (d4dlcd_orientation)
235  {
236  default:
237  // Invalid! Fall through to portrait mode
238  case Portrait:
239  data[3] = 0; // Mode
240  data[5]= (unsigned char) x1;
241  data[7]= (unsigned char) x2;
242  data[9]= (unsigned char) y1;
243  data[11]= (unsigned char) y2;
244  break;
245  case Portrait180:
246  data[3] = 0x03; // Mode
247  data[5] = (unsigned char) (D4D_SCREEN_SIZE_SHORTER_SIDE - 1 - x1);
248  data[7] = (unsigned char) (D4D_SCREEN_SIZE_SHORTER_SIDE - 1 - x2);
249  data[9] = (unsigned char) (D4D_SCREEN_SIZE_LONGER_SIDE - 1 - y1);
250  data[11] = (unsigned char) (D4D_SCREEN_SIZE_LONGER_SIDE - 1 - y2);
251  break;
252  case Landscape:
253  data[3] = 0x05; // Mode
254  data[5] = (unsigned char) (D4D_SCREEN_SIZE_SHORTER_SIDE - 1 - y1);
255  data[7] = (unsigned char) (D4D_SCREEN_SIZE_SHORTER_SIDE - 1 - y2);
256  data[9] = (unsigned char) x1;
257  data[11] = (unsigned char) x2;
258  break;
259  case Landscape180:
260  // Information on mode Landscape180: At this mode the display seems to have a bug.
261  // Please read the programmers manual for more information or just do not use this mode with
262  // large pictures or large boxes >125 lines in Y-direction
263  data[3] = 0x06; // Mode
264  data[5] = (unsigned char) y1;
265  data[7] = (unsigned char) y2;
266  data[9] = (unsigned char) (D4D_SCREEN_SIZE_LONGER_SIDE - 1 - x1);
267  data[11] = (unsigned char) (D4D_SCREEN_SIZE_LONGER_SIDE - 1 - x2);
268  break;
269  }
270 
271  D4DLCD_Command_Data((unsigned short*)data, 6);
272 
273  return 1;
274  }
275 
276  //-----------------------------------------------------------------------------
277  // FUNCTION: D4DLCD_SetOrientation_LS020
278  // SCOPE: Low Level Driver API function
279  // DESCRIPTION: The function set the new orientation of LCD
280  //
281  // PARAMETERS: D4DLCD_ORIENTATION new_orientation the requested new orientation
282  //
283  // RETURNS: result: 1 - Success
284  // 0 - Failed
285  //-----------------------------------------------------------------------------
286  static unsigned char D4DLCD_SetOrientation_LS020(D4DLCD_ORIENTATION new_orientation)
287  {
288  d4dlcd_orientation = new_orientation;
289  return D4DLCD_SetWindow_LS020(0, 0, 1, 1);
290  }
291 
292  //-----------------------------------------------------------------------------
293  // FUNCTION: D4DLCD_Send_PixelColor_LS020
294  // SCOPE: Low Level Driver API function
295  // DESCRIPTION: The function send the one pixel (Word) into LCD
296  //
297  // PARAMETERS: unsigned short Value value of pixel color
298  //
299  // RETURNS: none
300  //-----------------------------------------------------------------------------
301  static void D4DLCD_Send_PixelColor_LS020(D4D_COLOR value)
302  {
303  D4D_LLD_LCD_HW.D4DLCDHW_SendDataWord(value);
304  }
305 
306  //-----------------------------------------------------------------------------
307  // FUNCTION: D4DLCD_Get_PixelColor_LS020
308  // SCOPE: Low Level Driver API function
309  // DESCRIPTION: The function reads the one Word(Pixel) from LCD (if this function is supported)
310  //
311  // PARAMETERS: none
312  //
313  // RETURNS: unsigned short - the readed value
314  //
315  //-----------------------------------------------------------------------------
316  static D4D_COLOR D4DLCD_Get_PixelColor_LS020(void)
317  {
318  return D4D_LLD_LCD_HW.D4DLCDHW_ReadDataWord();
319  }
320 
321  //-----------------------------------------------------------------------------
322  // FUNCTION: D4DLCD_Flush_LS020
323  // SCOPE: Low Level Driver API function
324  // DESCRIPTION: For buffered low level interfaces is used to inform
325  // driver the complete object is drawed and pending pixels should be flushed
326  //
327  // PARAMETERS: none
328  //
329  // RETURNS: none
330  //-----------------------------------------------------------------------------
331  static void D4DLCD_Flush_LS020(D4DLCD_FLUSH_MODE mode)
332  {
333  D4D_LLD_LCD_HW.D4DLCDHW_FlushBuffer(mode);
334  }
335 
336 
337 #endif //(D4D_MK_STR(D4D_LLD_LCD) == d4dlcd_ls020_ID)
D4D low level standard LCD interface API structure.
Definition: d4d_lldapi.h:147
#define D4D_SCREEN_SIZE_LONGER_SIDE
This macro is used to define the size of longer side of LCD. If not defined, the longer side is set t...
Definition: d4d_base.h:101
Orientation LandScape up side down.
Definition: d4d_lldapi.h:69
#define D4D_LLD_LCD_HW
Definition: d4d_types.h:76
D4D Driver main header file.
Orientation LandScape.
Definition: d4d_lldapi.h:68
D4DLCD_FLUSH_MODE
D4D low level eGUI flush screen types enumeration.
Definition: d4d_lldapi.h:136
D4D Driver private header file.
Orientation Portrait up side down.
Definition: d4d_lldapi.h:67
D4DLCD_ORIENTATION
D4D low level screen orientation enumeration type.
Definition: d4d_lldapi.h:64
Switch pin to output mode.
Definition: d4d_lldapi.h:77
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
Set pin output register to logic 1.
Definition: d4d_lldapi.h:80
LCD device backlight enable signal.
Definition: d4d_lldapi.h:99
#define D4D_SCREEN_SIZE_SHORTER_SIDE
This macro is used to define the size of shorter side of LCD. If not defined, the shorter side is set...
Definition: d4d_base.h:108
D4D driver - ls020 lcd driver function header file.
Set pin output register to logic 0.
Definition: d4d_lldapi.h:79
D4D driver - common low level driver header file.
void D4DLCD_Delay_ms_Common(unsigned short period)
Orientation Portrait.
Definition: d4d_lldapi.h:66
D4D driver - resistive touch screen driver function header file.
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
LCD device reset signal.
Definition: d4d_lldapi.h:98