登录站点

用户名

密码

Segger emWin AT91SAM9261 16 Bits 4.3" 480 272

已有 1382 次阅读  2010-10-19 19:13   标签Bits  Segger  emWin 
/* PLA frequency */
#define MAIN_OSC_CLK (18432000UL)
#define MUL_PLLA          (109UL)
#define DIV_PLLA           (10UL)
#define PLLA_FREQ    ((MAIN_OSC_CLK * MUL_PLLA) / DIV_PLLA)

/* Further display controller values */
#define VL_PIXCLOCK  10000000

/*
#define VL_HSP       1
#define VL_VSP       2
#define VL_TFT       1
*/

#define VL_HPW       41     // HPW: Horizontal synchronization pulse width
#define VL_BLW       2      // HBP: Horizontal Back Porch
#define VL_ELW       2      // HFP: Horizontal Front Porch

#define VL_VPW       10     // VPW: Vertical Synchronization pulse width
#define VL_BFW       2      // VBP: Vertical Back Porch
#define VL_EFW       2      // VFP: Vertical Front Porch

#define VL_VHDLY     10     //  Number of cycles between VSYNC edge and HSYNC rising edge.

#if   (LCD_BITSPERPIXEL == 8)
  #define VL_BPIX      3
  #define SHIFT        0
#elif (LCD_BITSPERPIXEL == 16)
  #define VL_BPIX      4
  #define SHIFT        0
#elif (LCD_BITSPERPIXEL == 24)
  #define VL_BPIX      5
  #define SHIFT        1
#else
#error LCD_BITSPERPIXEL value is either unknown or not allowed
#endif

#define AT91C_MASTER_CLOCK_FOR_I2S (PLLA_FREQ / 2)

/* Display size */
#define _XSIZE           480uL
#define _YSIZE           272uL
//
// Physical display size
//
#define XSIZE_PHYS                480uL
#define YSIZE_PHYS                272uL
//
// Virtual display size
//
#define VXSIZE_PHYS               (XSIZE_PHYS)
#define VYSIZE_PHYS               (YSIZE_PHYS)

//
// Color conversion
//
#define COLOR_CONVERSION          GUICC_565

//
// Display driver
//
#define DISPLAY_DRIVER            GUIDRV_LIN_OSY_16

//
// Pixel width in bytes
//
#define PIXEL_WIDTH               2


*       _InitLCDController
*
* Function description:
*   Initializes the display controller
*/
static void _InitLCDController(unsigned LayerIndex) {
/*
  * Initialize port pins
  */
  AT91C_PIOB_PDR      = 0x001FFFEF;   // PIO Controller PIO Disable Register
  AT91C_PIOB_BSR      = 0x001FFFE0;   // PIO Peripheral B Select Register

  AT91C_PIOB_PER      = (1 << 4);
  AT91C_PIOB_OER      = (1 << 4);
  AT91C_PIOB_CODR     = (1 << 4);
  /*
  * Enable clock
  */
  AT91C_PMC_SCER      = (1 << 17);
  /*
  * Initialize LCDC registers
  */
  AT91C_LCDC_PWRCON   = 0x0C;
  AT91C_LCDC_DMACON   = 0;
  AT91C_LCDC_DMACON   = (1 << 1);
  AT91C_LCDC_LCDCON1  = ((((PLLA_FREQ / 2) / VL_PIXCLOCK + 1) / 2) - 1) << 12;
  AT91C_LCDC_LCDCON2  = ((U32)(1 << 31)
                      | (2<<0)
                      | (1 << 15))
                      | ((U32)(VL_BPIX << 5));

  // VHDLY: Vertical to horizontal delay : (0<<24)
  AT91C_LCDC_TIM1     = ((U32)((VL_VPW - 1) << 16))
                      | ((U32)((VL_VHDLY-1) << 24))
                      | ((U32)(VL_BFW << 8))
                      | ((U32)VL_EFW);

  AT91C_LCDC_TIM2     = ((U32)((VL_ELW - 1) << 21))
                      | ((U32)((VL_HPW - 1) << 8))
                      | ((U32)(VL_BLW - 1));

  AT91C_LCDC_LCDFRCFG = ((U32)((_XSIZE - 1) << 21))
                      | ((U32)(_YSIZE - 1) << (SHIFT));

  AT91C_LCDC_FIFO     = 512 - (2 * VL_BRSTLN + 3);

  AT91C_LCDC_MVAL     = 0;
  AT91C_LCDC_IDR      = ~0UL;

  AT91C_LCDC_CTRSTCON = 3
                      | (1 << 2)
                      | (1 << 3);

  AT91C_LCDC_CTRSTVAL = 0xDA;

  AT91C_LCDC_BA1      = (U32)(&_aVRAM[0]);

  AT91C_LCDC_FRMCFG   = ((U32)((VL_BRSTLN - 1) << 24))
                      | ((U32)_XSIZE * (U32)_YSIZE * (U32)(1 << VL_BPIX)) / 32;

  AT91C_LCDC_DMACON   = (1 << 0);

  AT91C_LCDC_PWRCON = (1 << 0) | 0x0C;

  // _InitTouch();
}

/*********************************************************************
*
*       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, required for Lin-driver
  //
  LCD_SetSizeEx    (0, XSIZE_PHYS,   YSIZE_PHYS);
  LCD_SetVSizeEx   (0, VXSIZE_PHYS,  VYSIZE_PHYS);
  LCD_SetVRAMAddrEx(0, (void*)((OS_U32)(&_aVRAM[0]) + OFFSET_VRAM));
  //
  // Set user palette data (only required if no fixed palette is used)
  //
  #if defined(PALETTE)
    LCD_SetLUTEx(0, PALETTE);
  #endif
}

上一篇: FatFS 学习笔记 下一篇: AT91SAM9261 JLink download

分享 举报