eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4dlcdhw_mqx_mpc5125_diu.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_mqx_mpc5125_diu_ID 1
54 
55 
56 // copilation enable preprocessor condition
57 // the string d4dtch_mqx_mpc5125_diu_ID must be replaced by define created one line up
58 #if (D4D_MK_STR(D4D_LLD_LCD_HW) == d4dlcdhw_mqx_mpc5125_diu_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  #include <mqx.h>
64  /******************************************************************************
65  * Macros
66  ******************************************************************************/
67  #if D4D_COLOR_SYSTEM != D4D_COLOR_SYSTEM_RGB565
68  #error The eGUI low level driver "d4dlcdhw_mqx_mpc5125_diu" not supported selected type of D4D_COLOR_SYSTEM. To run this driver just select D4D_COLOR_SYSTEM_RGB565.
69  #endif
70  /******************************************************************************
71  * Internal function prototypes
72  ******************************************************************************/
73 
74  static unsigned char D4DLCDHW_Init_MqxMpc5125_DIU(void);
75  static unsigned char D4DLCDHW_DeInit_MqxMpc5125_DIU(void);
76  static void D4DLCDHW_WriteData_MqxMpc5125_DIU(unsigned long addr, unsigned short value);
77  static unsigned short D4DLCDHW_ReadData_MqxMpc5125_DIU(unsigned long addr);
78  static D4DLCD_FRAMEBUFF_DESC* D4DLCDHW_GetFbDescriptor_MqxMpc5125_DIU(void);
79  static unsigned char D4DLCDHW_PinCtl_MqxMpc5125_DIU(D4DLCDHW_PINS pinId, D4DHW_PIN_STATE setState);
80  static void D4DLCD_FlushBuffer_MqxMpc5125_DIU(D4DLCD_FLUSH_MODE mode);
81 
82 
83  /**************************************************************/
89  // the main structure that contains low level driver api functions
90  // the name fo this structure is used for recognizing of configured low level driver of whole D4D
91  // so this name has to be used in main configuration header file of D4D driver to enable this driver
92  const D4DLCDHWFB_FUNCTIONS d4dlcdhw_mqx_mpc5125_diu =
93  {
94  D4DLCDHW_Init_MqxMpc5125_DIU,
95  D4DLCDHW_WriteData_MqxMpc5125_DIU,
96  D4DLCDHW_ReadData_MqxMpc5125_DIU,
97  D4DLCDHW_GetFbDescriptor_MqxMpc5125_DIU,
98  D4DLCDHW_PinCtl_MqxMpc5125_DIU,
99  D4DLCD_FlushBuffer_MqxMpc5125_DIU,
100  D4DLCDHW_DeInit_MqxMpc5125_DIU
101  };
102  /**************************************************************/
108  static D4DLCD_FRAMEBUFF_DESC d4dlcdhw_mqx_mpc5125_diu_desc;
109  static DISPLAY_CONTEXT_STRUCT_PTR d4dlcdhw_gdc_ptr = NULL;
110  static DISPLAY_PIXEL_BUFFER_PTR d4dlcdhw_pixbuff_ptr = NULL;
111  static DISPLAY_VIEW_STRUCT_PTR d4dlcdhw_view_ptr = NULL;
112  /**************************************************************/
119  //-----------------------------------------------------------------------------
120  // FUNCTION: D4DLCDHW_Init_MqxMpc5125_DIU
121  // SCOPE: Low Level Driver API function
122  // DESCRIPTION: The function is used for initialization of this low level driver
123  //
124  // PARAMETERS: none
125  //
126  // RETURNS: result: 1 - Success
127  // 0 - Failed
128  //-----------------------------------------------------------------------------
129  static unsigned char D4DLCDHW_Init_MqxMpc5125_DIU(void)
130  {
131  char buffer[64];
132 
133  sprintf (buffer, "%dx%dx%d", D4DLCDHWFB_X, D4DLCDHWFB_Y, D4DLCDHWFB_REFRESH);
134  d4dlcdhw_gdc_ptr = display_initialize(buffer);
135  if(d4dlcdhw_gdc_ptr == NULL)
136  return 0;
137 
138 
139 
140 
141  d4dlcdhw_pixbuff_ptr = display_create_pixel_buffer(D4DLCDHWFB_X, D4DLCDHWFB_Y, RGB24, NULL);
142 
143  d4dlcdhw_mqx_mpc5125_diu_desc.bpp_byte = d4dlcdhw_pixbuff_ptr->BPP;
144  d4dlcdhw_mqx_mpc5125_diu_desc.lcd_x_max = d4dlcdhw_pixbuff_ptr->X;
145  d4dlcdhw_mqx_mpc5125_diu_desc.lcd_y_max = d4dlcdhw_pixbuff_ptr->Y;
146  d4dlcdhw_mqx_mpc5125_diu_desc.fb_start_addr = (unsigned long) d4dlcdhw_pixbuff_ptr->FB;
147 
148  d4dlcdhw_view_ptr = display_create_view(d4dlcdhw_gdc_ptr, d4dlcdhw_pixbuff_ptr);
149 
150  if(d4dlcdhw_view_ptr == NULL)
151  {
152  D4DLCDHW_DeInit_MqxMpc5125_DIU();
153  return 0;
154  }
155 
156  display_center_view(d4dlcdhw_view_ptr);
157  display_show_view(d4dlcdhw_view_ptr, DIU_PLANE_1);
158 
159  return 1;
160  }
161 
162 
163  //-----------------------------------------------------------------------------
164  // FUNCTION: D4DLCDHW_DeInit_MqxMpc5125_DIU
165  // SCOPE: Low Level Driver API function
166  // DESCRIPTION: The function is used for deinitialization of this low level driver
167  //
168  // PARAMETERS: none
169  //
170  // RETURNS: result: 1 - Success
171  // 0 - Failed
172  //-----------------------------------------------------------------------------
173  static unsigned char D4DLCDHW_DeInit_MqxMpc5125_DIU(void)
174  {
175  display_destroy_view(d4dlcdhw_view_ptr);
176  display_destroy_pixel_buffer(d4dlcdhw_pixbuff_ptr);
177  display_deinit(d4dlcdhw_gdc_ptr);
178  return 1;
179  }
180 
181  //-----------------------------------------------------------------------------
182  // FUNCTION: D4DLCDHW_SendDataWord_MqxMpc5125_DIU
183  // SCOPE: Low Level Driver API function
184  // DESCRIPTION: The function send the one 16 bit variable into LCD
185  //
186  // PARAMETERS: unsigned long addr address to write data
187  // unsigned short value variable to send
188  //
189  // RETURNS: none
190  //-----------------------------------------------------------------------------
191  static void D4DLCDHW_WriteData_MqxMpc5125_DIU(unsigned long addr, unsigned short value)
192  {
193 
194 
195  #if 0
196  unsigned char color;
197 
198  color = D4D_COLOR_GET_R(value);
199  *((unsigned char*)addr) = color;
200 
201  color = D4D_COLOR_GET_G(value);
202  *((unsigned char*)addr+1) = color;
203 
204  color = D4D_COLOR_GET_B(value);
205  *((unsigned char*)addr+2) = color;
206  #else
207  unsigned long color;
208 
209  color = *((unsigned long*)addr);
210  color &= 0x000000ff;
211  color |= (D4D_COLOR_GET_R(value)) << 24;
212  color |= (D4D_COLOR_GET_G(value)) << 16;
213  color |= (D4D_COLOR_GET_B(value)) << 8;
214 
215  *((unsigned long*)addr) = color;
216  #endif
217  }
218 
219 
220  //-----------------------------------------------------------------------------
221  // FUNCTION: D4DLCDHW_ReadDataWord_MqxMpc5125_DIU
222  // SCOPE: Low Level Driver API function
223  // DESCRIPTION: The function reads the one 16 bit variable from LCD (if this function is supported)
224  //
225  // PARAMETERS: unsigned long addr address to read data
226  //
227  // RETURNS: unsigned short - the read value
228  //
229  //-----------------------------------------------------------------------------
230  static unsigned short D4DLCDHW_ReadData_MqxMpc5125_DIU(unsigned long addr)
231  {
232  unsigned short ret;
233  unsigned long color;
234 
235  color = (*((unsigned long*)addr)) & 0xff000000;
236 
237  ret = D4D_COLOR_RGB(((color & 0xffffff00)>> 3), ((color & 0xffff00ff)>> (2 + 8)), ((color & 0xff00ffff)>> (3 + 16)));
238 
239  return ret;
240  }
241 
242 
243  //-----------------------------------------------------------------------------
244  // FUNCTION: D4DLCDHW_GetFbDescriptor_MqxMpc5125_DIU
245  // SCOPE: Low Level Driver API function
246  // DESCRIPTION: The function return the pointer on filled frame buffer descriptor
247  //
248  // PARAMETERS: none
249  //
250  // RETURNS: D4DLCD_FRAMEBUFF_DESC* - pointer on frame buffer descriptor
251  //
252  //-----------------------------------------------------------------------------
253  static D4DLCD_FRAMEBUFF_DESC* D4DLCDHW_GetFbDescriptor_MqxMpc5125_DIU(void)
254  {
255  return (D4DLCD_FRAMEBUFF_DESC*) &d4dlcdhw_mqx_mpc5125_diu_desc;
256  }
257 
258  //-----------------------------------------------------------------------------
259  // FUNCTION: D4DLCDHW_PinCtl_MqxMpc5125_DIU
260  // SCOPE: Low Level Driver API function
261  // DESCRIPTION: allows control GPIO pins for LCD conrol purposes
262  //
263  // PARAMETERS: D4DLCDHW_PINS pinId - Pin identification
264  // D4DHW_PIN_STATE setState - Pin action
265  // RETURNS: for Get action retuns the pin value
266  //-----------------------------------------------------------------------------
267  static unsigned char D4DLCDHW_PinCtl_MqxMpc5125_DIU(D4DLCDHW_PINS pinId, D4DHW_PIN_STATE setState)
268  {
269  (void)pinId;
270  (void)setState;
271  return 0;
272  }
273 
274  //-----------------------------------------------------------------------------
275  // FUNCTION: D4DLCD_FlushBuffer_MqxMpc5125_DIU
276  // SCOPE: Low Level Driver API function
277  // DESCRIPTION: For buffered low level interfaces is used to inform
278  // driver the complete object is drawed and pending pixels should be flushed
279  //
280  // PARAMETERS: none
281  //
282  // RETURNS: none
283  //-----------------------------------------------------------------------------
284  static void D4DLCD_FlushBuffer_MqxMpc5125_DIU(D4DLCD_FLUSH_MODE mode)
285  {
286  D4D_UNUSED(mode);
287  }
288 #endif //(D4D_MK_STR(D4D_LLD_LCD_HW) == d4dlcdhw_mqx_mpc5125_diu_ID)
#define D4D_COLOR_GET_B(color)
Definition: d4d_scheme.h:438
#define D4D_COLOR_RGB(R, G, B)
Definition: d4d_scheme.h:434
D4D Driver main header file.
unsigned short lcd_x_max
The resolution of LCD in axis X.
Definition: d4d_lldapi.h:120
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
D4D low level frame buffer LCD interface API structure.
Definition: d4d_lldapi.h:179
#define D4DLCDHWFB_REFRESH
D4D low level frame buffer description structure.
Definition: d4d_lldapi.h:117
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
unsigned short lcd_y_max
The resolution of LCD in axis Y.
Definition: d4d_lldapi.h:121
unsigned char bpp_byte
The bytes per pixel.
Definition: d4d_lldapi.h:122
#define D4D_UNUSED(x)
Macro used just for notify compiler that the input parameter is not used.
Definition: d4d_base.h:504
#define D4DLCDHWFB_X
#define D4D_COLOR_GET_G(color)
Definition: d4d_scheme.h:437
unsigned long fb_start_addr
The address of frame buffer.
Definition: d4d_lldapi.h:119
D4D driver - mqx_mpc5125_diu hardware lcd driver function header file.
#define D4DLCDHWFB_Y
D4D driver - resistive touch screen driver function header file.
#define D4D_COLOR_GET_R(color)
Definition: d4d_scheme.h:436