Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GUIDRV_Lin_Private.h
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH & Co. KG * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2016 SEGGER Microcontroller GmbH & Co. KG * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.38 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to NXP Semiconductors USA, Inc. whose 00019 registered office is situated at 411 E. Plumeria Drive, San Jose, 00020 CA 95134, USA solely for the purposes of creating libraries for 00021 NXPs M0, M3/M4 and ARM7/9 processor-based devices, sublicensed and 00022 distributed under the terms and conditions of the NXP End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 00030 Licensor: SEGGER Microcontroller Systems LLC 00031 Licensed to: NXP Semiconductors, 1109 McKay Dr, M/S 76, San Jose, CA 95131, USA 00032 Licensed SEGGER software: emWin 00033 License number: GUI-00186 00034 License model: emWin License Agreement, dated August 20th 2011 00035 Licensed product: - 00036 Licensed platform: NXP's ARM 7/9, Cortex-M0,M3,M4 00037 Licensed number of seats: - 00038 ---------------------------------------------------------------------- 00039 File : GUIDRV_Lin_Private.h 00040 Purpose : Common definitions and common code for all LIN-drivers 00041 ---------------------------END-OF-HEADER------------------------------ 00042 */ 00043 00044 #ifndef GUIDRV_LIN_PRIVATE_H 00045 #define GUIDRV_LIN_PRIVATE_H 00046 00047 #include <string.h> 00048 00049 #if defined(__cplusplus) 00050 extern "C" { /* Make sure we have C-declarations in C++ programs */ 00051 #endif 00052 00053 /********************************************************************* 00054 * 00055 * Common definitions for all variants of the LIN driver 00056 * 00057 ********************************************************************** 00058 */ 00059 #if defined(WIN32) 00060 // 00061 // Simulation prototypes 00062 // 00063 U16 SIM_Lin_ReadMem16 (unsigned int Off); 00064 U32 SIM_Lin_ReadMem32 (unsigned int Off); 00065 U8 SIM_Lin_ReadMem08p (U8 * p); 00066 U32 SIM_Lin_ReadMem32p (U32 * p); 00067 void SIM_Lin_WriteMem16 (unsigned int Off, U16 Data); 00068 void SIM_Lin_WriteMem32 (unsigned int Off, U32 Data); 00069 void SIM_Lin_WriteMem08p(U8 * p, U8 Data); 00070 void SIM_Lin_WriteMem16p(U16 * p, U16 Data); 00071 void SIM_Lin_WriteMem32p(U32 * p, U32 Data); 00072 void SIM_Lin_memcpy (void * pDst, const void * pSrc, int Len); 00073 void SIM_Lin_memset (void * pDst, U8 Value, U32 Len); 00074 void SIM_Lin_SetVRAMAddr(int LayerIndex, void * pVRAM); 00075 void SIM_Lin_SetVRAMSize(int LayerIndex, int vxSize, int vySize, int xSize, int ySize); 00076 void SIM_Lin_CopyBuffer (int IndexSrc, int IndexDst); 00077 void SIM_Lin_ShowBuffer (int Index); 00078 // 00079 // Access macro definition for internal simulation 00080 // 00081 #define LCD_READ_MEM16(VRAMAddr, Off) SIM_Lin_ReadMem16(Off) 00082 #define LCD_READ_MEM32(VRAMAddr, Off) SIM_Lin_ReadMem32(Off) 00083 #define LCD_READ_MEM08P(p) SIM_Lin_ReadMem08p(p) 00084 #define LCD_READ_MEM32P(p) SIM_Lin_ReadMem32p(p) 00085 #define LCD_WRITE_MEM16(VRAMAddr, Off, Data) SIM_Lin_WriteMem16(Off, Data) 00086 #define LCD_WRITE_MEM32(VRAMAddr, Off, Data) SIM_Lin_WriteMem32(Off, Data) 00087 #define LCD_WRITE_MEM08P(p, Data) SIM_Lin_WriteMem08p(p, Data) 00088 #define LCD_WRITE_MEM16P(p, Data) SIM_Lin_WriteMem16p(p, Data) 00089 #define LCD_WRITE_MEM32P(p, Data) SIM_Lin_WriteMem32p(p, Data) 00090 #undef GUI_MEMCPY 00091 #define GUI_MEMCPY(pDst, pSrc, Len) SIM_Lin_memcpy(pDst, pSrc, Len) 00092 #undef GUI_MEMSET 00093 #define GUI_MEMSET(pDst, Value, Len) SIM_Lin_memset(pDst, Value, Len) 00094 #else 00095 // 00096 // Access macro definition for hardware 00097 // 00098 #define LCD_READ_MEM16(VRAMAddr, Off) (*((U16 *)VRAMAddr + (U32)Off)) 00099 #define LCD_READ_MEM32(VRAMAddr, Off) (*((U32 *)VRAMAddr + (U32)Off)) 00100 #define LCD_READ_MEM08P(p) (*((U8 *)p)) 00101 #define LCD_READ_MEM32P(p) (*((U32 *)p)) 00102 #define LCD_WRITE_MEM16(VRAMAddr, Off, Data) *((U16 *)VRAMAddr + (U32)Off) = (U16)(Data) 00103 #define LCD_WRITE_MEM32(VRAMAddr, Off, Data) *((U32 *)VRAMAddr + (U32)Off) = Data 00104 #define LCD_WRITE_MEM08P(p, Data) *((U8 *)p) = (U8)(Data) 00105 #define LCD_WRITE_MEM16P(p, Data) *((U16 *)p) = (U16)(Data) 00106 #define LCD_WRITE_MEM32P(p, Data) *((U32 *)p) = Data 00107 #endif 00108 00109 #ifndef WRITE_MEM16 00110 #define WRITE_MEM16(VRAMAddr, Off, Data) LCD_WRITE_MEM16(VRAMAddr, Off, Data) 00111 #endif 00112 #ifndef WRITE_MEM32 00113 #define WRITE_MEM32(VRAMAddr, Off, Data) LCD_WRITE_MEM32(VRAMAddr, Off, Data) 00114 #endif 00115 #ifndef READ_MEM08P 00116 #define READ_MEM08P(p) LCD_READ_MEM08P(p) 00117 #endif 00118 #ifndef READ_MEM16 00119 #define READ_MEM16(VRAMAddr, Off) LCD_READ_MEM16(VRAMAddr, Off) 00120 #endif 00121 #ifndef READ_MEM32 00122 #define READ_MEM32(VRAMAddr, Off) LCD_READ_MEM32(VRAMAddr, Off) 00123 #endif 00124 #ifndef READ_MEM32P 00125 #define READ_MEM32P(p) LCD_READ_MEM32P(p) 00126 #endif 00127 #ifndef WRITE_MEM08P 00128 #define WRITE_MEM08P(p, Data) LCD_WRITE_MEM08P(p, Data) 00129 #endif 00130 #ifndef WRITE_MEM16P 00131 #define WRITE_MEM16P(p, Data) LCD_WRITE_MEM16P(p, Data) 00132 #endif 00133 #ifndef WRITE_MEM32P 00134 #define WRITE_MEM32P(p, Data) LCD_WRITE_MEM32P(p, Data) 00135 #endif 00136 00137 #define OFF2PTR08(VRAMAddr, Off) (U8 *)((U8 *)VRAMAddr + (Off )) 00138 #define OFF2PTR16(VRAMAddr, Off) (U16 *)((U8 *)VRAMAddr + (Off << 1)) 00139 #define OFF2PTR32(VRAMAddr, Off) (U32 *)((U8 *)VRAMAddr + (Off << 2)) 00140 00141 // 00142 // Use unique context identified 00143 // 00144 #define DRIVER_CONTEXT DRIVER_CONTEXT_LIN 00145 00146 // 00147 // Definition of default members for DRIVER_CONTEXT structure 00148 // 00149 #define DEFAULT_CONTEXT_MEMBERS \ 00150 U32 VRAMAddr; \ 00151 U32 BaseAddr; \ 00152 int BufferIndex; \ 00153 int xSize, ySize; \ 00154 int vxSize, vySize; \ 00155 int vxSizePhys; \ 00156 int xPos, yPos; \ 00157 int Alpha; \ 00158 int IsVisible; \ 00159 void (* pfFillRect) (int /* LayerIndex */, \ 00160 int /* x0 */, \ 00161 int /* y0 */, \ 00162 int /* x1 */, \ 00163 int /* y1 */, \ 00164 U32 /* PixelIndex */); \ 00165 void (* pfCopyBuffer)(int /* LayerIndex */, \ 00166 int /* IndexSrc */, \ 00167 int /* IndexDst */); \ 00168 void (* pfDrawBMP1) (int /* LayerIndex */, \ 00169 int /* x */, \ 00170 int /* y */, \ 00171 U8 const * /* p */, \ 00172 int /* Diff */, \ 00173 int /* xSize */, \ 00174 int /* ySize */, \ 00175 int /* BytesPerLine */, \ 00176 const LCD_PIXELINDEX * /* pTrans */); \ 00177 void (* pfDrawBMP8) (int /* LayerIndex */, \ 00178 int /* x */, \ 00179 int /* y */, \ 00180 U8 const * /* p */, \ 00181 int /* xSize */, \ 00182 int /* ySize */, \ 00183 int /* BytesPerLine */, \ 00184 const LCD_PIXELINDEX * /* pTrans */); \ 00185 void (* pfCopyRect) (int /* LayerIndex */, \ 00186 int /* x0 */, \ 00187 int /* y0 */, \ 00188 int /* x1 */, \ 00189 int /* y1 */, \ 00190 int /* xSize */, \ 00191 int /* ySize */); \ 00192 void (* pfSetPos) (int /* LayerIndex */, \ 00193 int /* xPos */, \ 00194 int /* yPos */); 00195 00196 #ifndef PRIVATE_CONTEXT_MEMBERS 00197 #define PRIVATE_CONTEXT_MEMBERS 00198 #endif 00199 00200 // 00201 // Definition of default function management for _GetDevFunc() 00202 // 00203 #define DEFAULT_MANAGEMENT_GETDEVFUNC() \ 00204 case LCD_DEVFUNC_SET_VRAM_ADDR: \ 00205 return (void (*)(void))_SetVRAMAddr; \ 00206 case LCD_DEVFUNC_SET_VSIZE: \ 00207 return (void (*)(void))_SetVSize; \ 00208 case LCD_DEVFUNC_SET_SIZE: \ 00209 return (void (*)(void))_SetSize; \ 00210 case LCD_DEVFUNC_SETPOS: \ 00211 return (void (*)(void))_SetPos; \ 00212 case LCD_DEVFUNC_GETPOS: \ 00213 return (void (*)(void))_GetPos; \ 00214 case LCD_DEVFUNC_SETALPHA: \ 00215 return (void (*)(void))_SetAlpha; \ 00216 case LCD_DEVFUNC_SETVIS: \ 00217 return (void (*)(void))_SetVis; \ 00218 case LCD_DEVFUNC_INIT: \ 00219 return (void (*)(void))_Init; \ 00220 case LCD_DEVFUNC_ON: \ 00221 return (void (*)(void))_On; \ 00222 case LCD_DEVFUNC_OFF: \ 00223 return (void (*)(void))_Off; \ 00224 case LCD_DEVFUNC_ALPHAMODE: \ 00225 return (void (*)(void))_SetAlphaMode; \ 00226 case LCD_DEVFUNC_CHROMAMODE: \ 00227 return (void (*)(void))_SetChromaMode; \ 00228 case LCD_DEVFUNC_CHROMA: \ 00229 return (void (*)(void))_SetChroma; \ 00230 case LCD_DEVFUNC_COPYBUFFER: \ 00231 return (void (*)(void))_CopyBuffer; \ 00232 case LCD_DEVFUNC_SHOWBUFFER: \ 00233 return (void (*)(void))_ShowBuffer; \ 00234 case LCD_DEVFUNC_SETFUNC: \ 00235 return (void (*)(void))_SetDevFunc; \ 00236 case LCD_DEVFUNC_FILLRECT: \ 00237 return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfFillRect; \ 00238 case LCD_DEVFUNC_DRAWBMP_1BPP: \ 00239 return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfDrawBMP1; \ 00240 case LCD_DEVFUNC_DRAWBMP_8BPP: \ 00241 return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfDrawBMP8; \ 00242 case LCD_DEVFUNC_COPYRECT: \ 00243 return (void (*)(void))((DRIVER_CONTEXT *)(*ppDevice)->u.pContext)->pfCopyRect; 00244 00245 // 00246 // Definition of private function management for _GetDevFunc() 00247 // 00248 #ifndef PRIVATE_MANAGEMENT_GETDEVFUNC 00249 #define PRIVATE_MANAGEMENT_GETDEVFUNC() 00250 #endif 00251 00252 // 00253 // Definition of default function management for _SetDevFunc() 00254 // 00255 #define DEFAULT_MANAGEMENT_SETDEVFUNC() \ 00256 case LCD_DEVFUNC_FILLRECT: \ 00257 pContext->pfFillRect = (void (*)(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex))pFunc; \ 00258 break; \ 00259 case LCD_DEVFUNC_COPYBUFFER: \ 00260 pContext->pfCopyBuffer = (void (*)(int LayerIndex, int IndexSrc, int IndexDst))pFunc; \ 00261 break; \ 00262 case LCD_DEVFUNC_DRAWBMP_1BPP: \ 00263 pContext->pfDrawBMP1 = (void (*)(int LayerIndex, int x, int y, U8 const * p, int Diff, int xSize, int ySize, int BytesPerLine, const LCD_PIXELINDEX * pTrans))pFunc; \ 00264 break; \ 00265 case LCD_DEVFUNC_DRAWBMP_8BPP: \ 00266 pContext->pfDrawBMP8 = (void (*)(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine, const LCD_PIXELINDEX * pTrans))pFunc; \ 00267 break; \ 00268 case LCD_DEVFUNC_COPYRECT: \ 00269 pContext->pfCopyRect = (void (*)(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize))pFunc; \ 00270 break; \ 00271 case LCD_DEVFUNC_SETPOS: \ 00272 pContext->pfSetPos = (void (*)(int LayerIndex, int xPos, int yPos))pFunc; \ 00273 break; 00274 00275 // 00276 // Definition of private function management for _GetDevFunc() 00277 // 00278 #ifndef PRIVATE_MANAGEMENT_SETDEVFUNC 00279 #define PRIVATE_MANAGEMENT_SETDEVFUNC() 00280 #endif 00281 00282 // 00283 // Endian related definitions 00284 // 00285 #ifndef LCD_MIRROR 00286 #define LCD_MIRROR 0 00287 #endif 00288 00289 #if (LCD_MIRROR == 2) 00290 #define MIRROR(x) x = ((x & 0x000000ffUL) << 8) \ 00291 | ((x & 0x0000ff00UL) >> 8) \ 00292 | ((x & 0x00ff0000UL) << 8) \ 00293 | ((x & 0xff000000UL) >> 8) 00294 #else 00295 #define MIRROR(x) x = ((x & 0x000000ffUL) << 24) \ 00296 | ((x & 0x0000ff00UL) << 8) \ 00297 | ((x & 0x00ff0000UL) >> 8) \ 00298 | ((x & 0xff000000UL) >> 24) 00299 #endif 00300 00301 /********************************************************************* 00302 * 00303 * Types 00304 * 00305 ********************************************************************** 00306 */ 00307 // 00308 // DRIVER_CONTEXT structure consisting of default and private members 00309 // 00310 typedef struct { 00311 DEFAULT_CONTEXT_MEMBERS 00312 PRIVATE_CONTEXT_MEMBERS 00313 } DRIVER_CONTEXT; 00314 00315 /********************************************************************* 00316 * 00317 * Static code (common for all) 00318 * 00319 ********************************************************************** 00320 */ 00321 /********************************************************************* 00322 * 00323 * _InitOnce 00324 * 00325 * Purpose: 00326 * Allocates a fixed block for the context of the driver 00327 * 00328 * Return value: 00329 * 0 on success, 1 on error 00330 */ 00331 static int _InitOnce(GUI_DEVICE * pDevice) { 00332 if (pDevice->u.pContext == NULL) { 00333 pDevice->u.pContext = GUI_ALLOC_GetFixedBlock(sizeof(DRIVER_CONTEXT)); 00334 GUI__memset((U8 *)pDevice->u.pContext, 0, sizeof(DRIVER_CONTEXT)); 00335 } 00336 return pDevice->u.pContext ? 0 : 1; 00337 } 00338 00339 /********************************************************************* 00340 * 00341 * _GetRect 00342 * 00343 * Purpose: 00344 * Returns the display size. 00345 */ 00346 static void _GetRect(GUI_DEVICE * pDevice, LCD_RECT * pRect) { 00347 DRIVER_CONTEXT * pContext; 00348 00349 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00350 pRect->x0 = 0; 00351 pRect->y0 = 0; 00352 pRect->x1 = pContext->vxSize - 1; 00353 pRect->y1 = pContext->vySize - 1; 00354 } 00355 00356 /********************************************************************* 00357 * 00358 * _SetVis 00359 * 00360 * Purpose: 00361 * Sets the visibility of the given layer by sending a LCD_X_SETVIS command to LCD_X_DisplayDriver() 00362 * (Requires special hardware support.) 00363 */ 00364 static void _SetVis(GUI_DEVICE * pDevice, int OnOff) { 00365 DRIVER_CONTEXT * pContext; 00366 LCD_X_SETVIS_INFO Data = {0}; 00367 00368 _InitOnce(pDevice); 00369 if (pDevice->u.pContext) { 00370 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00371 pContext->IsVisible = OnOff; 00372 Data.OnOff = OnOff; 00373 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETVIS, (void *)&Data); 00374 } 00375 } 00376 00377 /********************************************************************* 00378 * 00379 * _SetPos 00380 * 00381 * Purpose: 00382 * Sets the position of the given layer by sending a LCD_X_SETPOS command to LCD_X_DisplayDriver() 00383 * (Requires special hardware support.) 00384 */ 00385 static void _SetPos(GUI_DEVICE * pDevice, int xPos, int yPos) { 00386 DRIVER_CONTEXT * pContext; 00387 int xSizeDisplay, ySizeDisplay, xSizeLayer, ySizeLayer, BitsPerPixel; 00388 LCD_X_SETPOS_INFO PosInfo = {0}; 00389 00390 _InitOnce(pDevice); 00391 if (pDevice->u.pContext) { 00392 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00393 if (pContext->pfSetPos) { 00394 // 00395 // Use custom callback to setlayer position 00396 // 00397 pContext->pfSetPos(pDevice->LayerIndex, xPos, yPos); 00398 } else { 00399 // 00400 // Calculate xPos/yPos and new layer size 00401 // 00402 pContext->xPos = xPos; 00403 pContext->yPos = yPos; 00404 00405 xSizeDisplay = LCD_GetXSizeDisplay(); 00406 ySizeDisplay = LCD_GetYSizeDisplay(); 00407 xSizeLayer = pContext->xSize; 00408 ySizeLayer = pContext->ySize; 00409 BitsPerPixel = pDevice->pDeviceAPI->pfGetDevProp(pDevice, LCD_DEVCAP_BITSPERPIXEL); 00410 PosInfo.BytesPerPixel = (BitsPerPixel + 7) / 8; 00411 if (xPos < 0) { 00412 PosInfo.Off -= xPos * PosInfo.BytesPerPixel; 00413 PosInfo.xPos = 0; 00414 PosInfo.xLen = xSizeLayer + xPos; 00415 } else { 00416 PosInfo.xPos = xPos; 00417 PosInfo.xLen = xSizeLayer; 00418 if ((PosInfo.xPos + PosInfo.xLen) > xSizeDisplay) { 00419 PosInfo.xLen = xSizeDisplay - xPos; 00420 } 00421 } 00422 if (yPos < 0) { 00423 PosInfo.Off -= yPos * PosInfo.BytesPerPixel * xSizeLayer; 00424 PosInfo.yPos = 0; 00425 PosInfo.yLen = ySizeLayer + yPos; 00426 } else { 00427 PosInfo.yPos = yPos; 00428 PosInfo.yLen = ySizeLayer; 00429 if ((PosInfo.yPos + PosInfo.yLen) > ySizeDisplay) { 00430 PosInfo.yLen = ySizeDisplay - yPos; 00431 } 00432 } 00433 if ((PosInfo.xLen <= 0) || (PosInfo.yLen <= 0) || (PosInfo.xPos >= xSizeDisplay) || (PosInfo.yPos >= ySizeDisplay)) { 00434 if (pContext->IsVisible == 1) { 00435 _SetVis(pDevice, 0); 00436 } 00437 return; 00438 } 00439 if (pContext->IsVisible == 0) { 00440 _SetVis(pDevice, 1); 00441 } 00442 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETPOS, (void *)&PosInfo); 00443 } 00444 } 00445 } 00446 00447 /********************************************************************* 00448 * 00449 * _GetPos 00450 * 00451 * Purpose: 00452 * Returns the position of the given layer. 00453 */ 00454 static void _GetPos(GUI_DEVICE * pDevice, int * pxPos, int * pyPos) { 00455 DRIVER_CONTEXT * pContext; 00456 00457 _InitOnce(pDevice); 00458 if (pDevice->u.pContext) { 00459 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00460 *pxPos = pContext->xPos; 00461 *pyPos = pContext->yPos; 00462 } 00463 } 00464 00465 /********************************************************************* 00466 * 00467 * _SetAlpha 00468 * 00469 * Purpose: 00470 * Sets the alpha value of the given layer by sending a LCD_X_SETALPHA command to LCD_X_DisplayDriver() 00471 * (Requires special hardware support.) 00472 */ 00473 static void _SetAlpha(GUI_DEVICE * pDevice, int Alpha) { 00474 DRIVER_CONTEXT * pContext; 00475 LCD_X_SETALPHA_INFO Data = {0}; 00476 00477 _InitOnce(pDevice); 00478 if (pDevice->u.pContext) { 00479 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00480 pContext->Alpha = Alpha; 00481 Data.Alpha = Alpha; 00482 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETALPHA, (void *)&Data); 00483 } 00484 } 00485 00486 /********************************************************************* 00487 * 00488 * _Init 00489 * 00490 * Purpose: 00491 * Called during the initialization process of emWin. 00492 */ 00493 static int _Init(GUI_DEVICE * pDevice) { 00494 int r; 00495 00496 r = _InitOnce(pDevice); 00497 r |= LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_INITCONTROLLER, NULL); 00498 return r; 00499 } 00500 00501 /********************************************************************* 00502 * 00503 * _On 00504 * 00505 * Purpose: 00506 * Sends a LCD_X_ON command to LCD_X_DisplayDriver(). 00507 */ 00508 static void _On (GUI_DEVICE * pDevice) { 00509 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_ON, NULL); 00510 } 00511 00512 /********************************************************************* 00513 * 00514 * _Off 00515 * 00516 * Purpose: 00517 * Sends a LCD_X_OFF command to LCD_X_DisplayDriver(). 00518 */ 00519 static void _Off (GUI_DEVICE * pDevice) { 00520 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_OFF, NULL); 00521 } 00522 00523 /********************************************************************* 00524 * 00525 * _SetAlphaMode 00526 * 00527 * Purpose: 00528 * Sets the alpha mode of the given layer by sending a LCD_X_SETALPHAMODE command to LCD_X_DisplayDriver() 00529 * (Requires special hardware support.) 00530 */ 00531 static void _SetAlphaMode(GUI_DEVICE * pDevice, int AlphaMode) { 00532 LCD_X_SETALPHAMODE_INFO Data = {0}; 00533 00534 Data.AlphaMode = AlphaMode; 00535 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETALPHAMODE, (void *)&Data); 00536 } 00537 00538 /********************************************************************* 00539 * 00540 * _SetChromaMode 00541 * 00542 * Purpose: 00543 * Sets the chroma mode of the given layer by sending a LCD_X_SETCHROMAMODE command to LCD_X_DisplayDriver() 00544 * (Requires special hardware support.) 00545 */ 00546 static void _SetChromaMode(GUI_DEVICE * pDevice, int ChromaMode) { 00547 LCD_X_SETCHROMAMODE_INFO Data = {0}; 00548 00549 Data.ChromaMode = ChromaMode; 00550 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETCHROMAMODE, (void *)&Data); 00551 } 00552 00553 /********************************************************************* 00554 * 00555 * _SetChroma 00556 * 00557 * Purpose: 00558 * Sets the chroma values of the given layer by sending a LCD_X_SETCHROMA command to LCD_X_DisplayDriver() 00559 * (Requires special hardware support.) 00560 */ 00561 static void _SetChroma(GUI_DEVICE * pDevice, LCD_COLOR ChromaMin, LCD_COLOR ChromaMax) { 00562 LCD_X_SETCHROMA_INFO Data = {0}; 00563 00564 Data.ChromaMin = ChromaMin; 00565 Data.ChromaMax = ChromaMax; 00566 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETCHROMA, (void *)&Data); 00567 } 00568 00569 /********************************************************************* 00570 * 00571 * _CopyBuffer 00572 * 00573 * Purpose: 00574 * Copies the source buffer to the destination buffer and routes 00575 * further drawing operations to the destination buffer. 00576 * 00577 * (Required for using multiple buffers) 00578 */ 00579 static void _CopyBuffer(GUI_DEVICE * pDevice, int IndexSrc, int IndexDst) { 00580 DRIVER_CONTEXT * pContext; 00581 #if (!defined(WIN32)) 00582 U32 AddrSrc, AddrDst; 00583 I32 BufferSize; 00584 int BitsPerPixel; 00585 #endif 00586 00587 _InitOnce(pDevice); 00588 if (pDevice->u.pContext) { 00589 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00590 if (IndexSrc != IndexDst) { 00591 #if defined(WIN32) 00592 SIM_Lin_CopyBuffer(IndexSrc, IndexDst); 00593 #else 00594 BitsPerPixel = pDevice->pDeviceAPI->pfGetDevProp(pDevice, LCD_DEVCAP_BITSPERPIXEL); 00595 BufferSize = (((U32)pContext->xSize * pContext->ySize * BitsPerPixel) >> 3); 00596 AddrSrc = pContext->BaseAddr + BufferSize * IndexSrc; 00597 AddrDst = pContext->BaseAddr + BufferSize * IndexDst; 00598 if (pContext->pfCopyBuffer) { 00599 // 00600 // Use custom callback function for copy operation 00601 // 00602 pContext->pfCopyBuffer(pDevice->LayerIndex, IndexSrc, IndexDst); 00603 } else { 00604 // 00605 // Calculate pointers for copy operation 00606 // 00607 GUI_MEMCPY((void *)AddrDst, (void *)AddrSrc, BufferSize); 00608 } 00609 // 00610 // Set destination buffer as target for further drawing operations 00611 // 00612 pContext->VRAMAddr = AddrDst; 00613 #endif 00614 } 00615 } 00616 } 00617 00618 /********************************************************************* 00619 * 00620 * _ShowBuffer 00621 * 00622 * Purpose: 00623 * Sends a LCD_X_SHOWBUFFER command to LCD_X_DisplayDriver() to make the given buffer visible. 00624 * 00625 * (Required for using multiple buffers) 00626 */ 00627 static void _ShowBuffer(GUI_DEVICE * pDevice, int Index) { 00628 LCD_X_SHOWBUFFER_INFO Data = {0}; 00629 00630 _InitOnce(pDevice); 00631 if (pDevice->u.pContext) { 00632 #if defined(WIN32) 00633 SIM_Lin_ShowBuffer(Index); 00634 #else 00635 Data.Index = Index; 00636 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SHOWBUFFER, (void *)&Data); 00637 #endif 00638 } 00639 } 00640 00641 /********************************************************************* 00642 * 00643 * _SetOrg 00644 * 00645 * Purpose: 00646 * Calls the driver callback function with the display origin to be set 00647 */ 00648 static void _SetOrg(GUI_DEVICE * pDevice, int x, int y) { 00649 #if (!defined(WIN32)) 00650 DRIVER_CONTEXT * pContext; 00651 int Orientation; 00652 #endif 00653 LCD_X_SETORG_INFO Data = {0}; 00654 00655 #if defined(WIN32) 00656 LCDSIM_SetOrg(x, y, pDevice->LayerIndex); 00657 #else 00658 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00659 Orientation = LCD_GetMirrorXEx(pDevice->LayerIndex) * GUI_MIRROR_X; 00660 Orientation |= LCD_GetMirrorYEx(pDevice->LayerIndex) * GUI_MIRROR_Y; 00661 Orientation |= LCD_GetSwapXYEx (pDevice->LayerIndex) * GUI_SWAP_XY; 00662 switch (Orientation) { 00663 case 0: 00664 Data.xPos = x; 00665 Data.yPos = y; 00666 break; 00667 case GUI_MIRROR_X: 00668 Data.xPos = pContext->vxSize - pContext->xSize - x; 00669 Data.yPos = y; 00670 break; 00671 case GUI_MIRROR_Y: 00672 Data.xPos = x; 00673 Data.yPos = pContext->vySize - pContext->ySize - y; 00674 break; 00675 case GUI_MIRROR_X | GUI_MIRROR_Y: 00676 Data.xPos = pContext->vxSize - pContext->xSize - x; 00677 Data.yPos = pContext->vySize - pContext->ySize - y; 00678 break; 00679 case GUI_SWAP_XY: 00680 Data.xPos = y; 00681 Data.yPos = x; 00682 break; 00683 case GUI_SWAP_XY | GUI_MIRROR_X: 00684 Data.xPos = pContext->vySize - pContext->ySize - y; 00685 Data.yPos = x; 00686 break; 00687 case GUI_SWAP_XY | GUI_MIRROR_Y: 00688 Data.xPos = y; 00689 Data.yPos = pContext->vxSize - pContext->xSize - x; 00690 break; 00691 case GUI_SWAP_XY | GUI_MIRROR_X | GUI_MIRROR_Y: 00692 Data.xPos = pContext->vySize - pContext->ySize - y; 00693 Data.yPos = pContext->vxSize - pContext->xSize - x; 00694 break; 00695 } 00696 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETORG, (void *)&Data); 00697 #endif 00698 } 00699 00700 /********************************************************************* 00701 * 00702 * _SetVRAMAddr 00703 */ 00704 static void _SetVRAMAddr(GUI_DEVICE * pDevice, void * pVRAM) { 00705 DRIVER_CONTEXT * pContext; 00706 LCD_X_SETVRAMADDR_INFO Data = {0}; 00707 00708 _InitOnce(pDevice); 00709 if (pDevice->u.pContext) { 00710 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00711 pContext->VRAMAddr = pContext->BaseAddr = (U32)pVRAM; 00712 Data.pVRAM = pVRAM; 00713 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETVRAMADDR, (void *)&Data); 00714 } 00715 #if defined(WIN32) 00716 SIM_Lin_SetVRAMAddr(pDevice->LayerIndex, pVRAM); 00717 #endif 00718 } 00719 00720 /********************************************************************* 00721 * 00722 * _SetVSize 00723 */ 00724 static void _SetVSize(GUI_DEVICE * pDevice, int xSize, int ySize) { 00725 DRIVER_CONTEXT * pContext; 00726 #if defined(WIN32) 00727 int NumBuffers; 00728 #endif 00729 00730 _InitOnce(pDevice); 00731 if (pDevice->u.pContext) { 00732 #if defined(WIN32) 00733 NumBuffers = GUI_MULTIBUF_GetNumBuffers(); 00734 #endif 00735 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00736 if (LCD_GetSwapXYEx(pDevice->LayerIndex)) { 00737 #if defined(WIN32) 00738 pContext->vxSize = xSize * NumBuffers; 00739 #else 00740 pContext->vxSize = xSize; 00741 #endif 00742 pContext->vySize = ySize; 00743 pContext->vxSizePhys = ySize; 00744 } else { 00745 pContext->vxSize = xSize; 00746 #if defined(WIN32) 00747 pContext->vySize = ySize * NumBuffers; 00748 #else 00749 pContext->vySize = ySize; 00750 #endif 00751 pContext->vxSizePhys = xSize; 00752 } 00753 } 00754 #if defined(WIN32) 00755 SIM_Lin_SetVRAMSize(pDevice->LayerIndex, pContext->vxSize, pContext->vySize, pContext->xSize, pContext->ySize); 00756 #endif 00757 } 00758 00759 /********************************************************************* 00760 * 00761 * _SetSize 00762 */ 00763 static void _SetSize(GUI_DEVICE * pDevice, int xSize, int ySize) { 00764 DRIVER_CONTEXT * pContext; 00765 LCD_X_SETSIZE_INFO Data = {0}; 00766 00767 _InitOnce(pDevice); 00768 if (pDevice->u.pContext) { 00769 pContext = (DRIVER_CONTEXT *)pDevice->u.pContext; 00770 if (pContext->vxSizePhys == 0) { 00771 if (LCD_GetSwapXYEx(pDevice->LayerIndex)) { 00772 pContext->vxSizePhys = ySize; 00773 } else { 00774 pContext->vxSizePhys = xSize; 00775 } 00776 } 00777 pContext->xSize = xSize; 00778 pContext->ySize = ySize; 00779 Data.xSize = xSize; 00780 Data.ySize = ySize; 00781 LCD_X_DisplayDriver(pDevice->LayerIndex, LCD_X_SETSIZE, (void *)&Data); 00782 } 00783 } 00784 00785 #if defined(__cplusplus) 00786 } 00787 #endif 00788 00789 #endif /* GUIDRV_LIN_PRIVATE_H */ 00790 00791 /*************************** End of file ****************************/
Generated on Wed Jul 20 2022 15:03:44 by
