text: /*********************************************************************
  *                SEGGER Microcontroller GmbH & Co. KG                *
  *        Solutions for real time microcontroller applications        *
  **********************************************************************
  *                                                                    *
  *        (c) 1996 - 2016  SEGGER Microcontroller GmbH & Co. KG       *
  *                                                                    *
  *        Internet: www.segger.com    Support:  support@segger.com    *
  *                                                                    *
  **********************************************************************
  
  ** emWin V5.34 - Graphical user interface for embedded applications **
  All  Intellectual Property rights  in the Software belongs to  SEGGER.
  emWin is protected by  international copyright laws.  Knowledge of the
  source code may not be used to write a similar product.  This file may
  only be used in accordance with the following terms:
  
  The  software has  been licensed  to Silicon Labs Norway, a subsidiary
  of Silicon Labs Inc. whose registered office is 400 West Cesar Chavez,
  Austin,  TX 78701, USA solely for  the purposes of creating  libraries 
  for its  ARM Cortex-M3, M4F  processor-based devices,  sublicensed and 
  distributed  under the  terms and conditions  of the  End User License  
  Agreement supplied by Silicon Labs.
  Full source code is available at: www.segger.com
  
  We appreciate your understanding and fairness.
  ----------------------------------------------------------------------
  Licensing information
  
  Licensor:                 SEGGER Software GmbH
  Licensed to:              Silicon Laboratories Norway
  Licensed SEGGER software: emWin
  License number:           GUI-00140
  License model:            See Agreement, dated 20th April 2012
  Licensed product:         - 
  Licensed platform:        Cortex M3, Cortex M4F
  Licensed number of seats: -
  ----------------------------------------------------------------------
  File        : LCDConf.c
  Purpose     : Display controller configuration (single layer)
  ---------------------------END-OF-HEADER------------------------------
  */
  
  #include "GUI.h"
  #include "GUIDRV_Lin.h"
  
  /*********************************************************************
  *
  *       Layer configuration (to be modified)
  *
  **********************************************************************
  */
  //
  // Physical display size
  //
  #define XSIZE_PHYS 640
  #define YSIZE_PHYS 480
  
  //
  // Color conversion
  //
  #define COLOR_CONVERSION GUICC_565
  
  //
  // Display driver
  //
  #define DISPLAY_DRIVER GUIDRV_LIN_16
  
  /*********************************************************************
  *
  *       Configuration checking
  *
  **********************************************************************
  */
  #ifndef   VXSIZE_PHYS
    #define VXSIZE_PHYS XSIZE_PHYS
  #endif
  #ifndef   VYSIZE_PHYS
    #define VYSIZE_PHYS YSIZE_PHYS
  #endif
  #ifndef   VRAM_ADDR
    #define VRAM_ADDR 0
  #endif
  
  #ifndef   XSIZE_PHYS
    #error Physical X size of display is not defined!
  #endif
  #ifndef   YSIZE_PHYS
    #error Physical Y size of display is not defined!
  #endif
  #ifndef   COLOR_CONVERSION
    #error Color conversion not defined!
  #endif
  #ifndef   DISPLAY_DRIVER
    #error No display driver defined!
  #endif
  
  /*********************************************************************
  *
  *       Public code
  *
  **********************************************************************
  */
  /*********************************************************************
  *
  *       LCD_X_Config
  *
  * Purpose:
  *   Called during the initialization process in order to set up the
  *   display driver configuration.
  *   
  */
  void LCD_X_Config(void) {
    //
    // Set display driver and color conversion for 1st layer
    //
    GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);
    //
    // Display driver configuration
    //
    LCD_SetSizeEx    (0, XSIZE_PHYS,   YSIZE_PHYS);
    LCD_SetVSizeEx   (0, VXSIZE_PHYS,  VYSIZE_PHYS);
    LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR);
    //
    // Set user palette data (only required if no fixed palette is used)
    //
    #if defined(PALETTE)
      LCD_SetLUTEx(0, PALETTE);
    #endif
  }
  
  /*********************************************************************
  *
  *       LCD_X_DisplayDriver
  *
  * Purpose:
  *   This function is called by the display driver for several purposes.
  *   To support the according task the routine needs to be adapted to
  *   the display controller. Please note that the commands marked with
  *   'optional' are not cogently required and should only be adapted if 
  *   the display controller supports these features.
  *
  * Parameter:
  *   LayerIndex - Index of layer to be configured
  *   Cmd        - Please refer to the details in the switch statement below
  *   pData      - Pointer to a LCD_X_DATA structure
  *
  * Return Value:
  *   < -1 - Error
  *     -1 - Command not handled
  *      0 - Ok
  */
  int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
    int r;
  
    switch (Cmd) {
    //
    // Required
    //
    case LCD_X_INITCONTROLLER: {
      //
      // Called during the initialization process in order to set up the
      // display controller and put it into operation. If the display
      // controller is not initialized by any external routine this needs
      // to be adapted by the customer...
      //
      // ...
      return 0;
    }
    case LCD_X_SETVRAMADDR: {
      //
      // Required for setting the address of the video RAM for drivers
      // with memory mapped video RAM which is passed in the 'pVRAM' element of p
      //
      LCD_X_SETVRAMADDR_INFO * p;
      p = (LCD_X_SETVRAMADDR_INFO *)pData;
      //...
      return 0;
    }
    case LCD_X_SETORG: {
      //
      // Required for setting the display origin which is passed in the 'xPos' and 'yPos' element of p
      //
      LCD_X_SETORG_INFO * p;
      p = (LCD_X_SETORG_INFO *)pData;
      //...
      return 0;
    }
    case LCD_X_SETLUTENTRY: {
      //
      // Required for setting a lookup table entry which is passed in the 'Pos' and 'Color' element of p
      //
      LCD_X_SETLUTENTRY_INFO * p;
      p = (LCD_X_SETLUTENTRY_INFO *)pData;
      //...
      return 0;
    }
    case LCD_X_ON: {
      //
      // Required if the display controller should support switching on and off
      //
      return 0;
    }
    case LCD_X_OFF: {
      //
      // Required if the display controller should support switching on and off
      //
      // ...
      return 0;
    }
    default:
      r = -1;
    }
    return r;
  }
  
  /*************************** End of file ****************************/
  