eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dlcdhw_gpio8080_byte_8b.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 D4DTCH_FUNCTIONS structure + "_ID"
52 // it is used for enable the code for compilation
53 #define d4dlcdhw_gpio8080_byte_8b_ID 1
54 
55 
56 // copilation enable preprocessor condition
57 // the string d4dtch_gpio8080_byte_8b_ID must be replaced by define created one line up
58 #if (D4D_MK_STR(D4D_LLD_LCD_HW) == d4dlcdhw_gpio8080_byte_8b_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
63  /******************************************************************************
64  * Macros
65  ******************************************************************************/
66  #if D4D_COLOR_SYSTEM != D4D_COLOR_SYSTEM_RGB565
67  #error The eGUI low level driver "d4dlcdhw_gpio8080_byte_8b" not supported selected type of D4D_COLOR_SYSTEM. To run this driver just select D4D_COLOR_SYSTEM_RGB565.
68  #endif
69  /******************************************************************************
70  * Internal function prototypes
71  ******************************************************************************/
72 
73  static unsigned char D4DLCDHW_Init_Gpio8080Byte_8b(void);
74  static unsigned char D4DLCDHW_DeInit_Gpio8080Byte_8b(void);
75  static void D4DLCDHW_SendDataWord_Gpio8080Byte_8b(unsigned short value);
76  static void D4DLCDHW_SendCmdWord_Gpio8080Byte_8b(unsigned short cmd);
77  static unsigned short D4DLCDHW_ReadDataWord_Gpio8080Byte_8b(void);
78  static unsigned short D4DLCDHW_ReadCmdWord_Gpio8080Byte_8b(void);
79  static unsigned char D4DLCDHW_PinCtl_Gpio8080Byte_8b(D4DLCDHW_PINS pinId, D4DHW_PIN_STATE setState);
80  static void D4DLCD_FlushBuffer_Gpio8080Byte_8b(D4DLCD_FLUSH_MODE mode);
81 
82  /**************************************************************/
88  // the main structure that contains low level driver api functions
89  // the name fo this structure is used for recognizing of configured low level driver of whole D4D
90  // so this name has to be used in main configuration header file of D4D driver to enable this driver
91  const D4DLCDHW_FUNCTIONS d4dlcdhw_gpio8080_byte_8b =
92  {
93  D4DLCDHW_Init_Gpio8080Byte_8b,
94  D4DLCDHW_SendDataWord_Gpio8080Byte_8b,
95  D4DLCDHW_SendCmdWord_Gpio8080Byte_8b,
96  D4DLCDHW_ReadDataWord_Gpio8080Byte_8b,
97  D4DLCDHW_ReadCmdWord_Gpio8080Byte_8b,
98  D4DLCDHW_PinCtl_Gpio8080Byte_8b,
99  D4DLCD_FlushBuffer_Gpio8080Byte_8b,
100  D4DLCDHW_DeInit_Gpio8080Byte_8b
101  };
102  /**************************************************************/
108  /**************************************************************/
115  //-----------------------------------------------------------------------------
116  // FUNCTION: D4DLCDHW_Init_Gpio8080Byte_8b
117  // SCOPE: Low Level Driver API function
118  // DESCRIPTION: The function is used for initialization of this low level driver
119  //
120  // PARAMETERS: none
121  //
122  // RETURNS: result: 1 - Success
123  // 0 - Failed
124  //-----------------------------------------------------------------------------
125  static unsigned char D4DLCDHW_Init_Gpio8080Byte_8b(void)
126  {
127  #ifdef D4DLCD_DISPLAY_MCU_USER_INIT
128  D4DLCD_DISPLAY_MCU_USER_INIT
129  #endif
130 
131  D4DLCD_ASSERT_CS;
132  D4DLCD_ASSERT_DC;
133 
134  D4DLCD_INIT_CS;
135  D4DLCD_INIT_DC;
136 
137 
138  D4DLCD_INIT_DATA; // 8 bit data port all outputs
139 
140  D4DLCD_INIT_WR;
141  D4DLCD_INIT_RD;
142 
143  D4DLCD_DEASSERT_WR;
144  D4DLCD_DEASSERT_RD;
145 
146  return 1;
147  }
148 
149 
150  //-----------------------------------------------------------------------------
151  // FUNCTION: D4DLCDHW_DeInit_Gpio8080Byte_8b
152  // SCOPE: Low Level Driver API function
153  // DESCRIPTION: The function is used for deinitialization of this low level driver
154  //
155  // PARAMETERS: none
156  //
157  // RETURNS: result: 1 - Success
158  // 0 - Failed
159  //-----------------------------------------------------------------------------
160  static unsigned char D4DLCDHW_DeInit_Gpio8080Byte_8b(void)
161  {
162 
163  }
164 
165  //-----------------------------------------------------------------------------
166  // FUNCTION: D4DLCDHW_SendDataWord_Gpio8080Byte_8b
167  // SCOPE: Low Level Driver API function
168  // DESCRIPTION: The function send the one 16 bit variable into LCD
169  //
170  // PARAMETERS: unsigned short value variable to send
171  //
172  // RETURNS: none
173  //-----------------------------------------------------------------------------
174  static void D4DLCDHW_SendDataWord_Gpio8080Byte_8b(unsigned short value)
175  {
176  OUTPUT_ALL(D4DLCD_DATA);
177  D4DLCD_ASSERT_CS;
178 
179  D4DLCD_DATA_WRITE((unsigned char)value); // lsb!
180  D4DLCD_ASSERT_WR;
181  asm(nop);
182  asm(nop);
183  asm(nop);
184  asm(nop);
185  asm(nop);
186  asm(nop);
187  asm(nop);
188  asm(nop);
189  asm(nop);
190  asm(nop);
191  asm(nop);
192  asm(nop);
193  asm(nop);
194  asm(nop);
195  asm(nop);
196  asm(nop);
197  asm(nop);
198  asm(nop);
199  D4DLCD_DEASSERT_WR;
200 
201  asm(nop);
202  asm(nop);
203  asm(nop);
204  asm(nop);
205  asm(nop);
206  asm(nop);
207  asm(nop);
208  asm(nop);
209  asm(nop);
210  asm(nop);
211  asm(nop);
212  asm(nop);
213  asm(nop);
214  asm(nop);
215  asm(nop);
216  asm(nop);
217  asm(nop);
218  asm(nop);
219 
220  D4DLCD_DEASSERT_CS;
221 
222 
223 
224  asm(nop);
225  asm(nop);
226  asm(nop);
227  asm(nop);
228  asm(nop);
229  asm(nop);
230  asm(nop);
231  asm(nop);
232  asm(nop);
233  asm(nop);
234  asm(nop);
235  asm(nop);
236  asm(nop);
237  asm(nop);
238  asm(nop);
239  asm(nop);
240  asm(nop);
241  asm(nop);
242  asm(nop);
243  asm(nop);
244  asm(nop);
245  asm(nop);
246  asm(nop);
247  asm(nop);
248  asm(nop);
249  asm(nop);
250  asm(nop);
251  asm(nop);
252  asm(nop);
253  asm(nop);
254  asm(nop);
255  asm(nop);
256  asm(nop);
257  asm(nop);
258  asm(nop);
259  asm(nop);
260  asm(nop);
261  asm(nop);
262  asm(nop);
263  asm(nop);
264  asm(nop);
265  asm(nop);
266  asm(nop);
267  asm(nop);
268  asm(nop);
269  asm(nop);
270  asm(nop);
271  asm(nop);
272  asm(nop);
273  asm(nop);
274  asm(nop);
275  asm(nop);
276  asm(nop);
277  asm(nop);
278  asm(nop);
279  asm(nop);
280  asm(nop);
281  asm(nop);
282  asm(nop);
283  asm(nop);
284  asm(nop);
285  asm(nop);
286  asm(nop);
287  asm(nop);
288  asm(nop);
289  asm(nop);
290  asm(nop);
291  asm(nop);
292  asm(nop);
293  asm(nop);
294  asm(nop);
295  asm(nop);
296  asm(nop);
297  asm(nop);
298  asm(nop);
299  asm(nop);
300  asm(nop);
301  asm(nop);
302  asm(nop);
303  asm(nop);
304  asm(nop);
305  asm(nop);
306  asm(nop);
307  asm(nop);
308  }
309 
310  //-----------------------------------------------------------------------------
311  // FUNCTION: D4DLCDHW_SendCmdWord_Gpio8080Byte_8b
312  // SCOPE: Low Level Driver API function
313  // DESCRIPTION: The function send the one 16 bit command into LCD
314  //
315  // PARAMETERS: unsigned short cmd command to send
316  //
317  // RETURNS: none
318  //-----------------------------------------------------------------------------
319  static void D4DLCDHW_SendCmdWord_Gpio8080Byte_8b(unsigned short cmd)
320  {
321  D4DLCD_ASSERT_DC; // DataCmd := 0
322  D4DLCDHW_SendDataWord_Gpio8080Byte_8b(cmd);
323  D4DLCD_DEASSERT_DC; // DataCmd := 1
324  }
325 
326 
327  //-----------------------------------------------------------------------------
328  // FUNCTION: D4DLCDHW_ReadDataWord_Gpio8080Byte_8b
329  // SCOPE: Low Level Driver API function
330  // DESCRIPTION: The function reads the one 16 bit variable from LCD (if this function is supported)
331  //
332  // PARAMETERS: none
333  //
334  // RETURNS: unsigned short - the readed value
335  //
336  //-----------------------------------------------------------------------------
337  static unsigned short D4DLCDHW_ReadDataWord_Gpio8080Byte_8b(void)
338  {
339  unsigned short value;
340 
341  INPUT_ALL(D4DLCD_DATA);
342  D4DLCD_DEASSERT_DC;
343  D4DLCD_ASSERT_CS;
344 
345  D4DLCD_ASSERT_RD;
346  D4DLCD_DEASSERT_RD;
347  value = D4DLCD_DATA; // msb!
348 
349  D4DLCD_DEASSERT_CS;
350 
351  return value;
352  }
353 
354  //-----------------------------------------------------------------------------
355  // FUNCTION: D4DLCDHW_ReadCmdWord_Gpio8080Byte_8b
356  // SCOPE: Low Level Driver API function
357  // DESCRIPTION: The function reads the one 16 bit command from LCD (if this function is supported)
358  //
359  // PARAMETERS: none
360  //
361  // RETURNS: unsigned short - the readed value
362  //
363  //-----------------------------------------------------------------------------
364  static unsigned short D4DLCDHW_ReadCmdWord_Gpio8080Byte_8b(void)
365  {
366  unsigned char tmp_res;
367  D4DLCD_ASSERT_DC; // DataCmd := 0
368  tmp_res = (unsigned char)D4DLCDHW_ReadDataWord_Gpio8080Byte_8b();
369  D4DLCD_DEASSERT_DC; // DataCmd := 1
370 
371  return tmp_res;
372  }
373 
374  //-----------------------------------------------------------------------------
375  // FUNCTION: D4DLCDHW_PinCtl_Gpio8080Byte_8b
376  // SCOPE: Low Level Driver API function
377  // DESCRIPTION: allows control GPIO pins for LCD conrol purposes
378  //
379  // PARAMETERS: D4DLCDHW_PINS pinId - Pin identification
380  // D4DHW_PIN_STATE setState - Pin action
381  // RETURNS: for Get action retuns the pin value
382  //-----------------------------------------------------------------------------
383  static unsigned char D4DLCDHW_PinCtl_Gpio8080Byte_8b(D4DLCDHW_PINS pinId, D4DHW_PIN_STATE setState)
384  {
385  switch(pinId)
386  {
387  case D4DLCD_RESET_PIN:
388  switch(setState)
389  {
390  case D4DHW_PIN_OUT:
391  OUTPUT(D4DLCD_RESET);
392  break;
393  case D4DHW_PIN_IN:
394  INPUT(D4DLCD_RESET);
395  break;
396  case D4DHW_PIN_SET_1:
397  D4DLCD_DEASSERT_RESET
398  break;
399  case D4DHW_PIN_SET_0:
400  D4DLCD_ASSERT_RESET;
401  break;
402  }
403  break;
405  switch(setState)
406  {
407 
408  #ifdef D4DLCD_BACKLIGHT
409 
410  case D4DHW_PIN_OUT:
411  OUTPUT(D4DLCD_BACKLIGHT);
412  break;
413  case D4DHW_PIN_IN:
414  INPUT(D4DLCD_BACKLIGHT);
415  break;
416  case D4DHW_PIN_SET_1:
417  D4DLCD_DEASSERT_BACKLIGHT
418  break;
419  case D4DHW_PIN_SET_0:
420  D4DLCD_ASSERT_BACKLIGHT;
421  break;
422 
423  #endif
424 
425  }
426  break;
427  }
428  return 0;
429  }
430 
431  //-----------------------------------------------------------------------------
432  // FUNCTION: D4DLCD_FlushBuffer_Gpio8080Byte_8b
433  // SCOPE: Low Level Driver API function
434  // DESCRIPTION: For buffered low level interfaces is used to inform
435  // driver the complete object is drawed and pending pixels should be flushed
436  //
437  // PARAMETERS: none
438  //
439  // RETURNS: none
440  //-----------------------------------------------------------------------------
441  static void D4DLCD_FlushBuffer_Gpio8080Byte_8b(D4DLCD_FLUSH_MODE mode)
442  {
443  D4D_UNUSED(mode);
444  }
445 
446 #endif //(D4D_MK_STR(D4D_LLD_LCD_HW) == d4dlcdhw_gpio8080_byte_8b_ID)
D4D low level standard LCD Hardware interface API structure.
Definition: d4d_lldapi.h:163
#define INPUT(x)
D4D Driver main header file.
D4DHW_PIN_STATE
D4D low level MCU pin state enumeration type.
Definition: d4d_lldapi.h:73
D4DLCD_FLUSH_MODE
D4D low level eGUI flush screen types enumeration.
Definition: d4d_lldapi.h:136
D4D Driver private header file.
D4DLCDHW_PINS
D4D low level MCU types definition for general LCD screen control signals.
Definition: d4d_lldapi.h:96
#define OUTPUT(x)
Switch pin to input mode (equivalent to high-Z)
Definition: d4d_lldapi.h:78
Switch pin to output mode.
Definition: d4d_lldapi.h:77
Set pin output register to logic 1.
Definition: d4d_lldapi.h:80
LCD device backlight enable signal.
Definition: d4d_lldapi.h:99
D4D driver hardware level LCD header file.
#define INPUT_ALL(x)
#define D4D_UNUSED(x)
Macro used just for notify compiler that the input parameter is not used.
Definition: d4d_base.h:504
Set pin output register to logic 0.
Definition: d4d_lldapi.h:79
D4D driver - resistive touch screen driver function header file.
LCD device reset signal.
Definition: d4d_lldapi.h:98
#define OUTPUT_ALL(x)